doot.workflow.structs.relation_spec

Classes

RelationSpec

{object} is {relation} to {target}

Module Contents

class doot.workflow.structs.relation_spec.RelationSpec(/, **data: Any)[source]

Bases: pydantic.BaseModel, jgdv._abstract.protocols.general.Buildable_p

{object} is {relation} to {target}

Object is optional, to allow multiple different objects to have the same relationship to the target. Encodes a relation between an object , (who owns this relationspec) and the subject of the relation (who is contained within the relation)

eg: (baking <needs> mixing)

(baking <blocks> cake)

May carry additional information: - constraints : dict|list. Maps obj[x] == targ[y] requirements - inject : InjectSpec. Maps targ[x] = obj[y] values to pass to target. - object : Maybe[TaskName]. the owning base object of the relationship

Parameters:

data (Any)

Marks: ClassVar[type[doot.workflow._interface.RelationMark]]
target: doot.workflow._interface.TaskName_p | doot.workflow._interface.Artifact_i
relation: doot.workflow._interface.RelationMeta_e
object: jgdv.Maybe[doot.workflow.structs.task_name.TaskName | doot.workflow.structs.artifact.TaskArtifact] = None
constraints: dict[str, str]
inject: jgdv.Maybe[doot.workflow.structs.inject_spec.InjectSpec] = None
_meta: dict
classmethod build(
data: doot.workflow._interface.RelationSpec_i | jgdv.structs.chainguard.ChainGuard | dict | doot.workflow._interface.TaskName_p | str,
*,
relation: jgdv.Maybe[doot.workflow._interface.RelationMark] = None,
) doot.workflow._interface.RelationSpec_i[source]

Create a new relation, defaulting to a requirement.

Parameters:
Return type:

doot.workflow._interface.RelationSpec_i

_validate_target(
val: Any,
) doot.workflow._interface.RelationTarget[source]
Parameters:

val (Any)

Return type:

doot.workflow._interface.RelationTarget

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

val (Any)

Return type:

dict

_validate_inject(
val: Any,
) jgdv.Maybe[str | doot.workflow._interface.InjectSpec_i][source]
Parameters:

val (Any)

Return type:

jgdv.Maybe[str | doot.workflow._interface.InjectSpec_i]

to_ordered_pair(
obj: doot.workflow._interface.RelationTarget,
*,
target: jgdv.Maybe[doot.workflow._interface.TaskName_p] = None,
) tuple[jgdv.Maybe[doot.workflow._interface.RelationTarget], jgdv.Maybe[doot.workflow._interface.RelationTarget]][source]

a helper to make an edge for the tracker. uses the current (abstract) target, unless an instance is provided

Parameters:
Return type:

tuple[jgdv.Maybe[doot.workflow._interface.RelationTarget], jgdv.Maybe[doot.workflow._interface.RelationTarget]]

instantiate(
*,
obj: jgdv.Maybe[doot.workflow._interface.RelationTarget] = None,
target: jgdv.Maybe[doot.workflow._interface.RelationTarget] = None,
) doot.workflow._interface.RelationSpec_i[source]

Duplicate this relation, but with a suitable concrete task or artifact as the object or subject

Parameters:
  • obj (jgdv.Maybe[doot.workflow._interface.RelationTarget])

  • target (jgdv.Maybe[doot.workflow._interface.RelationTarget])

Return type:

doot.workflow._interface.RelationSpec_i

forward_dir_p() bool[source]

is this relation’s direction obj -> target?

Return type:

bool

accepts(
control: doot.workflow._interface.Task_i | doot.workflow._interface.TaskSpec_i,
target: doot.workflow._interface.Task_i | doot.workflow._interface.TaskSpec_i,
) bool[source]

Test if this pair of Tasks satisfies the relation

Parameters:
Return type:

bool