Unofficial Python SDK for the Temporal Workflow Engine
Status
This should be considered EXPERIMENTAL at the moment. At the moment, all I can say is that the test cases currently pass. I have not tested this for any real world use cases yet.
Installation
pip install temporal-python-sdk
Sample Code
Sample code for using this library can be found in Workflows in Python Using Temporal.
Hello World
import asyncio
import logging
from datetime import timedelta
from temporal.activity_method import activity_method
from temporal.workerfactory import WorkerFactory
from temporal.workflow import workflow_method, Workflow, WorkflowClient
logging.basicConfig(level=logging.INFO)
TASK_QUEUE = "HelloActivity-python-tq"
NAMESPACE = "default"
# Activities Interface
class GreetingActivities:
@activity_method(task_queue=TASK_QUEUE, schedule_to_close_timeout=timedelta(seconds=1000))
async def compose_greeting(self, greeting: str, name: str) -> str:
raise NotImplementedError
# Activities Implementation
class GreetingActivitiesImpl:
async def compose_greeting(self, greeting: str, name: str):
return greeting + " " + name + "!"
# Workflow Interface
class GreetingWorkflow:
@workflow_method(task_queue=TASK_QUEUE)
async def get_greeting(self, name: str) -> str:
raise NotImplementedError
# Workflow Implementation
class GreetingWorkflowImpl(GreetingWorkflow):
def __init__(self):
self.greeting_activities: GreetingActivities = Workflow.new_activity_stub(GreetingActivities)
pass
async def get_greeting(self, name):
return await self.greeting_activities.compose_greeting("Hello", name)
async def client_main():
client = WorkflowClient.new_client(namespace=NAMESPACE)
factory = WorkerFactory(client, NAMESPACE)
worker = factory.new_worker(TASK_QUEUE)
worker.register_activities_implementation(GreetingActivitiesImpl(), "GreetingActivities")
worker.register_workflow_implementation_type(GreetingWorkflowImpl)
factory.start()
greeting_workflow: GreetingWorkflow = client.new_workflow_stub(GreetingWorkflow)
result = await greeting_workflow.get_greeting("Python")
print(result)
print("Stopping workers.....")
await worker.stop()
print("Workers stopped......")
if __name__ == '__main__':
asyncio.run(client_main())
Roadmap
1.0
- Workflow argument passing and return values
- Activity invocation
- Activity heartbeat and Activity.getHeartbeatDetails()
- doNotCompleteOnReturn
- ActivityCompletionClient
- complete
- complete_exceptionally
- Activity get_namespace(), get_task_token() get_workflow_execution()
- Activity Retry
- Activity Failure Exceptions
- workflow_execution_timeout / workflow_run_timeout / workflow_task_timeout
- Workflow exceptions
- Cron workflows
- Workflow static methods:
- await_till()
- sleep()
- current_time_millis()
- now()
- random_uuid()
- new_random()
- get_workflow_id()
- get_run_id()
- get_version()
- get_logger()
- Activity invocation parameters
- Query method
- Signal methods
- Workflow start parameters - workflow_id etc...
- Workflow client - starting workflows synchronously
- Workflow client - starting workflows asynchronously (WorkflowClient.start)
- Get workflow result after async execution (client.wait_for_close)
- Workflow client - invoking signals
- Workflow client - invoking queries
1.1
- ActivityStub and Workflow.newUntypedActivityStub
- Remove threading, use coroutines for everything all concurrency
- Classes as arguments and return values to/from activity and workflow methods (DataConverter)
- Type hints for DataConverter
- Parallel activity execution (STATUS: there's a working but not finalized API).
1.2
- Timers
- Custom workflow ids through start() and new_workflow_stub()
- WorkflowStub and WorkflowClient.newUntypedWorkflowStub
- ContinueAsNew
- Sticky workflows
- Child Workflows
1.3
- Support for keyword arguments
2.0
- Compatibility with Java client
- Compatibility with Golang client
- Upgrade python-betterproto
Post 2.0:
- sideEffect/mutableSideEffect
- Local activity
- Cancellation Scopes
- Explicit activity ids for activity invocations
Metadata
Release files for temporal-python-sdk 1.0.19
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| temporal-python-sdk-1.0.19.tar.gz | 51.6 kB | Without provenance | Details for temporal-python-sdk-1.0.19.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| temporal_python_sdk-1.0.19-py3-none-any.whl | Python 3 | none | any | Details for temporal_python_sdk-1.0.19-py3-none-any.whl |
Total release size: 116.0 kB
Release files / temporal-python-sdk-1.0.19.tar.gz
| Download URL | temporal-python-sdk-1.0.19.tar.gz |
|---|---|
| Size | 51.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be3ecbc25ad36b6d2c49b4b9ea2a299c4112cadf9fe3b40c1172adb356a822b6
|
|
BLAKE2b-256 checksum How to use checksums |
f93565b712ff6bfaec51f783d3c54228579e0f4900f5f93f82e73b89fe81c1a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.7
|
Release files / temporal_python_sdk-1.0.19-py3-none-any.whl
| Download URL | temporal_python_sdk-1.0.19-py3-none-any.whl |
|---|---|
| Size | 64.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
69e40dd70610e20296ffb42e608689d56367ba46e103d98766a44f10c021dcb8
|
|
BLAKE2b-256 checksum How to use checksums |
5bf8a0f349f0b0db55bc643e8a73b9c67f7732efe2a795e77384f5b090c7c0ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.7
|
Security for temporal-python-sdk 1.0.19
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.