Skip to content

Home

pfig logo pfig logo

CI PyPI version License: Apache 2.0

A tiny, strict DSL for declarative Python object configuration

pfig separates what you build (algorithm) from how you run it (environment). Built for ML workflows.

Install

pip install pfig

Until the first PyPI release is published, install from the repository:

pip install git+https://github.com/pfig-dev/pfig.git

For a complete walkthrough, see Getting Started.

Quick Example

# config.pfig
import torch
from train import Model, Trainer

include "./consts.pfig" as consts
external device

model = Model(hidden_size=@consts/hidden_size)
trainer = Trainer(model=@model, epochs=@consts/epochs, device=@device)
__entrypoint__ = @trainer.fit
pfig run config.pfig --set device=cuda

Security

pfig configs are trusted inputs. Running pfig validate, pfig run, or loading a bundle/replay snapshot can import Python modules, instantiate objects, clone git repositories, and install dependencies. See SECURITY.md.

Key Features

  • Providers: Lazy recipes with @name (shared) and @name() (fresh) instances
  • Includes: Modular configs with include "./base.pfig" as base
  • Externals: Runtime environment separation
  • Overrides: Config layering with override base/param = value
  • Snapshots: Automatic reproducibility tracking with Git state and environment capture
  • CLI: Validate, run, diff, fmt, bundle, and replay commands

Formatting

pfig fmt rewrites .pfig files to a canonical style. See the CLI reference.

Editor and AI agent support

  • pfig install-rules: Install agent rules for Cursor, Claude Code, or Codex — see CLI reference
  • LSP server: Diagnostics, go-to-definition, hover, completion, signature help, and semantic tokens — see LSP API
  • VS Code: Syntax highlighting via the vscode-pfig extension

Get Started

Resources

  • 🔗 Repository - Source code and issue tracking
  • 📚 Examples - Working examples and use cases
  • 🐛 Issues - Report bugs or request features
  • 🤝 Contributing - How to contribute to pfig

pfig: Explicit wiring, zero magic