Skip to content

Dagster plugin

pipeloom-dagster loads a pipeloom project into Dagster as one asset per execution unit (ADR-0066). It follows the orchestrator protocol: Dagster owns scheduling and retries, and each materialization runs one unit as a child process.

$ pip install "pipeloom[dagster]"

Supported: dagster>=1.10,<2, tested on 1.10.0 and the latest release in CI. The plugin uses only the public API (multi_asset, AssetSpec, AssetCheckSpec, TimeWindowPartitionsDefinition).

Load a project

# definitions.py
from pipeloom_dagster import definitions

defs = definitions("path/to/project", target="dev")
$ dagster dev -f definitions.py

definitions(project_dir, target="dev", *, manifest=None, vars=None) reads the plan and never imports model code. With manifest (a file from pipeloom compile --stable --out) it reads that file. Without it, it compiles the project and writes the manifest to <artifacts root>/dagster/. The plan hash is checked by every unit command, so a project that changed after the load fails the run with PLX103 until Dagster reloads.

Assets

  • One multi_asset per unit, with one asset. The key is the parts of the dataset identity of ADR-0055: project, target, catalog (when set), schema and relation name.
  • Dependencies are the parent units, so the Dagster graph is the unit graph.
  • Materializing an asset runs pipeloom run --select unit:<id> with the run id dagster-<dagster run id>, so the attempt files of one Dagster run share one folder under the artifacts root. Select one asset and exactly that unit runs.
  • A failing unit fails the step with the error code and message of the attempt file, and the child's output in the failure metadata.
  • The child needs the project's engine plugins in the same Python environment as Dagster.

Data tests

Each data test of a model is an asset check with the test's name. The unit runs with data tests on and the checks read the table results of its attempt file.

Test Check
on_violation: fail, blocking unset or true blocking, severity ERROR
on_violation: fail, blocking: false not blocking, severity WARN
on_violation: warn not blocking, severity WARN

A failed data test leaves the data written (PLQ303), so the asset is materialized and the check is failed. A failed blocking check fails the step and stops the downstream assets, as in Dagster. A check with no result in the attempt file is not reported, so Dagster shows it as not evaluated, never as passed.

Skipped units

When the unit leaves no attempt file, or its newest attempt is skipped (for example upstream_incomplete, when a downstream window is run before its upstream has produced it), the step fails with the skip reason and the held back keys. No materialization and no check result is recorded.

Retries

A model with retries above zero gets a Dagster RetryPolicy with that many retries and the retry_delay of the model. With retry_on: transient (the default), a failure whose attempt error category is permanent is raised with allow_retries=False, so Dagster does not retry it; with retry_on: any it does. A failure that left no attempt file is retried.

Partitions

An interval model gets a TimeWindowPartitionsDefinition in UTC: the cron of its grain (a week starts on Monday), the first window of begin, and the partition key format of ADR-0071, so a Dagster key and a pipeloom key are the same text. Materializing one partition runs the unit with --partition-key, which runs exactly that window. Models that are not interval models are not partitioned. Dagster lists a window as a partition once it is complete, so the current partial window is not offered.

Limits

  • The artifacts root must be visible to the process that runs Dagster. The plugin does not run pipeloom finalize; run it after a Dagster run when you want run_results.json.
  • Materializing a partition whose window is already in the ledger does no work (the unit settles with outcome: up_to_date), and Dagster still records a materialization for it.
  • A stop request kills the child process; there is no cancel grace.
  • Sources are not assets, and --full-refresh is not passed.