schedr.script

Plain Python scripts in a command task: the same dag_ctx as a Python task.

from schedr.script import dag_ctx gives a script run by a command task (python report.py, or any process the task starts) the run’s context as values: dag_ctx.params.region, dag_ctx.params(ReportParams), dag_ctx.run.planned_for. It is loaded from the agent over the task’s context channel (SCHEDR_CTX_FD) the first time it is read, with the same requests as schedr dag-ctx (decisions 143-146).

The values are decoded as in a task: a date is a date, a duration a timedelta, a tuple a tuple. A script doesn’t know the class the DAG declares, so dag_ctx.params.x is a field decoded by its stored form (a dataclass or model field holding an object is a dict), and dag_ctx.params(ReportParams) decodes strictly into the class passed.

Inside a Python task, the task’s own values are used; anywhere else (a Python task’s subprocess included: it has no channel) reading dag_ctx raises RuntimeError.