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]

Attributes#

Functions#

deserialize_pipeline(...)

Reconstruct a pipeline from a serialized configuration dictionary.

load_pipeline(...)

Load a pipeline from a YAML or JSON file.

save_pipeline(→ None)

Serialize a pipeline and write it to a YAML or JSON file.

serialize_pipeline(→ dict[str, Any])

Serialize a pipeline to a configuration dictionary.

Module Contents#

physicsnemo_curator.core.serialization.deserialize_pipeline(
data: dict[str, Any],
) 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:

Pipeline

physicsnemo_curator.core.serialization.load_pipeline(
path: str | pathlib.Path,
) physicsnemo_curator.core.base.Pipeline[Any][source]#

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:

Pipeline

Raises:
physicsnemo_curator.core.serialization.save_pipeline(
pipeline: physicsnemo_curator.core.base.Pipeline[Any],
path: str | pathlib.Path,
) None[source]#

Serialize a pipeline and write it to a YAML or JSON file.

The format is determined by the file extension: .yaml / .yml for YAML, .json for JSON. Parent directories are created automatically.

Parameters:
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],
) dict[str, Any][source]#

Serialize a pipeline to a configuration dictionary.

Calls _pipeline_config() and adds version and metadata keys. Ensures the sink key is always present (set to None when the pipeline has no sink).

The metadata section captures provenance information (package version, git hash, timestamp, platform) and is purely informational — it is ignored on deserialization.

Parameters:

pipeline (Pipeline) – The pipeline to serialize.

Returns:

Serialized pipeline configuration with keys version, metadata, source, filters, and sink.

Return type:

dict[str, Any]

physicsnemo_curator.core.serialization.logger#