Skip to content

The step model

Rendered at build time from the docstrings and signatures of continuous_gtfs.step. A member with no description has no docstring yet; the fix is in the code, never on this page.

@step and @check, the Step and Check base classes, finding declarations, and the definition and source hashes that version a step.

Step base class and @step decorator.

BeforeSpec module-attribute

BeforeSpec = "list[Step] | Literal['*']"

FindingsSpec module-attribute

FindingsSpec = 'list[str | tuple[str, dict[str, Any]]]'

StepRole module-attribute

StepRole = Literal['transform', 'check']

TRANSFORM module-attribute

TRANSFORM: StepRole = 'transform'

CHECK module-attribute

CHECK: StepRole = 'check'

CHECK_MUTATED_VIEW module-attribute

CHECK_MUTATED_VIEW = 'check_mutated_view'

CHECK_FAILED module-attribute

CHECK_FAILED = 'check_failed'

RESERVED_FINDING_CODES module-attribute

RESERVED_FINDING_CODES = frozenset(
    {CHECK_MUTATED_VIEW, CHECK_FAILED}
)

Step

Step(
    *,
    after: list[Step] | Literal["*"] | None = None,
    before: list[Step] | Literal["*"] | None = None,
    priority: int = 100,
    tags: list[str] | None = None,
    data_owner: str | None = None,
    enabled: bool = True,
    findings: list[Any] | None = None,
    **kwargs: Any,
)

Base class for every pipeline step.

Builtins subclass it and set files, description, findings and category as class attributes; @step and @check wrap functions into instances. Every step, builtin or custom, takes the shared parameters below, so a builtin's own Args: lists only what it adds.

Parameters:

Name Type Description Default
after list[Step] | Literal['*'] | None

Steps this one runs after, or "*" to run after every other step that touches its files.

None
before list[Step] | Literal['*'] | None

Steps this one runs before, or "*" to run before every other step. A step cannot be both before="*" and after="*".

None
priority int

Tiebreak among steps at the same DAG level; lower runs earlier.

100
tags list[str] | None

Free labels for grouping steps.

None
data_owner str | None

Email of the person responsible for the step's data.

None
enabled bool

False skips the step while leaving it in the DAG so dependency chains still hold.

True
findings list[Any] | None

Finding codes the step may emit, overriding the class declaration (specs/transform-framework.md §Declaring a finding vocabulary).

None
**kwargs Any

Reserved for subclasses.

{}

role class-attribute instance-attribute

role: StepRole = TRANSFORM

category class-attribute instance-attribute

category: str | None = None

files class-attribute instance-attribute

files: list[str] = list(type(self).files)

description class-attribute instance-attribute

description: str = type(self).description

findings class-attribute instance-attribute

findings: list[Any] = list(
    findings
    if findings is not None
    else type(self).findings
)

declared_findings instance-attribute

declared_findings: dict[str, list[str]] = (
    normalize_findings(self.findings)
)

after instance-attribute

after: list[Step] | Literal["*"] = (
    "*" if after == "*" else after or []
)

before instance-attribute

before: list[Step] | Literal["*"] = (
    "*" if before == "*" else before or []
)

priority instance-attribute

priority = priority

tags instance-attribute

tags = tags or []

data_owner instance-attribute

data_owner = data_owner

enabled instance-attribute

enabled = enabled

name instance-attribute

name: str = ''

source_path instance-attribute

source_path: str | None = site[0] if site else None

source_file instance-attribute

source_file: str | None = site[0] if site else None

source_line instance-attribute

source_line: int | None = site[1] if site else None

source_hash instance-attribute

source_hash: str | None = None

module_hash instance-attribute

module_hash: str | None = None

source instance-attribute

source: str | None = None

module_source instance-attribute

module_source: str | None = None

is_builtin property

is_builtin: bool

True for a parameterized builtin (a Step subclass instance); False for a function wrapped by @step / @check.

builtin_name property

builtin_name: str | None

The builtin's class name (RemoveRows, CombineFeeds, ...), or None for a decorated function.

label property

label: str

Human-readable label for UI display.

is_check property

is_check: bool

True when this step is a check: it reads the output and emits findings, never changes it (specs/transform-framework.md §Checks).

apply

apply(ctx: PipelineContext) -> None

Do the step's work against ctx. A builtin overrides this; a decorated function supplies it. Transforms mutate ctx.output; checks read it and call ctx.finding(...).

