Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ Some examples require extra dependencies. See each sample's directory for specif

## Test

Running the tests requires `poe` to be installed.
To run the tests:

uv tool install poethepoet

Once you have `poe` installed you can run:

poe test
uv run poe test
4 changes: 2 additions & 2 deletions activity_worker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ First run the Go workflow worker by running this in the `go_workflow` directory

go run .

Then in another terminal, run the sample from this directory:
Then in another terminal, run the sample from the root directory:

uv run activity_worker.py
uv run activity_worker/activity_worker.py

The Python code will invoke the Go workflow which will execute the Python activity and return.
6 changes: 3 additions & 3 deletions bedrock/basic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

A basic Bedrock workflow. Starts a workflow with a prompt, generates a response and ends the workflow.

To run, first see `samples-python` [README.md](../../README.md), and `bedrock` [README.md](../README.md) for prerequisites specific to this sample. Once set up, run the following from this directory:
To run, first see `samples-python` [README.md](../../README.md), and `bedrock` [README.md](../README.md) for prerequisites specific to this sample. Once set up, run the following from the root directory:

1. Run the worker: `uv run run_worker.py`
1. Run the worker: `uv run bedrock/basic/run_worker.py`
2. In another terminal run the client with a prompt:

e.g. `uv run send_message.py 'What animals are marsupials?'`
e.g. `uv run bedrock/basic/send_message.py 'What animals are marsupials?'`
12 changes: 6 additions & 6 deletions bedrock/entity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

Multi-Turn Chat using an Entity Workflow. The workflow runs forever unless explicitly ended. The workflow continues as new after a configurable number of chat turns to keep the prompt size small and the Temporal event history small. Each continued-as-new workflow receives a summary of the conversation history so far for context.

To run, first see `samples-python` [README.md](../../README.md), and `bedrock` [README.md](../README.md) for prerequisites specific to this sample. Once set up, run the following from this directory:
To run, first see `samples-python` [README.md](../../README.md), and `bedrock` [README.md](../README.md) for prerequisites specific to this sample. Once set up, run the following from the root directory:

1. Run the worker: `uv run run_worker.py`
1. Run the worker: `uv run bedrock/entity/run_worker.py`
2. In another terminal run the client with a prompt.

Example: `uv run send_message.py 'What animals are marsupials?'`
Example: `uv run bedrock/entity/send_message.py 'What animals are marsupials?'`

3. View the worker's output for the response.
4. Give followup prompts by signaling the workflow.

Example: `uv run send_message.py 'Do they lay eggs?'`
Example: `uv run bedrock/entity/send_message.py 'Do they lay eggs?'`
5. Get the conversation history summary by querying the workflow.

Example: `uv run get_history.py`
6. To end the chat session, run `uv run end_chat.py`
Example: `uv run bedrock/entity/get_history.py`
6. To end the chat session, run `uv run bedrock/entity/end_chat.py`
10 changes: 5 additions & 5 deletions bedrock/signals_and_queries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@

Adding signals & queries to the [basic Bedrock sample](../1_basic). Starts a workflow with a prompt, allows follow-up prompts to be given using Temporal signals, and allows the conversation history to be queried using Temporal queries.

To run, first see `samples-python` [README.md](../../README.md), and `bedrock` [README.md](../README.md) for prerequisites specific to this sample. Once set up, run the following from this directory:
To run, first see `samples-python` [README.md](../../README.md), and `bedrock` [README.md](../README.md) for prerequisites specific to this sample. Once set up, run the following from the root directory:

1. Run the worker: `uv run run_worker.py`
1. Run the worker: `uv run bedrock/signals_and_queries/run_worker.py`
2. In another terminal run the client with a prompt.

Example: `uv run send_message.py 'What animals are marsupials?'`
Example: `uv run bedrock/signals_and_queries/send_message.py 'What animals are marsupials?'`

3. View the worker's output for the response.
4. Give followup prompts by signaling the workflow.

Example: `uv run send_message.py 'Do they lay eggs?'`
Example: `uv run bedrock/signals_and_queries/send_message.py 'Do they lay eggs?'`
5. Get the conversation history by querying the workflow.

Example: `uv run get_history.py`
Example: `uv run bedrock/signals_and_queries/get_history.py`
6. The workflow will timeout after inactivity.
6 changes: 3 additions & 3 deletions cloud_export_to_parquet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ Please make sure your python is 3.9 above. For this sample, run:

Before you start, please modify workflow input in `create_schedule.py` with your s3 bucket and namespace. Also make sure you've the right AWS permission set up in your environment to allow this workflow read and write to your s3 bucket.

To run, first see [README.md](../README.md) for prerequisites. Then, run the following from this directory to start the worker:
To run, first see [README.md](../README.md) for prerequisites. Then, run the following from the root directory to start the worker:

```bash
uv run run_worker.py
uv run cloud_export_to_parquet/run_worker.py
```

