Workflows SDK for Python

Usage and symbol reference

The Render SDK for Python provides support for:

  • Defining workflow
  • Triggering 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.

ArgumentDescription
default_retry

A Retry object defining default retry behavior for all tasks in this workflow.

Individual tasks can override this.

default_timeout

The default timeout (in seconds) for all tasks in this workflow.

Individual tasks can override this.

default_plan

The default to use for all tasks in this workflow.

Individual task definitions can override this.

One of the following:

CPURAMPlan ID

Up to 1 CPU

Up to 4 GB

flex

24 GB

2c-4g

28 GB

2c-8g

48 GB

4c-8g

416 GB

4c-16g

The default value is flex.

Providing starter or standard is equivalent to providing flex (these two compute plans were discontinued following the Render Workflows beta).

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).

ArgumentDescription
*apps

Required. One or more Workflows objects to incorporate into this object.

If two objects define a task with the same name, this raises a ValueError.

default_retry

The default retry configuration for new tasks registered on this workflow. Same as the Workflows constructor argument.

default_timeout

The default timeout for new tasks registered on this workflow. Same as the Workflows constructor argument.

default_plan

The default compute plan for new tasks registered on this workflow. Same as the Workflows constructor argument.

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

OptionDescription

Task decorator arguments

name

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.

retry

A Retry object defining retry behavior for the task. See retry arguments below.