doot.workflow.structs.inject_spec
Type Aliases
Classes
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.BaseModelA 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)
- 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( ) dict[str, jgdv.Maybe[doot.util.dkey.DKey | str]][source]
prepare keys for the expansions literal = True : means rhs is not a key
- 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,
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:
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)
- Return type:
- 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,
validate specs or tasks checks from_spec, and if given tasks, from_state as well
- Parameters:
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)
- Return type:
- apply_from_spec( ) 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:
- apply_from_state(
- control: dict | doot.workflow._interface.Task_p,
Expand a key using the control _internal_state
- Parameters:
control (dict | doot.workflow._interface.Task_p)
- Return type: