Tasks
Tasks are the fundamental units of work and data that flow through an Abstra Workflow. They act as the communication mechanism between Stages, allowing one stage to trigger the next and pass information along the defined path.
Key aspects of Tasks include their Payload, Type, and Lifecycle.
Task Payload
Each Task carries a payload, which is essentially a Python dictionary (dict
). This payload stores data in a key: value
format. Stages can add data to the payload, and subsequent stages can read and use this data, enabling information transfer throughout the workflow.
# Example payload
task_payload = {
"customer_id": 12345,
"order_total": 99.50,
"status": "approved"
}
Task Type
Every Task has a Type, which is a user-defined string label (e.g., "approved", "invoice_needed", "error_occurred").
Task Types are primarily used for routing. You can configure Transitions between stages to only allow Tasks of a specific Type to pass through. This enables conditional logic within your workflow, directing tasks down different paths based on their type.
Example: A Form stage might create tasks of type "approved" or "declined". Subsequent Transitions can then route these tasks to different processing stages based on that type.
Task Lifecycle and Statuses
Tasks progress through a defined lifecycle, tracked by their status:
- Pending: The initial state of a Task when it arrives at a stage, waiting to be processed.
- Locked: When a stage run picks up a Pending task to process it, the task's status changes to Locked. This prevents other concurrent runs of the same stage from picking up and processing the same task simultaneously, ensuring each task is handled only once at a time.
- Completed: After a stage successfully finishes processing a task, it should mark the task as Completed. Completed tasks will not be picked up again by that stage in future runs.
If a stage run fails or does not explicitly mark a Locked task as Completed, the task will automatically revert to Pending status after a timeout, allowing it to be retried in a subsequent run.
You can typically monitor the status and payload of tasks flowing through your workflow via a dedicated Tasks monitoring page within the Abstra Editor or Cloud Console.