definition_params

definition_params() -> dict[str, Any]

What this instance was built from, as a JSON-canonicalizable dict.

The default reads every instance attribute except DAG wiring and scanner bookkeeping, so a builtin's constructor parameters (files, conditions, description, ...) are covered without each builtin declaring them. A builtin holding state that does not canonicalize (a callable, a DataFrame) overrides this to name what defines it.

Check

Check(
    *, after: Any = None, before: Any = None, **kwargs: Any
)

Bases: Step

Base class for builtin checks (specs/transform-framework.md §Checks).

A check reads the output, emits findings, and cannot change the data: it runs after every transform, concurrently with the other checks, against its own read-only view of the output. It takes Step's arguments except before / after, which raise — a check has no position to declare.

role class-attribute instance-attribute

role: StepRole = CHECK

normalize_findings

normalize_findings(
    spec: list[Any] | None, *, step_name: str = ""
) -> dict[str, list[str]]

Normalize a findings=[...] declaration into {code: subject_keys}.

Accepts a bare code (no subject → class grain) or a (code, {"subject": [...]}) pair. Never raises on a malformed entry: declaring is discoverability, not enforcement (specs/transform-framework.md §Declaring a finding vocabulary), so a typo'd declaration degrades to "no subject" and warns rather than breaking pipeline load. A duplicate code keeps the last entry. A framework-reserved code (RESERVED_FINDING_CODES) is dropped with a warning: the framework owns it, and the platform already counts it as declared on every check.

definition_hash

definition_hash(step_obj: Step) -> str

sha256 over the canonical JSON of step_obj.definition_params().

definition_text

definition_text(step_obj: Step) -> str

A builtin instance's definition text: the same canonical serialization definition_hash hashes, laid out one key per line so a changed parameter diffs as the lines that hold it (specs/transform-framework.md §Step Snapshot at Registration, source). Compacting it again — json.dumps(json.loads(text), sort_keys=True) — reproduces the hashed payload exactly, so the layout never moves a hash.

normalized_source

normalized_source(source: str) -> str

Source text as source_text_hash hashes it: dedented, each line right-stripped, so a re-indent or trailing whitespace is not a change. This is the text a @step function's snapshot source carries.

source_text_hash

source_text_hash(source: str) -> str

sha256 over normalized_source(source).

step

step(
    *args: Any,
    files: list[str] | None = None,
    after: list[Step] | Literal["*"] | None = None,
    before: list[Step] | Literal["*"] | None = None,
    priority: int = 100,
    tags: list[str] | None = None,
    data_owner: str | None = None,
    enabled: bool = True,
    description: str | None = None,
    findings: list[Any] | None = None,
) -> Step | Callable[[Callable], Step]

Decorator that wraps a function as a Step instance.

Usage

@step(files=["stops.txt"], after=[some_other_step]) def my_transform(ctx): ...

@step( files=["stops.txt"], findings=[("stop_outside_area", {"subject": ["stop_id"]})], ) def check_stops(ctx): ctx.emit_finding("stop_outside_area", ...)

The decorated name becomes a Step instance, not a function.

@step() is the documented idiom. Bare @step (no parentheses) is also accepted and is identical to @step(): the decorated function arrives as the sole positional argument with no configuration, which is unambiguous because the positional slot otherwise only ever holds a files list. Any other callable in the configuration — a function alongside keyword options, or files= given a callable — raises TypeError rather than silently registering nothing.

check

check(
    *args: Any,
    files: list[str] | None = None,
    priority: int = 100,
    tags: list[str] | None = None,
    data_owner: str | None = None,
    enabled: bool = True,
    description: str | None = None,
    findings: list[Any] | None = None,
    after: Any = None,
    before: Any = None,
) -> Step | Callable[[Callable], Step]

Decorator that wraps a function as a check (specs/transform-framework.md §Checks): a step that reads the output and emits findings and cannot change the data.

Usage

@check( files=["stops.txt"], findings=[("stop_outside_area", {"subject": ["stop_id"]})], ) def check_stops(ctx): ctx.emit_finding("stop_outside_area", ...)

Takes @step's arguments and forms (bare @check is @check()) except before / after: a check runs after every transform, so either one raises ValueError naming the step. after/before are in the signature only so that error can name the step instead of Python reporting an unexpected keyword. priority has no effect on a check; checks order among themselves by name.