samples-python icon indicating copy to clipboard operation
samples-python copied to clipboard

Add Request/Response sample with activity-based responses (fixes #6)

Open barmoshe opened this issue 10 months ago • 2 comments

What was changed

  • Added a new sample directory reqrespactivity to the repository.
  • Ported the Request/Response demo from Go to Python, which demonstrates how to send a request (via a signal) to a workflow and receive a response via a callback activity.
  • This sample includes:
    • workflow.py: Contains the workflow definition, data models, and the uppercase activity.
    • requester.py: Implements a requester that signals the workflow and awaits the callback response.
    • starter.py: Starts the workflow.
    • worker.py: Runs the workflow and activity worker.
    • requester_run.py: Continuously sends requests (e.g., "foo0", "foo1", etc.) to the workflow and prints the uppercase responses.
  • An updated README (README.md) provides detailed instructions on running the sample.

Why?

  • To provide a Python port of the Request/Response demo as seen in the Go samples.
  • This sample demonstrates the use of Temporal's Python SDK for activity-based responses where the workflow processes signal-based requests and responds using a callback activity.
  • The implementation serves as a reference for users looking to integrate similar functionality in their Python applications.

Checklist

  1. Closes #6 and #7
  2. How was this tested:
    • A Temporal server was run locally using Docker.
    • The worker was started via python worker.py to register the workflow and activity.
    • The workflow was started using python starter.py and confirmed to be running.
    • The requester was executed using python requester_run.py, which sent requests (e.g., "foo0", "foo1", etc.) and received correct uppercase responses ("FOO0", "FOO1", etc.).
  3. Any docs updates needed?
    • The new sample includes its own README that documents the sample and mirrors the instructions from the Go version.
    • No further updates to docs.temporal.io are required at this time.

barmoshe avatar Mar 11 '25 11:03 barmoshe

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Mar 11 '25 11:03 CLAassistant

https://github.com/temporalio/samples-python/issues/6 and the Go samples predate Workflow Update. We now recommend using workflow update for request/response instead of the "response activity" pattern.

cretz avatar Mar 11 '25 14:03 cretz