serialization#
Pipeline serialization and deserialization to YAML and JSON formats.
Provides functions to serialize a Pipeline
to a dictionary, save it to disk (YAML or JSON), and reconstruct a live pipeline
from saved configuration. Class resolution uses importlib and parameter
coercion relies on Param.type() declarations from each component’s
params() classmethod.
Examples
>>> from physicsnemo_curator.core.serialization import save_pipeline, load_pipeline
>>> save_pipeline(pipeline, "my_pipeline.yaml")
>>> restored = load_pipeline("my_pipeline.yaml")
>>> restored[0]
Functions#
|
Reconstruct a pipeline from a serialized configuration dictionary. |
|
Load a pipeline from a YAML or JSON file. |
|
Serialize a pipeline and write it to a YAML or JSON file. |
|
Serialize a pipeline to a configuration dictionary. |
Module Contents#
- physicsnemo_curator.core.serialization.deserialize_pipeline( ) physicsnemo_curator.core.base.Pipeline[Any][source]#
Reconstruct a pipeline from a serialized configuration dictionary.
- Parameters:
data (dict[str, Any]) – Serialized pipeline config (as produced by
serialize_pipeline()).- Returns:
A fully reconstructed pipeline with source, filters, and optional sink.
- Return type:
- physicsnemo_curator.core.serialization.load_pipeline(
- path: str | pathlib.Path,
Load a pipeline from a YAML or JSON file.
- Parameters:
path (str | pathlib.Path) – Path to the serialized pipeline file.
- Returns:
The deserialized pipeline.
- Return type:
- Raises:
FileNotFoundError – If the file does not exist.
ValueError – If the file extension is not supported.
- physicsnemo_curator.core.serialization.save_pipeline(
- pipeline: physicsnemo_curator.core.base.Pipeline[Any],
- path: str | pathlib.Path,
Serialize a pipeline and write it to a YAML or JSON file.
The format is determined by the file extension:
.yaml/.ymlfor YAML,.jsonfor JSON. Parent directories are created automatically.- Parameters:
pipeline (Pipeline) – The pipeline to save.
path (str | pathlib.Path) – Destination file path.
- Raises:
ValueError – If the file extension is not
.yaml,.yml, or.json.
- physicsnemo_curator.core.serialization.serialize_pipeline(
- pipeline: physicsnemo_curator.core.base.Pipeline[Any],
Serialize a pipeline to a configuration dictionary.
Calls
_pipeline_config()and adds aversionkey. Ensures thesinkkey is always present (set toNonewhen the pipeline has no sink).