Workflows SDK for Python
Usage and symbol reference
The Render SDK for Python provides support for:
- Defining workflow tasks
- Triggering runs of those tasks from your other Python code
When triggering runs, you use different classes for asynchronous and synchronous execution contexts.
Install
From your Python project directory:
If you already have the SDK installed, make sure you're using version 1.0.1 or later:
After installing, make sure to add render>=1.0.1 as a dependency in your application's requirements.txt, pyproject.toml, or equivalent.
Defining tasks
The following symbols pertain to creating and registering tasks in your workflow service. For guidance on how to use them, see Defining Workflow Tasks.
The Workflows class
Handles defining and registering workflow tasks. Initialize this in each file where you define tasks.
Initializing
Workflows(*, default_retry=None, default_timeout=None, default_plan=None)
Initializes a new Workflows object. All arguments are optional.
| Argument | Description | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
A Individual tasks can override this. | ||||||||||||||||||
|
The default timeout (in seconds) for all tasks in this workflow. Individual tasks can override this. | ||||||||||||||||||
|
The default compute plan to use for all tasks in this workflow. Individual task definitions can override this. One of the following:
The default value is Providing |
Workflows.from_workflows(*apps, default_retry=None, default_timeout=None, default_plan=None)
Initializes a new Workflows object that incorporates tasks from one or more other Workflows objects.
Use this in your workflow's entry point file if you import task definitions from other files:
If you set any defaults with this method (such as default_timeout), those defaults apply only to tasks registered directly on this Workflows object (not to tasks registered on the imported objects).
| Argument | Description |
|---|---|
|
Required. One or more If two objects define a task with the same name, this raises a |
|
The default retry configuration for new tasks registered on this workflow. Same as the |
|
The default timeout for new tasks registered on this workflow. Same as the |
|
The default compute plan for new tasks registered on this workflow. Same as the |
The @app.task decorator
You apply the @app.task decorator to a Python function to register it as a workflow task. For details, see Defining Workflow Tasks
Minimal example
Example with all arguments
Argument reference
| Option | Description |
|---|---|
|
Task decorator arguments | |
|
A custom name for the task. This affects the task's slug, which you use to reference the task when triggering runs. If omitted, defaults to the name of the decorated function. |
|
A |
|
| |