Pipeline#
Client for managing pipelines with data fitting, calculations, and validation.
For usage examples and guides, see Simulate API on docs.ionworks.com.
Pipeline client for running parameterization workflows.
This module provides the PipelineClient for creating and managing
pipelines that combine data fitting, calculations, and validation steps
for battery model parameterization.
Pipeline shape validation is delegated to ionworks_schema — both
this client’s PipelineClient.create() method and the backend route
parse against the same schema, so a payload that builds with
iws.Pipeline(...) validates identically end-to-end.
- class ionworks.pipeline.PipelineSubmissionMetadata(*, project_id=None, options=None)[source]#
Bases:
BaseModelSDK-only metadata attached to a pipeline submission.
These fields are not part of
ionworks_schema.Pipelinebecause they describe how the submission is routed (which project, which runtime options) rather than what the pipeline does.- resolve_project_id()[source]#
Resolve project_id from env vars if not provided.
Prefers
IONWORKS_PROJECT_ID; falls back to the deprecatedPROJECT_ID(with aDeprecationWarning) viaresolve_env_project_id().- Return type:
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ionworks.pipeline.DataFitResponse(*, parameter_values)[source]#
Bases:
BaseModelResponse from a data fitting step containing fitted parameters.
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ionworks.pipeline.CalculationResponse(*, parameter_values)[source]#
Bases:
BaseModelResponse from a calculation step containing calculated parameters.
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ionworks.pipeline.ValidationResponse(*, validation_results, summary_stats)[source]#
Bases:
BaseModelResponse from a validation step containing validation results.
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ionworks.pipeline.EntryResponse(*, parameter_values)[source]#
Bases:
BaseModelResponse from an entry point containing parameter values.
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ionworks.pipeline.PipelineSubmissionResponse(*, id, name, description=None, status, error=None)[source]#
Bases:
BaseModelResponse from submitting a pipeline to the API.
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ionworks.pipeline.PipelineResponse(*, result, element_results)[source]#
Bases:
BaseModelComplete response from retrieving pipeline results.
- model_config = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ionworks.pipeline.PipelineClient(client)[source]#
Bases:
objectClient for creating and managing pipeline workflows.
- Parameters:
client (Any)
- __init__(client)[source]#
Initialize the pipeline client.
- Parameters:
client (Any) – The HTTP client to use for API requests.
- Return type:
None
- create(config, *, project_id=None, name=None, description=None, options=None)[source]#
Run a complete pipeline with the given configuration.
- Parameters:
config (ionworks_schema.Pipeline or dict[str, Any]) – Pipeline configuration. Either an
iws.Pipelineschema instance (constructed viaiws.Pipeline(elements=...)) or a dict withelements,name,descriptionand SDK-only fields such asproject_id/options. Dicts are validated againstiws.Pipelinebefore submission so shape errors surface locally.project_id (str, optional) – Project to submit to. Falls back to a
project_idfield onconfig(dict form), then to thePROJECT_IDenv var.name (str, optional) – Submission name override. Falls back to the schema’s
namefield.description (str, optional) – Submission description override. Falls back to the schema’s
descriptionfield.options (dict[str, Any], optional) – Submission options (e.g.
{"live_progress_updates": True}). Falls back toconfig["options"](dict form).
- Returns:
The pipeline submission response.
- Return type:
- Raises:
ValueError – If the configuration is invalid.
- update(pipeline_id, name=None, description=None)[source]#
Partially update a pipeline’s name and/or description.
This is a metadata-only update: it cannot modify the pipeline’s config or affect a running job.
- Parameters:
- Returns:
The updated record.
- Return type:
- Raises:
ValueError – If neither
namenordescriptionis provided.
- list(project_id=None, limit=None)[source]#
List all pipelines.
- Parameters:
project_id (str | None) – The project id to filter pipelines. If not provided, uses the project_id set on the Ionworks client or the IONWORKS_PROJECT_ID environment variable.
limit (int | None) – Maximum number of pipelines to return. If not provided, returns all pipelines (up to the API’s default limit).
- Returns:
List of pipeline submission responses.
- Return type:
- Raises:
ValueError – If response data is not a list or project_id is missing.
- get(job_id)[source]#
Get the pipeline response for the given job id.
- Parameters:
job_id (str) – The job id.
- Returns:
The pipeline submission response.
- Return type:
- result(job_id)[source]#
Get the result for the given job id.
- Parameters:
job_id (str) – The job id.
- Returns:
The pipeline results.
- Return type:
- cancel(pipeline_id)[source]#
Cancel a running pipeline and all its non-terminal elements.
- Parameters:
pipeline_id (str) – The pipeline ID to cancel.
- Returns:
The updated record (status will be
canceledif cancellation took effect; otherwise the current state is returned).- Return type:
- delete(pipeline_id)[source]#
Delete a pipeline, its elements, associated jobs, and storage files.
- Parameters:
pipeline_id (str) – The pipeline ID to delete.
- Return type:
None
- get_element_metadata(pipeline_id, element_name, elements=None)[source]#
Fetch the metadata blob for a named element of a pipeline.
Locates the element by name in the pipeline’s elements list, then delegates to
client.job.get_metadatafor the underlying job. Use this when you need fields that are stripped fromelement.resultand persisted to storage instead — for example,validation_resultsandvalidation_plot_configwritten by a validation element.- Parameters:
pipeline_id (str) – The pipeline whose element metadata to fetch.
element_name (str) – The name of the element within the pipeline — the key used in the
elementsdict at submission time. Element names are user-chosen and unique per pipeline (a pipeline may run multiple validation elements under names like"validate_pristine"and"validate_aged").elements (list[dict], optional) – Pre-fetched elements list from
GET /pipelines/{id}/elements. Pass this when pulling metadata for several elements of the same pipeline to avoid re-fetching the list on every call. When omitted, the list is fetched fresh.
- Returns:
The parsed metadata payload for the element’s job.
- Return type:
- Raises:
ValueError – If the pipeline has no element with the given name, or that element has no associated job (e.g. it never ran).
- wait_for_completion(pipeline_id, timeout=600, poll_interval=2, verbose=True, raise_on_failure=True)[source]#
Wait for a pipeline to complete by polling until done or timeout.
- Parameters:
pipeline_id (str) – The pipeline ID to wait for.
timeout (int, optional) – Maximum time to wait in seconds (default: 600).
poll_interval (int, optional) – Time between polls in seconds (default: 2).
verbose (bool, optional) – Whether to print status updates (default: True).
raise_on_failure (bool, optional) – Whether to raise IonworksError when pipeline fails (default: True).
- Returns:
The completed (or failed, if raise_on_failure=False) pipeline response.
- Return type:
- Raises:
TimeoutError – If timeout is reached before the pipeline completes.
IonworksError – If the pipeline fails and raise_on_failure is True.