doot.workflow.structs.inject_spec

Type Aliases

ConstraintData

Classes

InjectSpec

A ConstraintData representation of an injection.

Module Contents

doot.workflow.structs.inject_spec.ConstraintData: TypeAlias = TaskSpec | dict | ChainGuard
class doot.workflow.structs.inject_spec.InjectSpec(/, **data: Any)[source]

Bases: pydantic.BaseModel

A ConstraintData representation of an injection.

With a Task C, the control, and Task T, the target, C injects data into T at defined times: - from_spec[K1, K2] : T.spec[K1] = C.spec[K2] - from_state[K1, K2] : T._internal_state[K1] = C._internal_state[K2] - from_target[K0, K2] : T._internal_state[K1_] = T.spec[C.spec[K2]] - literal[K1, V] : T._internal_state[k1] = V

Injection data can be: - list[DKey] : coerced to dict of {K : K}. Implicit keys - dict[k1:str, k2:DKey] : k1 is implicit, k2 is explicit

Parameters:

data (Any)

from_spec: dict = None
from_state: dict = None
from_target: dict = None
literal: dict = None
with_suffix: jgdv.Maybe[str] = None
_mapping: dict
classmethod build(data: dict) jgdv.Maybe[Self][source]

builds an InjectSpec from basic data

Parameters:

data (dict)

Return type:

jgdv.Maybe[Self]

static _prep_keys(
keys: jgdv.Maybe[dict[str, str] | list[str]],
literal: bool = False,
) dict[str, jgdv.Maybe[doot.util.dkey.DKey | str]][source]

prepare keys for the expansions literal = True : means rhs is not a key

Parameters:
Return type:

dict[str, jgdv.Maybe[doot.util.dkey.DKey | str]]

_validate_injection() Self[source]
Return type:

Self

_validate_from_spec(val: Any) dict[source]
Parameters:

val (Any)

Return type:

dict

_validate_from_state(val: Any) dict[source]
Parameters:

val (Any)

Return type:

dict

_validate_from_target(val: Any) dict[source]
Parameters:

val (Any)

Return type:

dict

_validate_literal(val: Any) dict[source]
Parameters:

val (Any)

Return type:

dict

validate(
control: doot.workflow._interface.Task_i | doot.workflow._interface.TaskSpec_i,
target: doot.workflow._interface.Task_i | doot.workflow._interface.TaskSpec_i,
*,
only_spec: bool = False,
) bool[source]

Ensures this injection is usable with given sources, and given required injections

eg: target(must_inject=[‘a’]), control(‘a’=5) Injection(from_spec=[‘a’]) The Injection is valid.

eg: target(must_inject=[‘a’]), control(‘d’=9) Injection(from_spec=[‘a’]) The Injection is invalid, ‘a’ is missing from the source.

eg: target() control(‘a’=10) Injection(from_spec=[‘a’]) The Injection is invalid, ‘a’ is surplus to the task.

Parameters:
Return type:

bool

validate_details(
control: doot.workflow._interface.Task_i | doot.workflow._interface.TaskSpec_i,
target: doot.workflow._interface.Task_i | doot.workflow._interface.TaskSpec_i,
*,
only_spec: bool = False,
) dict[source]

validate specs or tasks checks from_spec, and if given tasks, from_state as well

Parameters:
Return type:

dict

apply_from_spec(
control: dict | doot.workflow._interface.TaskSpec_i | doot.workflow._interface.Task_p,
) dict[source]

Apply values from the control’s spec values.

Fully expands keys in ‘from_spec’, Only partially expands (L1) from ‘from_target’

Parameters:

control (dict | doot.workflow._interface.TaskSpec_i | doot.workflow._interface.Task_p)

Return type:

dict

apply_from_state(
control: dict | doot.workflow._interface.Task_p,
) dict[source]

Expand a key using the control _internal_state

Parameters:

control (dict | doot.workflow._interface.Task_p)

Return type:

dict

apply_literal(val: Any) dict[source]

Takes a value and sets it for any keys in self.literal

Used for job’s to insert literal values into a key. eg: when mapping filenames to generated tasks

Parameters:

val (Any)

Return type:

dict