Skip to main content

Run Temporal's quickstart on Diagrid

Temporal's getting-started tutorial builds a money transfer application: a workflow that withdraws money from one account and deposits it in another. This guide runs that application on Diagrid. You don't change its code. You only point it at a Diagrid App instead of a local Temporal server.

Temporal workflows on Diagrid are in preview.

Prerequisites​

  • The Diagrid CLI, logged in with diagrid login.
  • On macOS and Linux, jq.
  • Python 3.10 or later, or Go 1.23 or later.
  • Optional: the Temporal CLI, to check on the workflow.

You don't need a Temporal server.

1. Create a Temporal App​

Create a project and an App that uses the Temporal workflow API. Projects created with diagrid CLI 1.119.0 or later get the managed workflow store by default. With CLI 1.118.0 or older, the project has no workflow store, and diagrid app create --workflow-api temporal fails. Upgrade the CLI, or run diagrid project update temporal-quickstart --enable-managed-workflow for a project that already exists:

diagrid project create temporal-quickstart --use
diagrid app create money-transfer --workflow-api temporal --wait

The App's name, money-transfer, is the Temporal namespace the sample uses.

2. Get the sample​

git clone https://github.com/temporalio/money-transfer-project-template-python
cd money-transfer-project-template-python
python3 -m venv env
source env/bin/activate
python -m pip install "temporalio>=1.18.1"

On Windows, activate the virtual environment with env\Scripts\activate.

3. Point the sample at Diagrid​

The sample reads Temporal's standard connection settings from the environment. Set them in each terminal you use for the next steps:

export TEMPORAL_ADDRESS="$(diagrid project get temporal-quickstart -o json | jq -r '.status.endpoints.grpc | "\(.host):\(.port)"')"
export TEMPORAL_NAMESPACE=money-transfer
export TEMPORAL_API_KEY="$(diagrid appid get money-transfer -o json | jq -r .status.apiToken)"

With these set, the sample connects to Diagrid over TLS with the App's API token, instead of to localhost:7233.

4. Start the worker​

The worker runs the workflow and activity code. Start it and leave it running:

python run_worker.py

5. Start a transfer​

In a second terminal, set the connection settings again, then start the workflow:

source env/bin/activate
python run_workflow.py

The sample prints the result when the workflow completes:

Result: Transfer complete (transaction IDs: W-..., D-...)

6. See the workflow​

The workflow ran on Diagrid. List it with the Temporal CLI, which reads the same connection settings:

temporal workflow list
temporal workflow show --workflow-id pay-invoice-701

You can also find it in the workflows view of the Diagrid Web Console, or with diagrid workflow list.

To see Temporal's retries at work, follow the rest of Temporal's Python or Go tutorial. Its steps run the same way on Diagrid. Diagrid has no Temporal Web UI, so use the Temporal CLI or the Diagrid Web Console where the tutorial uses the Web UI.

Clean up​

Stop the worker with Ctrl+C, then delete the project:

diagrid project delete temporal-quickstart

Next steps​