This is the set of Python samples for the Python SDK.
Prerequisites:
- Python >= 3.8
- Poetry
- Local Temporal server running
With this repository cloned, run the following at the root of the directory:
poetry install
That loads all required dependencies. Then to run a sample, usually you just run it in Python. For example:
poetry run python hello/hello_activity.py
Some examples require extra dependencies. See each sample's directory for specific instructions.
- hello - All of the basic features.
- hello_activity - Execute an activity from a workflow.
- hello_activity_choice - Execute certain activities inside a workflow based on dynamic input.
- hello_activity_method - Demonstrate an activity that is an instance method on a class and can access class state.
- hello_activity_multiprocess - Execute a synchronous activity on a process pool.
- hello_activity_retry - Demonstrate activity retry by failing until a certain number of attempts.
- hello_activity_threaded - Execute a synchronous activity on a thread pool.
- hello_async_activity_completion - Complete an activity outside of the function that was called.
- hello_cancellation - Manually react to cancellation inside workflows and activities.
- hello_child_workflow - Execute a child workflow from a workflow.
- hello_continue_as_new - Use continue as new to restart a workflow.
- hello_cron - Execute a workflow once a minute.
- hello_exception - Execute an activity that raises an error out of the workflow and out of the program.
- hello_local_activity - Execute a local activity from a workflow.
- hello_mtls - Accept URL, namespace, and certificate info as CLI args and use mTLS for connecting to server.
- hello_parallel_activity - Execute multiple activities at once.
- hello_query - Invoke queries on a workflow.
- hello_search_attributes - Start workflow with search attributes then change while running.
- hello_signal - Send signals to a workflow.
- activity_worker - Use Python activities from a workflow in another language.
- bedrock - Orchestrate a chatbot with Amazon Bedrock.
- cloud_export_to_parquet - Set up schedule workflow to process exported files on an hourly basis
- context_propagation - Context propagation through workflows/activities via interceptor.
- custom_converter - Use a custom payload converter to handle custom types.
- custom_decorator - Custom decorator to auto-heartbeat a long-running activity.
- dsl - DSL workflow that executes steps defined in a YAML file.
- encryption - Apply end-to-end encryption for all input/output.
- gevent_async - Combine gevent and Temporal.
- langchain - Orchestrate workflows for LangChain.
- open_telemetry - Trace workflows with OpenTelemetry.
- patching - Alter workflows safely with
patch
anddeprecate_patch
. - polling - Recommended implementation of an activity that needs to periodically poll an external resource waiting its successful completion.
- prometheus - Configure Prometheus metrics on clients/workers.
- pydantic_converter - Data converter for using Pydantic models.
- schedules - Demonstrates a Workflow Execution that occurs according to a schedule.
- sentry - Report errors to Sentry.
- worker_specific_task_queues - Use unique task queues to ensure activities run on specific workers.
- worker_versioning - Use the Worker Versioning feature to more easily version your workflows & other code.
Running the tests requires poe
to be installed.
python -m pip install poethepoet
Once you have poe
installed you can run:
poe test