A step wraps a top-level def with a name, its input and output types, its
kind, and the step it follows:
def download(mut ctx: Ctx, month: Month) raises -> RawFile: ...
def load(mut ctx: Ctx, raw: RawFile) raises -> Loaded: ...
def compact(mut ctx: Ctx, loaded: Seq[Loaded]) raises -> Int64: ...
comptime Download = Step["download", Month, RawFile, download, Mapped]
comptime Load = Step["load", RawFile, Loaded, load, Mapped, after=Download]
comptime Compact = Step["compact", Seq[Loaded], Int64, compact, Gather, after=Load]
A mapped step runs once per partition of a run, a gather step once per run.
The edge is checked when the pipeline is compiled:
| Step |
Its input must be |
| first, mapped |
the pipeline's partition key, such as Month |
| first, gather |
a Seq of the key, every partition of the run |
| mapped, after a mapped step |
that step's output |
| gather, after a mapped step |
Seq of that step's output, one per partition in run order |
| gather, after a gather step |
that step's output |
A mapped step can't follow a gather step. Types are compared by their
reflected names, which include their module; the first step's input is
checked by Pipeline.check, which knows the key.
A step declares the datasets it reads and writes, as namespace.table
names in the warehouse (orca.tables):
comptime Clean = Step[
"clean", Month, Int64, clean, Mapped,
reads=["raw.events"], writes=["lake.events"],
]
orca.tables refuses a scan of a dataset the step didn't declare in
reads, and a commit to one it didn't declare in writes, so the graph of
pipelines and datasets that describe gives is what the steps do.
Structs
StepKind
struct StepKind
Whether a step runs once per partition or once per run.
Implements Copyable, Equatable, ImplicitlyCopyable, Movable, RegisterPassable, TrivialRegisterPassable, Writable
- Fields
value: Int
__eq__
def __eq__(self, other: Self) -> Bool
write_to
def write_to(self, mut writer: T)
NoStep
struct NoStep
What a first step follows.
Implements Movable, StepLike
step_name
def step_name() -> StaticString
upstream
def upstream() -> StaticString
upstream_function
def upstream_function() -> StaticString
function
def function() -> StaticString
output_type
def output_type() -> StaticString
dataset_reads
def dataset_reads() -> List[String]
dataset_writes
def dataset_writes() -> List[String]
run
def run(mut ctx: Ctx, input: Span[UInt8], mut out: List[UInt8])
Step
struct Step[name: StringSpan[ImmStaticOrigin], A_: Copyable & Deinitable, R_: Copyable & Deinitable, f: def(mut Ctx, A_) raises thin -> R_, kind_: StepKind, *, after: StepLike = NoStep, retries: Int = Int(0), reads: List[StringSpan[ImmStaticOrigin]] = List(__list_literal__=NoneType(None)), writes: List[StringSpan[ImmStaticOrigin]] = List(__list_literal__=NoneType(None))]
A step named name running f on an A_ to make an R_.
Implements Movable, StepLike
step_name
def step_name() -> StaticString
upstream
def upstream() -> StaticString
upstream_function
def upstream_function() -> StaticString
function
def function() -> StaticString
output_type
def output_type() -> StaticString
dataset_reads
def dataset_reads() -> List[String]
dataset_writes
def dataset_writes() -> List[String]
run
def run(mut ctx: Ctx, input: Span[UInt8], mut out: List[UInt8])