This will start the worker. Then, in another terminal, run the following to execute the schedule:

```bash
uv run create_schedule.py
uv run cloud_export_to_parquet/create_schedule.py
```

The workflow should convert exported file in your input s3 bucket to parquet in your specified location.
6 changes: 3 additions & 3 deletions context_propagation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
This sample shows how to use an interceptor to propagate contextual information through workflows and activities. For
this example, [contextvars](https://docs.python.org/3/library/contextvars.html) holds the contextual information.

To run, first see [README.md](../README.md) for prerequisites. Then, run the following from this directory to start the
To run, first see [README.md](../README.md) for prerequisites. Then, run the following from the root directory to start the
worker:

uv run worker.py
uv run context_propagation/worker.py

This will start the worker. Then, in another terminal, run the following to execute the workflow:

uv run starter.py
uv run context_propagation/starter.py

The starter terminal should complete with the hello result and the worker terminal should show the logs with the
propagated user ID contextual information flowing through the workflows/activities.
6 changes: 3 additions & 3 deletions custom_converter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

This sample shows how to make a custom payload converter for a type not natively supported by Temporal.

To run, first see [README.md](../README.md) for prerequisites. Then, run the following from this directory to start the
To run, first see [README.md](../README.md) for prerequisites. Then, run the following from the root directory to start the
worker:

uv run worker.py
uv run custom_converter/worker.py

This will start the worker. Then, in another terminal, run the following to execute the workflow:

uv run starter.py
uv run custom_converter/starter.py

The workflow should complete with the hello result. If the custom converter was not set for the custom input and output
classes, we would get an error on the client side and on the worker side.
6 changes: 3 additions & 3 deletions custom_decorator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
This sample shows a custom decorator can help with Temporal code reuse. Specifically, this makes a `@auto_heartbeater`
decorator that automatically configures an activity to heartbeat twice as frequently as the heartbeat timeout is set to.

To run, first see [README.md](../README.md) for prerequisites. Then, run the following from this directory to start the
To run, first see [README.md](../README.md) for prerequisites. Then, run the following from the root directory to start the
worker:

uv run worker.py
uv run custom_decorator/worker.py

This will start the worker. Then, in another terminal, run the following to execute the workflow:

uv run starter.py
uv run custom_decorator/starter.py

The workflow will be started, and then after 5 seconds will be sent a signal to cancel its forever-running activity.
The activity has a heartbeat timeout set to 2s, so since it has the `@auto_heartbeater` decorator set, it will heartbeat
Expand Down
12 changes: 6 additions & 6 deletions dsl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ For this sample, the optional `dsl` dependency group must be included. To includ

uv sync --group dsl

To run, first see [README.md](../README.md) for prerequisites. Then, run the following from this directory to start the
To run, first see [README.md](../README.md) for prerequisites. Then, run the following from the root directory to start the
worker:

uv run worker.py
uv run dsl/worker.py

This will start the worker. Then, in another terminal, run the following to execute a workflow of steps defined in
[workflow1.yaml](workflow1.yaml):
[workflow1.yaml](dsl/workflow1.yaml):

uv run starter.py workflow1.yaml
uv run dsl/starter.py dsl/workflow1.yaml

This will run the workflow and show the final variables that the workflow returns. Looking in the worker terminal, each
step executed will be visible.

Similarly we can do the same for the more advanced [workflow2.yaml](workflow2.yaml) file:
Similarly we can do the same for the more advanced [workflow2.yaml](dsl/workflow2.yaml) file:

uv run starter.py workflow2.yaml
uv run dsl/starter.py dsl/workflow2.yaml

This sample gives a guide of how one can write a workflow to interpret arbitrary steps from a user-provided DSL. Many
DSL models are more advanced and are more specific to conform to business logic needs.
8 changes: 4 additions & 4 deletions encryption/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ For this sample, the optional `encryption` dependency group must be included. To

uv sync --group encryption

To run, first see [README.md](../README.md) for prerequisites. Then, run the following from this directory to start the
To run, first see [README.md](../README.md) for prerequisites. Then, run the following from the root directory to start the
worker:

uv run worker.py
uv run encryption/worker.py

This will start the worker. Then, in another terminal, run the following to execute the workflow:

uv run starter.py
uv run encryption/starter.py

The workflow should complete with the hello result. To view the workflow, use [temporal](https://docs.temporal.io/cli):

Expand All @@ -31,7 +31,7 @@ Note how the result looks like (with wrapping removed):
This is because the data is encrypted and not visible. To make data visible to external Temporal tools like `temporal` and
the UI, start a codec server in another terminal:

uv run codec_server.py
uv run encryption/codec_server.py

Now with that running, run `temporal` again with the codec endpoint:

Expand Down
8 changes: 4 additions & 4 deletions gevent_async/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ For this sample, the optional `gevent` dependency group must be included. To inc
uv sync --group gevent

To run the sample, first see [README.md](../README.md) for prerequisites such as having a localhost Temporal server
running. Then, run the following from this directory to start the worker:
running. Then, run the following from the root directory to start the worker:

uv run worker.py
uv run gevent_async/worker.py

This will start the worker. The worker has a workflow and two activities, one `asyncio` based and one gevent based. Now
in another terminal, run the following from this directory to execute the workflow:
in another terminal, run the following to execute the workflow:

uv run starter.py
uv run gevent_async/starter.py

The workflow should run and complete with the hello result. Note on the worker terminal there will be logs of the
workflow and activity executions.
6 changes: 3 additions & 3 deletions hello/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

These samples show basic workflow and activity features.

To run, first see [README.md](../README.md) for prerequisites. Then, run the following from this directory to run the
To run, first see [README.md](../README.md) for prerequisites. Then, run the following from the root directory to run the
`hello_activity.py` sample:

uv run hello_activity.py
uv run hello/hello_activity.py

The result will be:

Result: Hello, World!

Replace `hello_activity.py` in the command with any other example filename to run it instead.
Replace `hello/hello_activity.py` in the command with any other example filename (with the `hello/` prefix) to run it instead.

## Samples

Expand Down
6 changes: 3 additions & 3 deletions langchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ Export your [OpenAI API key](https://platform.openai.com/api-keys) as an environ

export OPENAI_API_KEY='...'

To run, first see [README.md](../README.md) for prerequisites. Then, run the following from this directory to start the
To run, first see [README.md](../README.md) for prerequisites. Then, run the following from the root directory to start the
worker:

uv run worker.py
uv run langchain/worker.py

This will start the worker. Then, in another terminal, run the following to execute a workflow:

uv run starter.py
uv run langchain/starter.py

Then, in another terminal, run the following command to translate a phrase:

Expand Down
6 changes: 3 additions & 3 deletions message_passing/introduction/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ See https://docs.temporal.io/develop/python/message-passing.

To run, first see the main [README.md](../../README.md) for prerequisites.

Then create two terminals and `cd` to this directory.
Then create two terminals.

Run the worker in one terminal:

uv run worker.py
uv run message_passing/introduction/worker.py

And execute the workflow in the other terminal:

uv run starter.py
uv run message_passing/introduction/starter.py

8 changes: 4 additions & 4 deletions message_passing/safe_message_handlers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ This sample shows off important techniques for handling signals and updates, aka

To run, first see [README.md](../../README.md) for prerequisites.

Then, run the following from this directory to run the worker:
\
uv run worker.py
Then, run the following from the root directory to run the worker:

uv run message_passing/safe_message_handlers/worker.py

Then, in another terminal, run the following to execute the workflow:

uv run starter.py
uv run message_passing/safe_message_handlers/starter.py

This will start a worker to run your workflow and activities, then start a ClusterManagerWorkflow and put it through its paces.
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ update-with-start is used to add items to the cart, receiving back the updated c

To run, first see the main [README.md](../../../README.md) for prerequisites.

Then run the following from this directory:
Then run the following from the root directory:

uv run worker.py
uv run message_passing/update_with_start/lazy_initialization/worker.py

Then, in another terminal:

uv run starter.py
uv run message_passing/update_with_start/lazy_initialization/starter.py

This will start a worker to run your workflow and activities, then simulate a backend application receiving
requests to add items to a shopping cart, before finalizing the order.
6 changes: 3 additions & 3 deletions message_passing/waiting_for_handlers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ usually wait for the handlers to finish immediately before the call to
continue_as_new(); that's not illustrated in this sample.


To run, open two terminals and `cd` to this directory in them.
To run, open two terminals.

Run the worker in one terminal:

uv run worker.py
uv run message_passing/waiting_for_handlers/worker.py

And run the workflow-starter code in the other terminal:

uv run starter.py
uv run message_passing/waiting_for_handlers/starter.py


Here's the output you'll see:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ This sample demonstrates how to do the following:

For a simpler sample showing how to do (1) without (2), see [safe_message_handlers](../safe_message_handlers/README.md).

To run, open two terminals and `cd` to this directory in them.
To run, open two terminals.

Run the worker in one terminal:

uv run worker.py
uv run message_passing/waiting_for_handlers_and_compensation/worker.py

And run the workflow-starter code in the other terminal:

uv run starter.py
uv run message_passing/waiting_for_handlers_and_compensation/starter.py


Here's the output you'll see:
Expand Down
6 changes: 3 additions & 3 deletions open_telemetry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ To run, first see [README.md](../README.md) for prerequisites. Then run the foll

docker compose up

Now, from this directory, start the worker in its own terminal:
Now, start the worker in its own terminal:

uv run worker.py
uv run open_telemetry/worker.py

Then, in another terminal, run the following to execute the workflow:

uv run starter.py
uv run open_telemetry/starter.py

The workflow should complete with the hello result.

Expand Down
Loading
Loading