load_bundle
Open a .sdsge archive and reconstruct its components. Equivalent to SymbolicDSGE.bundle.build_from; load_bundle is the friendlier top-level alias.
load_bundle is re-exported at SymbolicDSGE root.
Inputs:
| Name | Description |
|---|---|
| path | Path to the .sdsge file. |
Returns:
| Type | Description |
|---|---|
LoadedBundle |
Container with manifest, reference/dgp (re-solved models), estimation artifacts, mc artifacts, and the optional simulation prefill. See LoadedBundle. |
Behavior:
- Read
manifest.jsonand validatesdsge_version. - Walk every member declared in the manifest:
- YAML models are re-parsed and re-compiled+solved using stored
compile_kwargs/solve_kwargs. - Estimation / MC text members are parsed back into their respective dataclasses.
- CSV / Parquet members are dispatched by
Member.formatand decoded into numpy arrays.
- YAML models are re-parsed and re-compiled+solved using stored
- Inline
SimSpecis read from the manifest itself.
Format-agnostic reader
load_bundle dispatches each tabular member on Member.format. A hand-zipped CSV-only bundle and a CLI-built Parquet bundle both load through the same path. No [bundle] extra is required — parquet-engine is a regular dependency.
Re-solve cost
Loading runs the full parse → compile → solve pipeline once per model member. For large models or scripts that open many bundles in a loop, cache the LoadedBundle rather than reopening.
Example
from SymbolicDSGE import load_bundle
loaded = load_bundle("experiment-1.sdsge")
print(loaded.manifest.created_by)
if loaded.reference is not None:
print(loaded.reference.policy.stab == 0)
In-code authoring counterpart
SolvedModel.save_sdsge(
path: str | Path,
*,
yaml_text: str | None = None, # (1)!
role: str = "reference",
compile_kwargs: Mapping[str, Any] | None = None,
solve_kwargs: Mapping[str, Any] | None = None,
) -> Path
- Override the YAML embedded in the bundle. Defaults to
compiled.config.source_yaml(populated byModelParser).
Convenience wrapper around SolvedModel.to_bundle_builder for the model-only case. For bundles that include estimation / MC / sim members, call to_bundle_builder and chain the additions.
SolvedModel.to_bundle_builder(
*,
yaml_text: str | None = None,
role: str = "reference",
compile_kwargs: Mapping[str, Any] | None = None,
solve_kwargs: Mapping[str, Any] | None = None,
created_by: str | None = None,
) -> BundleBuilder
Return a BundleBuilder pre-seeded with the model's YAML. Chain estimation / MC / simulation members, then call .write() to materialize the archive.
Source YAML required
to_bundle_builder raises ValueError if compiled.config.source_yaml is None and no yaml_text= override is given. ModelParser(path) and ModelParser.from_string(text) both populate source_yaml automatically; programmatically constructed ModelConfig instances do not.
See also
BundleBuilder— assemble bundles from code.LoadedBundle— the return type.sdsge-decompile— the CLI counterpart.- Bundle Loading Guide — full walkthrough.