from_yaml
from_yaml(path, *, check_paths=True)Read a YAML file into a spec: the same object from_dict builds, by the same rules.
One pipeline, two ways in. A specification written by hand and one read from a file are the same thing, and save_spec() turns it back - which is how a worked example can write out the YAML of the run it has just done, beside the results. This sentence named as_dict() until 2026-10-11, a method no spec has ever had; the way back did not exist at all, which is what platypus#120 was filed about.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| path | str | Path | The file to read. | required |
| check_paths | bool | As for from_dict. |
True |
Returns
| Name | Type | Description |
|---|---|---|
| PlatypusSpec | A SegmentationSpec or a DetectionSpec, whichever task names. |
Raises
| Name | Type | Description |
|---|---|---|
| ConfigError | If the file is missing, is not valid YAML, is empty, or describes a configuration with problems. Each is said with the path, so the reader knows which file to open. |
import pathlib, tempfile lines = [ … ‘task: semantic_segmentation’, … ‘data:’, … ’ train_path: train/‘, …’ validation_path: valid/‘, …’ colormap: [[0, 0, 0], [255, 255, 255]]‘, … ’models:’, … ’ - name: unet’, … ’ architecture: u_net’, … ’ input_shape: [256, 256]’, … ] path = pathlib.Path(tempfile.mkdtemp()) / “run.yaml” _ = path.write_text(“”.join(lines)) spec = from_yaml(path, check_paths=False) spec.models[0].name, spec.models[0].input_shape (‘unet’, (256, 256))