upxo.pxtal.fm_steel_3d.ensemble_seed_config module
Ensemble seed-config files: a pipeline run’s configuration, written and read back.
A seed-config file records the full configuration of a completed pipeline run
(config) and a first-pass grouping of its keys by pipeline stage
(injection_points), so that a later tool can vary the parameters of one
stage while holding the others fixed, e.g. re-roll the PAG texture and keep
the base-grain morphology. The groupings in INJECTION_POINT_KEYS are not
exhaustive: a key that is not listed still appears in config.
Schema evolution: whenever a field is added, renamed or removed, bump
CURRENT_SCHEMA_VERSION and add a _migrate_v{N}_to_v{N+1}(payload)
function to _MIGRATIONS, so that files written by an older version keep
loading.
- exception upxo.pxtal.fm_steel_3d.ensemble_seed_config.EnsembleSeedConfigError[source]
Bases:
ExceptionRaised when a seed-config file can’t be loaded or understood.
- upxo.pxtal.fm_steel_3d.ensemble_seed_config.load_ensemble_seed_config(path)[source]
Load, validate, and (if needed) migrate an ensemble seed-config JSON file.
- Parameters:
path (str or Path)
- Returns:
The payload, guaranteed to be at CURRENT_SCHEMA_VERSION and to contain at least: schema_version, generated_at, seed_name, notes, pipeline_mode, config, injection_points.
- Return type:
- Raises:
EnsembleSeedConfigError – If the file is missing, malformed, missing required keys, was written by a newer schema version than this code understands, or no migration path exists from its schema_version to the current one.
- upxo.pxtal.fm_steel_3d.ensemble_seed_config.list_ensemble_seed_configs(directory)[source]
Return sorted Path objects for every *.json file in directory that looks like an ensemble seed-config (has a readable ‘schema_version’). Unreadable/unrelated .json files are silently skipped, not raised.
- upxo.pxtal.fm_steel_3d.ensemble_seed_config.write_ensemble_seed_config(config, out_dir, seed_name='seed', notes='', pipeline_mode=None, injection_points=None)[source]
Write a seed-config file
<out_dir>/<seed_name>_<n>.json.nis the lowest index not yet used for this name, and the file is created exclusively, so an existing file is never overwritten. Characters ofseed_nameother than letters, digits,_and-become_.- Parameters:
config (dict) – The full configuration of the run (written as
config).out_dir (str or Path) – Created if it does not exist.
pipeline_mode (str, optional) – Taken from
config['pipeline_mode'](else ‘block’) when not given.injection_points (dict, optional) –
{stage: {key: value}}. By default the keys ofconfiglisted inINJECTION_POINT_KEYSfor each stage.
- Returns:
pathlib.Path
- Return type:
the file written.
- Raises:
OSError – If the directory or file can’t be created.