Run pipeline graphs: one ingest job, Source and Read nodes

This commit is contained in:
Roberto Treviño
2026-11-24 18:20:26 -06:00
parent 79a55a7a62
commit 8d874736db
4 changed files with 187 additions and 197 deletions
+11 -26
View File
@@ -1,45 +1,30 @@
"""Dagster code location: every heavy step of the platform is a job defined here.
Ingestion jobs take the pipeline to run (and optionally its config version) as run config.
"""
"""Dagster code location: every heavy step of the platform is a job defined here."""
import dagster as dg
from models import unpack
from persistance import collect, config_log
from models import graph
from persistance import config_log
WRITES = {"writes": "platform"} # dagster.yaml lets one run with this tag at a time (SQLite)
class PipelineRun(dg.Config):
pipeline: str
version: int | None = None
version: int | None = None # default: the latest saved
@dg.op
def collect_sources(context: dg.OpExecutionContext, config: PipelineRun) -> int:
def run_pipeline(context: dg.OpExecutionContext, config: PipelineRun) -> int:
"""Every node of the pipeline graph, inputs first. Returns the config version run."""
version, pipeline = config_log.get(config.pipeline, config.version)
for source in pipeline.sources:
info = collect.run(source)
context.log.info(f"{source.name}: {info}")
return version
@dg.op
def unpack_items(context: dg.OpExecutionContext, config: PipelineRun) -> int:
version, pipeline = config_log.get(config.pipeline, config.version)
context.log.info(str(unpack.run(pipeline)))
context.log.info(f"{config.pipeline} v{version}: {len(pipeline.nodes)} nodes")
graph.run(config.pipeline, pipeline, log=context.log.info)
return version
@dg.job(tags=WRITES)
def collect_job():
collect_sources()
def ingest():
run_pipeline()
@dg.job(tags=WRITES)
def unpack_job():
unpack_items()
defs = dg.Definitions(jobs=[collect_job, unpack_job])
defs = dg.Definitions(jobs=[ingest])