schedr._model.registry¶
The DAGs defined while importing DAG files, and where they are defined.
The runner (parse mode) imports each file inside parse_root() and then takes the
DAGs with take_defined(). Outside the runner (tests, an interactive session) DAGs are
collected the same way, located as local:<file name>.
- schedr._model.registry.LOCAL_ROOT = 'local'¶
The root name of DAGs defined outside any configured DAG root.
- type schedr._model.registry.ScriptAsker = Callable[[str], Mapping[str, Any]]¶
Asks the agent for a
schedr.tomldeclaration by reference: its answer.
- schedr._model.registry.script_declarations(ask)¶
Lets each
ScriptOperatorinside the block ask for its declaration.- Parameters:
ask (ScriptAsker) – Asks the agent (the runner’s parse channel).
- Yields:
Nothing.
- Return type:
Iterator[None]
- schedr._model.registry.script_asker()¶
How to ask for a
schedr.tomldeclaration;Noneoutside a parse.- Returns:
The asker, while the runner parses.
- Return type:
ScriptAsker | None
- class schedr._model.registry.DefinedDag(model, functions=<factory>, params_class=None, cleanups=<factory>)¶
Bases:
objectA DAG whose
with Dag(...)block finished, with its tasks’ Python functions.- Parameters:
- model¶
The DAG as DAG JSON types.
- Type:
- functions¶
The function of each Python task, by task ID (the runner calls them).
- Type:
collections.abc.Mapping[str, collections.abc.Callable[[…], Any]]
- cleanups¶
The
cleanup=function of each Python task with one, by task ID.- Type:
collections.abc.Mapping[str, collections.abc.Callable[[…], Any]]
- schedr._model.registry.parse_root(name, path)¶
Locates DAGs defined inside the block relative to a DAG root.
- Parameters:
name (str) – The root’s name, e.g.
etl-repo.path (Path) – The root’s directory.
- Yields:
Nothing; DAGs defined in files under
pathget locations relative to it.- Return type:
Iterator[None]
- schedr._model.registry.parse_root_active()¶
Whether a parse root is set (the runner parsing a DAG folder).
- Returns:
Trueinsideparse_root().- Return type:
bool
- schedr._model.registry.location_for(filename)¶
Where a DAG defined in
filenameis, given the current parse root.- Parameters:
filename (str) – The DAG file’s path, as Python reports it (
__file__).- Returns:
The root and the path relative to it, with
/separators;localand the file name when there is no parse root or the file isn’t under it.- Return type:
- schedr._model.registry.root_location(filename)¶
Where
filenameis in the current parse root, orNoneoutside it (or without one).Unlike
location_for(), a root that is itself namedlocalis told apart.- Parameters:
filename (str) – The file’s path, as Python reports it (
__file__).- Returns:
The root and the path relative to it, with
/separators, orNone.- Return type:
DagLocation | None
- schedr._model.registry.register(dag, functions=None, filename=None, params_class=None, cleanups=None)¶
Records a DAG whose
with Dag(...)block finished.- Parameters:
dag (Dag) – The DAG.
functions (Mapping[str, Callable[[...], Any]] | None) – The function of each of its Python tasks, by task ID.
filename (str | None) – The file defining it (
__file__), remembered fordefined_in().params_class (type | None) – The class its run parameters are declared with.
cleanups (Mapping[str, Callable[[...], Any]] | None) – The
cleanup=function of each Python task with one, by task ID.
- Return type:
None
- schedr._model.registry.defined_in(filename, dag_id)¶
The latest definition of a DAG in a file, if this process has imported it.
Unlike
take_entries(), this remembers every DAG defined so far (e.g. by a test importing a DAG file), so its task functions and their types can be found again.- Parameters:
filename (str | Path) – The DAG file.
dag_id (str) – The DAG’s ID.
- Returns:
The DAG with its task functions, or
None.- Return type:
DefinedDag | None
- schedr._model.registry.take_entries()¶
Returns the DAGs defined since the last call, with their functions, and forgets them.
- Returns:
The DAGs, in definition order.
- Return type:
list[DefinedDag]