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.toml declaration by reference: its answer.

schedr._model.registry.script_declarations(ask)

Lets each ScriptOperator inside 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.toml declaration; None outside 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: object

A DAG whose with Dag(...) block finished, with its tasks’ Python functions.

Parameters:
  • model (Dag)

  • functions (Mapping[str, Callable[[...], Any]])

  • params_class (type | None)

  • cleanups (Mapping[str, Callable[[...], Any]])

model

The DAG as DAG JSON types.

Type:

schedr._model.dag.Dag

functions

The function of each Python task, by task ID (the runner calls them).

Type:

collections.abc.Mapping[str, collections.abc.Callable[[…], Any]]

params_class

The class its run parameters are declared with; None: none.

Type:

type | None

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 path get 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:

True inside parse_root().

Return type:

bool

schedr._model.registry.location_for(filename)

Where a DAG defined in filename is, 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; local and the file name when there is no parse root or the file isn’t under it.

Return type:

DagLocation

schedr._model.registry.root_location(filename)

Where filename is in the current parse root, or None outside it (or without one).

Unlike location_for(), a root that is itself named local is 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, or None.

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 for defined_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]

schedr._model.registry.take_defined()

Returns the DAGs defined since the last call, in definition order, and forgets them.

Returns:

The DAGs (their models).

Return type:

list[Dag]