---
agent:
  instructions: "Use this search API to find relevant content across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://segmentstream.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Pipeline SDK

Load source rows, transform warehouse tables and run the selected assets together as a job.

## What you can build

- [Ingest and transform rows](https://segmentstream.com/docs/sdk/pipeline#load-one-order-and-calculate-revenue)

  Declare a source table and a model with typed inputs, outputs and partitioning.

- [Refresh a set of assets](https://segmentstream.com/docs/sdk/pipeline#run-the-job-and-check-the-output)

  Select a model and its upstream dependencies for a repeatable job.

- [Schedule or replay work](https://segmentstream.com/docs/jobs-and-workflows)

  Run a refresh on a schedule and inspect or repeat a run.

## Start in the pipeline package

Use the workspace’s pipeline/ Python project and the warehouse extra in its pyproject.toml. The distribution is segmentstream-pipeline. Its Python import is segmentstream. The example uses the starter’s existing warehouse connection.

## Load one order and calculate revenue

The ingestion emits one row. The model receives the orders table by argument name and compiles the aggregation to warehouse SQL. Register both assets and a job in the pipeline definitions, merging with existing definitions if the workspace already has jobs.

pipeline/definitions.py

```
from collections.abc import Iterator

import ibis.expr.types as ir
import segmentstream as s

@s.ingestion(
    tier=s.Tier.Bronze, partitioning=s.Partitioning.Unpartitioned,
    schema={"amount": "float64"},
)
def orders() -> Iterator[s.IngestionRow]:
    yield {"amount": 25.0}

@s.model(
    tier=s.Tier.Gold, partitioning=s.Partitioning.Unpartitioned,
    schema={"total_revenue": "float64"},
)
def revenue(orders: ir.Table) -> ir.Table:
    return orders.aggregate(total_revenue=orders.amount.sum())

defs = s.definitions(
    assets=[orders, revenue],
    jobs=[s.job("revenue", assets=[revenue], include_upstream=True)],
)
```

## Run the job and check the output

After deploying the pipeline to a workspace with its warehouse configured, run the revenue job and inspect the run. The revenue table should contain one row with total_revenue equal to 25.0. The upstream selection makes the job refresh orders first.

Terminal

```
segmentstream job run revenue
segmentstream job runs revenue
```

## Selected API methods and types

### Declare a source · `ingestion`

Declare source ingestion returning an Ibis table or yielding schema-checked rows. The lineage group defaults to the first declared connection key, falling back to "ingestion". Use '/'-separated segments such as group="google_ads/pmax" to nest the asset in the lineage UI. Assign a concurrency pool with pool="meta_ads" and declare its limit in s.definitions(pools=...).

```
ingestion(*, tier: Tier | Missing=MISSING, partitioning: PartitionChoice | Missing=MISSING, mode: IngestionModeChoice | None=None, key: str | None=None, inputs: Mapping[str, AssetReference] | None=None, deps: Sequence[Dependency]=(), group: str | None=None, pool: str | None=None, description: str | None=None, connections: Sequence[str]=(), secrets: Sequence[str]=(), retry_policy: dg.RetryPolicy | None=None, metadata: Mapping[str, Any] | None=None, schema: ResourceSchema | Missing=MISSING, primary_key: Sequence[str]=(), schema_evolution: SchemaEvolution | Missing=MISSING) -> Callable[[Callable[..., Any]], AssetDeclaration]
```

### Transform a table · `model`

Declare a warehouse SQL model with an explicit output schema. The lineage group defaults to the first declared connection key, falling back to "transformation". Use '/'-separated segments such as group="google_ads/pmax" to nest the asset in the lineage UI. Assign a concurrency pool with pool="meta_ads" and declare its limit in s.definitions(pools=...).

```
model(*, tier: Tier | Missing=MISSING, partitioning: PartitionChoice | Missing=MISSING, schema: ResourceSchema | Missing=MISSING, storage: TableStorage | None=None, key: str | None=None, inputs: Mapping[str, AssetReference | AllPartitions] | None=None, deps: Sequence[Dependency]=(), group: str | None=None, pool: str | None=None, description: str | None=None, connections: Sequence[str]=(), secrets: Sequence[str]=(), retry_policy: dg.RetryPolicy | None=None, metadata: Mapping[str, Any] | None=None) -> Callable[[Callable[..., Any]], AssetDeclaration]
```

### Select assets for a run · `job`

Declare an explicit named asset selection and optional typed defaults.

```
job(name: str, *, assets: Sequence[AssetReference], include_upstream: bool=False, allow_app_runs: bool=False, config: Mapping[str, dg.Config | Mapping[str, Any]] | None=None, description: str | None=None) -> JobDeclaration
```

### Register the pipeline · `definitions`

Resolve and validate a project, returning ordinary Dagster Definitions. \`\`engine\`\` names the orchestrator that runs the deployment's jobs. It is written into the manifest: a deployment runs on the engine its code declares, or on the SegmentStream engine when it declares none, and keeps it until a later deployment declares or defaults to another. \`\`s.Engine.SegmentStream\`\`, the default and the recommended engine, accepts only SDK declarations. \`\`s.Engine.Dagster\`\` is deprecated: it keeps a deployment on Dagster, native Dagster objects included, until 2027-01-19. The workspace's \`\`docs/pipeline-engine-migration.md\`\` moves a pipeline from Dagster to the engine.

```
definitions(*, assets: Sequence[RegisteredAsset], semantic_models: object=_REMOVED_ARGUMENT, checks: Sequence[CheckDeclaration | dg.AssetChecksDefinition]=(), jobs: Sequence[JobDeclaration]=(), schedules: Sequence[ScheduleDeclaration]=(), pools: Mapping[str, int] | None=None, warehouse: WarehouseResource | None=None, resources: Mapping[str, Any] | None=None, default_io_manager: bool=True, engine: Engine=Engine.SegmentStream) -> dg.Definitions
```

[Jobs and workflows](https://segmentstream.com/docs/jobs-and-workflows)

[Read as Markdown ↗](https://segmentstream.com/docs/sdk/pipeline.md)
