amoorion.app.workflows

The workflows of an Amoorion: written in Python, run by name or by what arrives.

Functions

rules_of(rules)

Rules as they may be given: a YAML file or directory, or a list of rules and files.

Classes

Workflows()

Workflows kept by name on this object.

amoorion.app.workflows.rules_of(rules)[source]

Rules as they may be given: a YAML file or directory, or a list of rules and files.

Parameters:

rules (str | Path | list[Any] | None)

Return type:

list[Rule]

class amoorion.app.workflows.Workflows[source]

Bases: object

Workflows kept by name on this object.

workflow(name=None, *, rules=None, steps=None, limit=100)[source]

With a name, a decorator keeping a function as a workflow; without, the method workflow.

@amo.workflow("name", rules=…) keeps the function; amo.workflow(steps=[…]) runs steps, amo.workflow(rules=…) runs rules on the inbox.

Parameters:
  • name (str | None)

  • rules (str | Path | list[Any] | None)

  • steps (list[Step | dict[str, Any]] | None)

  • limit (int)

Return type:

Any

workflows()[source]

The names of the workflows kept on this object.

Return type:

list[str]

perform(name, inputs=None)[source]

Run a kept workflow by its name, whatever its rules say.

Parameters:
  • name (str)

  • inputs (dict[str, Any] | None)

Return type:

WorkflowRun

react(limit=100)[source]

Run kept workflows on the inbox’s new messages their rules match, once per message.

Oldest first; safe to run from a timer. A failed run gets the message again next time. The steps of a rule run first, and their results are in inputs["steps"].

Parameters:

limit (int)

Return type:

list[WorkflowRun]