schedr._model.values

References, templates and task arguments in DAG JSON (schedr-model, value.rs).

class schedr._model.values.DagCtxField(*values)

Bases: StrEnum

A field of the run’s context: dag_ctx.run.* and dag_ctx.dag_id.

class schedr._model.values.OutputRef(task, path=(), on=())

Bases: object

An upstream task’s output, or a part of it.

Parameters:
  • task (str)

  • path (Sequence[str | int])

  • on (Sequence[str])

task

The upstream task’s ID.

Type:

str

path

Field names and list / tuple indexes into the output; empty for all of it.

Type:

collections.abc.Sequence[str | int]

on

The outcomes it was narrowed to (.on(...)); empty for any. On another outcome, or a skipped upstream task, it stands for None.

Type:

collections.abc.Sequence[str]

to_json()

The reference as DAG JSON.

Returns:

{"kind": "output", "task": ..., "path": [...], "on": [...]} (path and on only if not empty).

Return type:

dict[str, Any]

class schedr._model.values.OutcomeRef(task)

Bases: object

An upstream task’s outcome itself (.outcome), as its name.

Parameters:

task (str)

task

The upstream task’s ID.

Type:

str

to_json()

The reference as DAG JSON.

Returns:

{"kind": "outcome", "task": ...}.

Return type:

dict[str, Any]

class schedr._model.values.DagCtxRef(field)

Bases: object

A field of the run’s context.

Parameters:

field (DagCtxField)

field

Which field.

Type:

schedr._model.values.DagCtxField

to_json()

The reference as DAG JSON.

Returns:

{"kind": "dag_ctx", "field": ...}.

Return type:

dict[str, Any]

class schedr._model.values.ParamRef(path=())

Bases: object

The run’s parameters, or a part of them (dag_ctx.params.region, decision 138).

Parameters:

path (Sequence[str | int])

path

Field names and list / tuple indexes into the parameters; empty for all of them.

Type:

collections.abc.Sequence[str | int]

to_json()

The reference as DAG JSON.

Returns:

{"kind": "param", "path": [...]} (path only if not empty).

Return type:

dict[str, Any]

schedr._model.values.check_storage_name(name)

Why name can’t be a secret storage’s name (its [secret_storage.<name>] key).

Parameters:

name (str) – The name.

Returns:

The reason, or None for a good name.

Return type:

str | None

schedr._model.values.storage_label(storage)

A storage as written in Python.

secrets, secrets.other, or secrets.storage('vault-2') for a name that can’t be an attribute: not a Python name, a keyword, _ first, or storage or value (the methods).

Parameters:

storage (str | None) – Its name; None for the default one.

Returns:

The label.

Return type:

str

schedr._model.values.check_secret_path(path, what)

Why path can’t be a secret’s path (or a prefix without its last /).

Parameters:
  • path (str) – The path.

  • what (str) – path or prefix, for the message.

Returns:

The reason, or None for a good path.

Return type:

str | None

class schedr._model.values.SecretRef(path, key=None, storage=None, default=None)

Bases: object

A secret in a secret storage: path#key, or path for the whole secret.

Parameters:
  • path (str)

  • key (str | None)

  • storage (str | None)

  • default (str | None)

path

The secret’s path in the storage (etl/db).

Type:

str

key

The key in it (password); None for the whole secret.

Type:

str | None

storage

The storage; None for the default one.

Type:

str | None

default

What a reference reads when the secret or its key is missing (.get(key, default)); a key’s only.

Type:

str | None

spec()

path#key, or path for the whole secret.

Returns:

The spec.

Return type:

str

label()

As written in Python (decision 176).

secrets['etl/db']['password'], secrets.other['etl/db'], secrets['etl/db'].get('password', '').

Returns:

The label.

Return type:

str

to_json()

The reference as DAG JSON.

Returns:

{"kind": "secret", "path": ..., "key": ..., "storage": ..., "default": ...} (key, storage and default only if set).

Return type:

dict[str, Any]

class schedr._model.values.SecretPrefixDecl(prefix, storage=None)

Bases: object

Every secret under a prefix, declared in secrets= (SecretPrefix(...)).

Parameters:
  • prefix (str)

  • storage (str | None)

prefix

The prefix, ending in /.

Type:

str

storage

The storage; None for the default one.

Type:

str | None

label()

As written in Python.

Returns:

SecretPrefix('connections/'), with storage= when it names one.

Return type:

str

to_json()

The declaration as DAG JSON.

Returns:

{"kind": "prefix", "prefix": ..., "storage": ...} (storage only if set).

Return type:

dict[str, Any]

schedr._model.values.covers(declared, ref)

Whether a declaration in secrets= lets a task read ref (as the agent decides).

Parameters:
Returns:

True for the same secret (or a key of a whole one declared), or one under a declared prefix, in the same storage.

Return type:

bool

type schedr._model.values.SecretDecl = SecretRef | SecretPrefixDecl

A secret a task declares in secrets=: one (or a whole one), or a prefix.

type schedr._model.values.Reference = OutputRef | OutcomeRef | DagCtxRef | ParamRef | SecretRef

Any reference.

class schedr._model.values.TemplateRef(reference, format=None, encode=None)

Bases: object

A reference inside a template, with its optional format spec.

Parameters:
  • reference (Reference)

  • format (str | None)

  • encode (Literal['url'] | None)

reference

What is filled in.

Type:

schedr._model.values.Reference

format

The t-string format spec (raw, %Y-%m-%d, …), if any.

Type:

str | None

encode

How its text is written in: "url", percent-encoded (a typed connection’s URL, decision 188); None as it is.

Type:

Literal[‘url’] | None

to_json()

The template part as DAG JSON.

Returns:

{"ref": {...reference, "format": ..., "encode": ...}} (each only if set).

Return type:

dict[str, Any]

type schedr._model.values.TemplatePart = str | TemplateRef

Literal text or a reference.

class schedr._model.values.Template(parts=<factory>)

Bases: object

A t-string as data: its parts in order.

Parameters:

parts (Sequence[TemplatePart])

parts

Literal text and references.

Type:

collections.abc.Sequence[schedr._model.values.TemplatePart]

references()

The references in this template, in order.

Returns:

Every reference of the template’s parts.

Return type:

list[Reference]

to_json()

The template as DAG JSON.

Returns:

A list of {"text": ...} and {"ref": ...} parts.

Return type:

list[dict[str, Any]]

class schedr._model.values.LiteralValue(value)

Bases: object

A JSON value as encoded by the API (with tagged extra types), passed as is.

Parameters:

value (Any)

value

The JSON-compatible value.

Type:

Any

references()

A literal has no references.

Returns:

An empty list.

Return type:

list[Reference]

to_json()

The value as DAG JSON.

Returns:

{"literal": ...}.

Return type:

dict[str, Any]

class schedr._model.values.RefValue(reference)

Bases: object

A reference passed with its type.

Parameters:

reference (Reference)

reference

The reference.

Type:

schedr._model.values.Reference

references()

The reference itself.

Returns:

A one-element list.

Return type:

list[Reference]

to_json()

The value as DAG JSON.

Returns:

{"ref": ...}.

Return type:

dict[str, Any]

class schedr._model.values.TemplateValue(template)

Bases: object

A t-string, rendered to a string at run time.

Parameters:

template (Template)

template

The template.

Type:

schedr._model.values.Template

references()

The template’s references.

Returns:

Its references, in order.

Return type:

list[Reference]

to_json()

The value as DAG JSON.

Returns:

{"template": [...]}.

Return type:

dict[str, Any]

class schedr._model.values.ListValue(items)

Bases: object

A list whose elements may contain references.

Parameters:

items (Sequence[Value])

items

The elements.

Type:

collections.abc.Sequence[schedr._model.values.Value]

references()

The elements’ references, in order.

Returns:

Every reference at any depth.

Return type:

list[Reference]

to_json()

The value as DAG JSON.

Returns:

{"list": [...]}.

Return type:

dict[str, Any]

class schedr._model.values.MapValue(entries)

Bases: object

A dictionary (string keys) whose values may contain references.

Parameters:

entries (Mapping[str, Value])

entries

The entries.

Type:

collections.abc.Mapping[str, schedr._model.values.Value]

references()

The values’ references, by key order.

Returns:

Every reference at any depth, ordered by key (as stored).

Return type:

list[Reference]

to_json()

The value as DAG JSON.

Returns:

{"map": {...}} with keys sorted (as the Rust side stores them).

Return type:

dict[str, Any]

type schedr._model.values.Value = LiteralValue | RefValue | TemplateValue | ListValue | MapValue

Any task argument value.