cognition.decision.stage

Support for workflow housed within a single enumerated field.

Attributes

StageSupporter

Function to optionally provide kwargs based upon interaction with IO

Classes

StagedState

Extensible state with an

Functions

staged_operator(dp, stage, **kwargs)

Given that a decision process is using a staged

Module Contents

class cognition.decision.stage.StagedState[T: enum.Enum]

Bases: cognition.util.enumeration.EnumDispatch[T]

Extensible state with an enumerated stage controlled via enum-named transition

To use…

  • declare dataclasses.dataclass() subclass with stage field type and initial value

  • add additional fields as necessary

  • implement enum-named methods for non- terminal stages; each of which must return the next stage value (and can take arbitrary supporting arguments)

stage: T

Required field: locus of task-flow state

transition(*args, **kwargs)

Update stage via enum-named methods; each such method must return the next stage, with logic dependent upon passed arguments.

Parameters:
  • args (Any) – positional arguments to pass

  • kwargs (Any) – keyword arguments to pass

Return type:

None

type cognition.decision.stage.StageSupporter = BiFunction[S, IOContainer, Mapping[str, Any] | None]

Function to optionally provide kwargs based upon interaction with IO

cognition.decision.stage.staged_operator[SE, SS](dp, stage, **kwargs)

Given that a decision process is using a staged state, convenience decorator to add a full operator that applies during a supplied stage

Parameters:
Return type:

cognition.util.functypes.Function[StageSupporter[SE, SS], StageSupporter[SE, SS]]