pycsamt.pipeline._base#
Base class for pyCSAMT pipeline objects.
PipelineBase is the common ancestor for Pipeline (and any
future pipeline variant). It provides three groups of functionality that are
domain-specific to the pipeline subsystem and would not fit naturally into
PyCSAMTObject (which targets lightweight
config/style objects).
Why not inherit PyCSAMTObject?#
PyCSAMTObject gives generic __repr__, to_dict, and summary
built for dataclass-style config holders. Pipeline needs a specialized
scikit-learn-style repr and its own serialization contract (to_yaml,
to_json, to_py). Inheriting from two incompatible repr contracts
creates confusion; a clean separation is better.
Groups provided#
Registry access (static / class methods) Explore what steps are available without constructing a pipeline.
Export (instance methods)
to_py(path)— new format that produces an editable Python script (YAML and JSON are onPipelineitself).Scaffold (class method)
scaffold(path, fmt, preset, name)— generate a ready-to-edit starter config in YAML, JSON, or Python.
Classes
Base class for pyCSAMT pipeline objects. |
- class pycsamt.pipeline._base.PipelineBase[source]#
Bases:
objectBase class for pyCSAMT pipeline objects.
Inherit from this to gain registry introspection,
to_pyexport, andscaffoldtemplate generation.Pipelineinherits this.- static available_steps(category=None)[source]#
Return all registered
StepSpecobjects.- Parameters:
category (str | None) – When supplied, restrict to steps in that category (e.g.
"noise_removal","frequency").- Return type:
Examples
>>> Pipeline.available_steps() >>> Pipeline.available_steps("static_shift")
- static available_categories()[source]#
Return a sorted list of step category names.
Examples
>>> Pipeline.available_categories() ['dimensionality', 'frequency', 'noise_removal', ...]
- static step_info(code_or_name)[source]#
Return a formatted info block for a single step.
- Parameters:
code_or_name (str) – Registry code (
"NR001") or snake-case name ("notch_powerline").- Return type:
Examples
>>> print(Pipeline.step_info("NR001")) >>> print(Pipeline.step_info("correct_ss_ama"))
- classmethod catalogue(category=None)[source]#
Return a full formatted catalogue of all available steps.
- Parameters:
category (str | None) – Restrict output to one category, or
Nonefor all.- Return type:
Examples
>>> print(Pipeline.catalogue()) >>> print(Pipeline.catalogue("tensor"))
- to_py(path=None)[source]#
Serialize this pipeline to a Python config script.
Produces a
pipeline_configdict in a clean, readable.pyfile that can be edited and reloaded withfrom_py(). Steps are grouped by category and commented with their human-readable labels.- Parameters:
path (str | Path | None) – If given, write the output to this file path.
- Returns:
The generated Python source as a string (always returned, whether or not path is provided).
- Return type:
Examples
>>> src = pipe.to_py() >>> print(src) >>> pipe.to_py("config/my_workflow.py")
- classmethod scaffold(path=None, *, fmt='yaml', preset=None, name='my_workflow', outdir='pipe_results')[source]#
Generate a ready-to-edit starter pipeline config.
The scaffold contains: - Active steps from preset (or a sensible default set) - All other available steps commented out with descriptions
- Parameters:
path (str | Path | None) – Write the output to this file. Extension is inferred from fmt if the path has none.
fmt (str) – Output format:
"yaml"(default),"json", or"py".preset (str | None) – Name of a built-in preset to use as the active step set (e.g.
"basic_qc","full_processing"). WhenNonea minimalbasic_qc-style set is used.name (str) – Pipeline name written into the config.
outdir (str) – Default output directory written into the config.
- Returns:
The generated config content as a string.
- Return type:
Examples
>>> print(Pipeline.scaffold()) >>> Pipeline.scaffold("config/starter.yaml", preset="full_processing") >>> Pipeline.scaffold("config/starter.py", fmt="py")