# amoorion.app.workflows

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

### Functions

| [`rules_of`](#amoorion.app.workflows.rules_of)(rules)   | Rules as they may be given: a YAML file or directory, or a list of rules and files.   |
|--------------------------------------------------------------------|---------------------------------------------------------------------------------------|

### Classes

| [`Workflows`](#amoorion.app.workflows.Workflows)()   | Workflows kept by name on this object.   |
|----------------------------------------------------------------|------------------------------------------|

### amoorion.app.workflows.rules_of(rules)

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*](amoorion.workflows.rules.html.md#amoorion.workflows.rules.Rule)]

### *class* amoorion.app.workflows.Workflows

Bases: `object`

Workflows kept by name on this object.

#### workflow(name=None, , rules=None, steps=None, limit=100)

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*](amoorion.workflows.base.html.md#amoorion.workflows.base.Step) *|* *dict* *[**str* *,* *Any* *]* *]*  *|* *None*)
  * **limit** (*int*)
* **Return type:**
  *Any*

#### workflows()

The names of the workflows kept on this object.

* **Return type:**
  list[str]

#### perform(name, inputs=None)

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

* **Parameters:**
  * **name** (*str*)
  * **inputs** (*dict* *[**str* *,* *Any* *]*  *|* *None*)
* **Return type:**
  [*WorkflowRun*](amoorion.workflows.python.html.md#amoorion.workflows.python.WorkflowRun)

#### react(limit=100)

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*](amoorion.workflows.python.html.md#amoorion.workflows.python.WorkflowRun)]
