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.pipeline — both
this client’s PipelineClient.create() method and the backend route
parse against the same schema, so a payload that builds with
iw.pipeline.Pipeline(...) validates identically end-to-end.
- class ionworks.api.pipeline.PipelineSubmissionMetadata(*, project_id: str | None = None, options: dict[str, Any] | None = None)[source]¶
Bases:
BaseModelSDK-only metadata attached to a pipeline submission.
These fields are not part of
ionworks.pipeline.Pipelinebecause they describe how the submission is routed (which project, which runtime options) rather than what the pipeline does.- resolve_project_id() PipelineSubmissionMetadata[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().
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ionworks.api.pipeline.DataFitResponse(*, parameter_values: dict[str, Any])[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.api.pipeline.CalculationResponse(*, parameter_values: dict[str, Any])[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.api.pipeline.EntryResponse(*, parameter_values: dict[str, Any])[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.api.pipeline.PipelineSubmissionResponse(*, url: str | None = None, api_url: str | None = None, id: str, name: str, description: str | None = None, project_id: str | None = None, status: str, error: str | None = None, is_terminal: bool, is_failed: bool)[source]¶
Bases:
ResourceLinksResponse 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.api.pipeline.PipelineResponse(*, result: dict[str, Any], element_results: dict[str, Any])[source]¶
Bases:
BaseModelComplete response from retrieving pipeline results.
resultandelement_resultsare the raw dicts returned by the backend, unchanged.element()andresultsadditionally decode those raw per-element dicts into typedionworks.pipelineresult objects (lazily, cached), wiring up overlay/trace/posterior fetchers per element.- __init__(**data: Any) None[source]¶
Build the response, accepting the back-refs as keyword arguments.
Pydantic silently drops underscore-prefixed keyword arguments, so
client/pipeline_idare popped here and assigned to their private attributes. Passing them at construction keeps a response from ever existing without them — the lazy fetchers no-op on a missing client, which would otherwise surface much later as an empty overlay.- Parameters:
**data – The backend’s response fields, plus optional
client(HTTP client) andpipeline_id.
- element(name: str) ionworks.pipeline.BaseResults[source]¶
Return the typed
ionworks.pipelineresult for a named element.Decodes
element_results[name]into the matchingionworks.pipelineresult class (see_coerce_element_result()) and caches it. The overlay / trace / posterior fetchers are bound to the element’s job.- Parameters:
name (str) – The element name (the key used in
element_results).- Returns:
The typed result object.
- Return type:
ionworks.pipeline.BaseResults
- Raises:
ValueError – If no element with the given name exists in the pipeline.
- property results: dict[str, TypeAliasForwardRef('ionworks.pipeline.BaseResults')]¶
Typed results for every element, keyed by element name (cached).
- model_config = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class ionworks.api.pipeline.PipelineClient(client: Any)[source]¶
Bases:
objectClient for creating and managing pipeline workflows.
- __init__(client: Any) None[source]¶
Initialize the pipeline client.
- Parameters:
client (Any) – The HTTP client to use for API requests.
- create(config: TypeAliasForwardRef('ionworks.pipeline.Pipeline') | dict[str, Any], *, project_id: str | None = None, name: str | None = None, description: str | None = None, options: dict[str, Any] | None = None) PipelineSubmissionResponse[source]¶
Run a complete pipeline with the given configuration.
- Parameters:
config (ionworks.pipeline.Pipeline or dict[str, Any]) – Pipeline configuration. Either an
iw.pipeline.Pipelineschema instance (constructed viaiw.pipeline.Pipeline(elements=...)) or a dict withelements,name,descriptionand SDK-only fields such asproject_id/options. Dicts are validated againstiw.pipeline.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: str, name: str | None = None, description: str | None = None) PipelineSubmissionResponse[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: str | None = None, limit: int | None = None, offset: int | None = None, id: str | None = None, name: str | None = None, description: str | None = None, status: str | None = None, created_by_email: str | None = None, created_at: str | None = None, updated_at: str | None = None, created_at_gt: str | None = None, created_at_lt: str | None = None, updated_at_gt: str | None = None, updated_at_lt: str | None = None, order_by: str | None = None, order: str | None = None) PaginatedList[PipelineSubmissionResponse][source]¶
List pipelines for a project.
- Parameters:
project_id (str | None, optional) – 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, optional) – Maximum number of pipelines to return. If not provided, returns all pipelines (up to the API’s default limit).
offset (int | None, optional) – Number of pipelines to skip for pagination. Sent to the API as
skip— the/pipelinesroute’s wire name for this parameter — while keepingoffsetas the Python name for consistency with the SDK’s otherlist()methods.id (str | None, optional) – Optional filters. Pass values directly for exact match or use Supabase operator syntax (e.g.
"ilike.%foo%","in.(completed,failed)").name (str | None, optional) – Optional filters. Pass values directly for exact match or use Supabase operator syntax (e.g.
"ilike.%foo%","in.(completed,failed)").description (str | None, optional) – Optional filters. Pass values directly for exact match or use Supabase operator syntax (e.g.
"ilike.%foo%","in.(completed,failed)").status (str | None, optional) – Optional filters. Pass values directly for exact match or use Supabase operator syntax (e.g.
"ilike.%foo%","in.(completed,failed)").created_by_email (str | None, optional) – Optional filters. Pass values directly for exact match or use Supabase operator syntax (e.g.
"ilike.%foo%","in.(completed,failed)").created_at (str | None, optional) – Optional Supabase-operator filter on the timestamp field (e.g.
"gte.2025-01-01").updated_at (str | None, optional) – Optional Supabase-operator filter on the timestamp field (e.g.
"gte.2025-01-01").created_at_gt – str | None, optional Inclusive lower / upper bounds for between-style date queries.
created_at_lt – str | None, optional Inclusive lower / upper bounds for between-style date queries.
updated_at_gt – str | None, optional Inclusive lower / upper bounds for between-style date queries.
updated_at_lt – str | None, optional Inclusive lower / upper bounds for between-style date queries.
order_by (str | None, optional) – Sort column. One of
id,name,description,status,created_at,updated_at,created_by_email. Falls back to the API’s default (created_at).order (str | None, optional) – Sort direction (
"asc"or"desc"). Falls back to the API’s default ("desc").
- Returns:
A list-like page of pipeline submission responses, with
.countand.totalfor pagination.- Return type:
- Raises:
ValueError – If response data is not a list or project_id is missing.
- get(job_id: str) PipelineSubmissionResponse[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: str) PipelineResponse[source]¶
Get the result for the given job id.
- Parameters:
job_id (str) – The job id.
- Returns:
The pipeline results.
- Return type:
- list_elements(pipeline_id: str, *, summary: bool = False) list[dict[str, Any]][source]¶
List a pipeline’s elements in run order, with each one’s config and result.
Pass
summary=Truefor metadata without configuration or result data.
- get_element_job_config(element_id: str) dict[str, Any][source]¶
Get one element’s full
job_config.list_elements()leaves the larger keys (parameters,optimizer,cost) out of each element’sjob_config; this returns them: the fixed parameter values, the fitted parameters and their bounds, and the optimizer settings.- Parameters:
element_id (str) – The element’s
id, aslist_elements()returns it.- Returns:
The element’s
job_config, or{}for an element that does not exist or that you cannot see.- Return type:
- cancel(pipeline_id: str) PipelineSubmissionResponse[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: str) None[source]¶
Delete a pipeline, its elements, associated jobs, and storage files.
- Parameters:
pipeline_id (str) – The pipeline ID to delete.
- get_element_metadata(pipeline_id: str, element_name: str, elements: list[dict[str, Any]] | None = None) dict[str, Any][source]¶
Fetch the metadata blob for a named element of a pipeline.
Locates the element by name, then delegates to
client.job.get_metadata. Use it for fields stripped fromelement.resultand persisted to storage instead — for example thevalidation_plot_configa validation element writes.Not for a validation element’s time series: those are stored per objective rather than on this blob. Use
get_element_series_channels()andget_element_series(), which cost one objective rather than all of them.- 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).
- get_element_series_channels(pipeline_id: str, element_name: str, elements: list[dict[str, Any]] | None = None) dict[str, dict[str, list[str]]][source]¶
List an element’s validation-series objectives and their channels.
Delegates to
get_series_channels()for the element’s job. Names only, no samples — call it beforeget_element_series()to learn which objectives exist, which channels each carries, and which of the two solves it has.- Parameters:
pipeline_id (str) – The pipeline whose element to describe.
element_name (str) – Name of the element within the pipeline.
elements (list[dict], optional) – Pre-fetched elements list, as for
get_element_metadata().
- Returns:
{objective: {source: [channel, ...]}}.- Return type:
- get_element_series(pipeline_id: str, element_name: str, objective: str, elements: list[dict[str, Any]] | None = None, **kwargs: Any) dict[str, list][source]¶
Get one objective’s model-vs-data series from a named element.
Delegates to
get_series()for the element’s job. This is the way to read a validation element’s time series: it reads one objective rather than the element’s whole metadata blob.- Parameters:
pipeline_id (str) – The pipeline whose element to read.
element_name (str) – Name of the element within the pipeline.
objective (str) – Objective name, as listed by
get_element_series_channels().elements (list[dict], optional) – Pre-fetched elements list, as for
get_element_metadata().**kwargs – Passed through to
get_series()—source,columns,x_column,max_points,x_min,x_max.
- Returns:
One list per channel, all of equal length, keyed by channel name.
- Return type:
- wait_for_completion(pipeline_id: str, timeout: int = 600, poll_interval: int = 2, verbose: bool = True, raise_on_failure: bool = True) PipelineSubmissionResponse[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 the pipeline fails or is canceled (default: True).
- Returns:
The terminal pipeline response (failed / canceled included when raise_on_failure=False).
- Return type:
- Raises:
TimeoutError – If timeout is reached before the pipeline reaches a terminal state.
IonworksError – If the pipeline failed or was canceled and raise_on_failure is True.