Pipeline¶
- class ionworkspipeline.Pipeline(elements, output_file=None, name=None, description=None)¶
A pipeline is a sequence of pipeline elements, each of which takes a set of parameters as input and returns a set of parameters as output. The output of one element is the input of the next. The pipeline can be run to generate a set of parameters, and a report can be generated to document the pipeline.
Parameters¶
- elementsdict of {str: _PipelineElement}
A dictionary of pipeline elements. The name is used to identify the element in the report.
- output_filestr, optional
The file to save the parameters to. If None, the parameters are not saved.
- namestr, optional
A name for the pipeline. Useful for identification and reporting.
- descriptionstr, optional
A description of what the pipeline does.
Extends:
ConfigMixinSee also:
Pipeline— field-level documentation.- classmethod from_schema(schema)¶
Construct a
Pipelinefrom a validatedionworks_schema.Pipeline.Each entry in
schema.elementsis dispatched to the matching pipeline element’sfrom_schemabased on the schema class hierarchy:DirectEntry-style schemas,DirectEntryFunctionSchemawrappers,DataFit/ArrayDataFit,Validation, andCalculationare each handled. Pre-built pipeline elements pass through unchanged; raw dicts are forwarded as-is.Parameters¶
- schemaionworks_schema.Pipeline
Validated schema describing the pipeline elements and metadata.
Returns¶
- Pipeline
Pipeline whose elements are pipeline-side instances ready to run.
- run() ParameterValues¶
Execute all pipeline elements sequentially to generate parameters.
Each element receives the accumulated ParameterValues and returns new parameters to add. Results are combined and optionally saved to a file.
Returns¶
- iwp.ParameterValues
Complete set of parameters generated by the pipeline.
Examples¶
Build and run a parameter pipeline:
>>> geom_params = iwp.ParameterValues({ ... "Positive electrode capacity [A.h]": 3.0, ... "Positive electrode active material volume fraction": 0.65, ... "Positive electrode thickness [m]": 80e-6, ... "Electrode area [m2]": 0.1, ... }) >>> pipeline = iwp.Pipeline({ ... "geometry": iwp.direct_entries.DirectEntry(geom_params, "Datasheet"), ... "capacity": iwp.calculations.ElectrodeCapacity( ... "positive", use_stoich_window=False ... ), ... }) >>> result = pipeline.run() >>> float(result["Maximum concentration in positive electrode [mol.m-3]"]) > 0 True
Every step a pipeline runs is a PipelineElement.
- class ionworkspipeline.pipeline.PipelineElement(source: str | None)¶
Base class for pipeline elements. Provides methods for generating a report and latex source code.
Parameters¶
- sourcestr
The source of the pipeline element, e.g. a reference to a paper or a description of the method used to generate the parameters.
Extends:
OptionsController- run(parameter_values: ParameterValues) ParameterValues¶
Execute the pipeline element.
Parameters¶
- parameter_valuesParameterValues
Input parameters. Must be ParameterValues object.
Returns¶
- ParameterValues
New parameters to add to pipeline.
Elements capture their constructor arguments through
ConfigMixin, which is what makes
to_config() round-trip.
- class ionworkspipeline.controllers.ConfigMixin¶
Mixin that automatically captures __init__ parameters for subclasses.
When a class inherits from this mixin, any subclass that defines its own __init__ method will have its parameters automatically captured and stored in self._init_params. This is useful for serialization/deserialization (e.g., to_config methods for reverse parsing).
Additionally, if the __init__ has an “options” parameter, it captures which option keys were explicitly passed in self._options_keys_passed before calling the original __init__.
The captured parameters exclude self and filter out None values.
Example¶
>>> class MyClass(ConfigMixin): ... def __init__(self, a, b=None, c=10): ... self.a = a ... self.c = c ... >>> obj = MyClass(1, c=20) >>> obj._init_params {'a': 1, 'c': 20}
See also:
ConfigMixin— field-level documentation.- classmethod from_schema(schema)¶
Construct from a validated ionworks_schema instance.
Forwards the schema’s fields as kwargs to
cls(...), converting any field that holds a nested schema to its runtime counterpart (detected from the values, not declared). Subclasses whose construction needs more (runtime-only fields, alias remapping, deferred parsing) still override.
- class ionworkspipeline.controllers.OptionsController¶
Gives a class an
optionsdict validated against its own defaults.
Common pipelines¶
Collections of pre-defined pipelines for common tasks.