Python SDK
cfdl_sdk compiles and runs CFDL models from Python with pandas accessors
over the results. The compiler and engine are embedded in-process as a Rust
extension module — no separate binary or server, and results are
byte-identical to the CLI's.
Install
See Install for Python. Short version, from a checkout:
pip install -e "python/[dev,viz]".
Quickstart
import cfdl_sdk
results = cfdl_sdk.run(
"examples/cre_developer",
packs_dir="packs",
config="examples/cre_developer/run.base.json",
)
results.cashflows() # wide DataFrame: one column per stream, PeriodIndex
results.metrics() # flat Series of core + domain metrics
results.metrics_frame() # metric / value / currency / source(core|domain:<pack>)
results.scenarios() # one row per scenario (when the run declares them)
results.monte_carlo() # per-metric summary stats (mean/stdev/percentiles)
results.annual() # annual rollup, when presentconfig accepts a dict, a path to a run-config JSON file, or a raw JSON
string. pack (for domain metrics) is auto-detected from a pack file in
the model directory, or can be passed explicitly. compile() and
Model.run() are available separately when you want to reuse compiled IR.
Compile problems raise CompileError with structured .diagnostics
(code, message, span); runtime problems raise RunError.
Notebooks
Four notebooks, one per domain, built on the benchmark models. Each is published here with the outputs and chart it produced, so you can read the SDK's DataFrame surface on a real model before installing anything:
Each opens in Google Colab from the badge at the top of the page — Colab installs the SDK and fetches the models on the first cell, so nothing is needed locally.
To run them on your own machine:
pip install "cfdl-sdk[notebooks]"
git clone --depth 1 https://github.com/cfdl-dev/cfdl
jupyter lab cfdl/examples/notebooksThe clone supplies the benchmark models and pack definitions the notebooks read; the SDK itself comes from PyPI.