Skip to main content
The ionworks-api Python package exposes client.pipeline for running and managing pipelines. For installation and authentication, see the Python API client page.

Submitting a pipeline

client.pipeline.create() accepts either an iws.Pipeline schema instance or the dict returned by .to_config(). Schema instances are validated locally before submission, so shape errors surface immediately.

Serializing a pipeline to JSON

Use .to_config() when you want to inspect, cache, or transport the pipeline payload as JSON — for example to review it before submission, commit it to version control, or hand it off to another process.
.to_config() is the only supported serializer. It emits the discriminators pipeline elements and objectives need (top-level elements are keyed on element_type, and nested schemas carry their own type), and emits each field under its wire name (for example, data_inputdata).Do not use Pydantic’s model_dump() to build API payloads. model_dump() drops these discriminators and emits Python attribute names instead of wire names, so it produces a dict the API may reject.

Overriding submission metadata

create() accepts optional project_id, name, description, and options kwargs that override any values carried on the schema:
When project_id is omitted, the client falls back to the default configured on Ionworks(...) or the IONWORKS_PROJECT_ID environment variable.

Waiting for completion

Pass raise_on_failure=False to get the failed submission response back instead of raising when the pipeline errors out.

Retrieving results

result.element_results mirrors the keys you passed to iws.Pipeline(elements=...).

Element metadata

Some elements (notably Validation) write extra metadata that isn’t included in element_results. Fetch it with:

Data-fit parameter trace

Data-fit elements log the optimizer’s per-iteration progress to the element’s job metadata. Pull it down with client.job.get_parameter_trace using the element’s job ID — see Inspecting the parameter trace for the full schema. The element’s job_id lives in the pipeline’s elements list rather than in element_results, so fetch the list and pick out the data-fit element by name:

Data-fit model-vs-data plot data

client.job.get_plot_data returns the model-vs-data traces for a data-fit job — the same overlay Studio renders on the fit’s results page. A data-fit re-runs a validation on its best-fit parameters and stores the overlay in its own metadata, so you can fetch it directly from the fit’s job ID without adding a separate Validation element or parsing the raw metadata blob.
Use this when you want to reproduce the fit overlay in a notebook or report, or feed it into your own plotting pipeline. Traces are decimated server-side to at most max_points points per series (default 2000, range 10010000). For semantic zoom — refetching more detail as a user zooms in — pass x_min and x_max set to the current viewport:

Listing pipelines

Getting a single submission

SimplePipeline

A SimplePipeline is a lightweight alternative to Pipeline for workflows with at most one expensive element — a single DataFit or Validation. It runs fire-and-forget and returns a flat result containing parameter_values, cost, and (for validation) summary_stats. Submit and poll it through client.simple_pipeline.

Building the config

SimplePipeline inherits everything from Pipeline and adds client-side validation that rejects configs with more than one expensive element:
If you pass more than one DataFit or Validation element, SimplePipeline raises a ValueError immediately — no need to wait for a server-side rejection.

Submitting and polling

client.simple_pipeline.create() mirrors client.pipeline.create() — it accepts either an iws.SimplePipeline schema instance or the dict returned by .to_config(). Prefer the schema instance: you don’t need to call .to_config() yourself, and shape errors surface locally when you build the schema object. A raw dict is forwarded as-is, so a malformed dict is only rejected server-side as an HTTP 422.

Validation pipelines

SimplePipeline also supports a single Validation element. The result includes summary_stats alongside parameter_values.

End-to-end example

For more end-to-end examples (entry-only, calculation-only, datafit, validation), see packages/ionworks-api/examples/pipeline/ in the SDK repo.