cadence-python-client 0.1.0__tar.gz → 0.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- cadence_python_client-0.2.1/.cursorrules +49 -0
- cadence_python_client-0.2.1/.github/dco.yml +2 -0
- cadence_python_client-0.2.1/.github/pull_request_template.md +20 -0
- cadence_python_client-0.2.1/.github/workflows/ci_checks.yml +97 -0
- cadence_python_client-0.2.1/.github/workflows/python-publish.yml +62 -0
- cadence_python_client-0.2.1/.github/workflows/semantic-pr.yml +72 -0
- cadence_python_client-0.2.1/.gitignore +114 -0
- cadence_python_client-0.2.1/.gitmodules +3 -0
- cadence_python_client-0.2.1/CONTRIBUTING.md +31 -0
- cadence_python_client-0.2.1/Makefile +55 -0
- {cadence_python_client-0.1.0/cadence_python_client.egg-info → cadence_python_client-0.2.1}/PKG-INFO +11 -5
- cadence_python_client-0.2.1/cadence/_internal/activity/__init__.py +10 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/activity/_activity_executor.py +24 -6
- cadence_python_client-0.2.1/cadence/_internal/activity/_context.py +95 -0
- cadence_python_client-0.2.1/cadence/_internal/activity/_definition.py +206 -0
- cadence_python_client-0.2.1/cadence/_internal/activity/_heartbeat.py +42 -0
- cadence_python_client-0.2.1/cadence/_internal/fn_signature.py +90 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/rpc/retry.py +5 -2
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/rpc/yarpc.py +3 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/workflow/context.py +21 -6
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/workflow/deterministic_event_loop.py +37 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/workflow/statemachine/activity_state_machine.py +14 -9
- cadence_python_client-0.2.1/cadence/_internal/workflow/statemachine/cancellation.py +36 -0
- cadence_python_client-0.2.1/cadence/_internal/workflow/statemachine/completion_state_machine.py +25 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/workflow/statemachine/decision_manager.py +72 -13
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/workflow/statemachine/decision_state_machine.py +31 -13
- cadence_python_client-0.2.1/cadence/_internal/workflow/statemachine/nondeterminism.py +308 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/workflow/statemachine/timer_state_machine.py +13 -8
- cadence_python_client-0.2.1/cadence/_internal/workflow/workflow_engine.py +263 -0
- cadence_python_client-0.2.1/cadence/_internal/workflow/workflow_instance.py +53 -0
- cadence_python_client-0.2.1/cadence/activity.py +364 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/common_pb2.py +3 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/common_pb2.pyi +4 -2
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/common_pb2_grpc.py +1 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/decision_pb2.py +3 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/decision_pb2.pyi +7 -5
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/decision_pb2_grpc.py +1 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/domain_pb2.py +3 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/domain_pb2.pyi +6 -4
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/domain_pb2_grpc.py +1 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/error_pb2.py +3 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/error_pb2.pyi +2 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/error_pb2_grpc.py +1 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/history_pb2.py +3 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/history_pb2.pyi +10 -8
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/history_pb2_grpc.py +1 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/query_pb2.py +3 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/query_pb2.pyi +2 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/query_pb2_grpc.py +1 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/service_domain_pb2.py +3 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/service_domain_pb2.pyi +5 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/service_domain_pb2_grpc.py +1 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/service_meta_pb2.py +3 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/service_meta_pb2_grpc.py +1 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/service_visibility_pb2.py +3 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/service_visibility_pb2.pyi +2 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/service_visibility_pb2_grpc.py +1 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/service_worker_pb2.py +3 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/service_worker_pb2.pyi +5 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/service_worker_pb2_grpc.py +1 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/service_workflow_pb2.py +3 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/service_workflow_pb2.pyi +4 -2
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/service_workflow_pb2_grpc.py +1 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/tasklist_pb2.py +3 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/tasklist_pb2.pyi +5 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/tasklist_pb2_grpc.py +1 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/visibility_pb2.py +3 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/visibility_pb2.pyi +4 -2
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/visibility_pb2_grpc.py +1 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/workflow_pb2.py +3 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/workflow_pb2.pyi +9 -7
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/workflow_pb2_grpc.py +1 -1
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/client.py +66 -10
- cadence_python_client-0.2.1/cadence/contrib/__init__.py +0 -0
- cadence_python_client-0.2.1/cadence/contrib/openai/README.md +124 -0
- cadence_python_client-0.2.1/cadence/contrib/openai/__init__.py +15 -0
- cadence_python_client-0.2.1/cadence/contrib/openai/cadence_agent_runner.py +133 -0
- cadence_python_client-0.2.1/cadence/contrib/openai/cadence_handoff.py +42 -0
- cadence_python_client-0.2.1/cadence/contrib/openai/cadence_model.py +71 -0
- cadence_python_client-0.2.1/cadence/contrib/openai/cadence_registry.py +6 -0
- cadence_python_client-0.2.1/cadence/contrib/openai/cadence_tool.py +54 -0
- cadence_python_client-0.2.1/cadence/contrib/openai/images/cadence-web-agent-run.jpg +0 -0
- cadence_python_client-0.2.1/cadence/contrib/openai/openai_activities.py +51 -0
- cadence_python_client-0.2.1/cadence/contrib/openai/pydantic_data_converter.py +148 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/data_converter.py +12 -5
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/error.py +20 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/worker/__init__.py +0 -2
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/worker/_registry.py +67 -81
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/worker/_worker.py +25 -5
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/workflow.py +66 -2
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1/cadence_python_client.egg-info}/PKG-INFO +11 -5
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence_python_client.egg-info/SOURCES.txt +74 -3
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence_python_client.egg-info/requires.txt +11 -4
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/pyproject.toml +14 -7
- cadence_python_client-0.2.1/scripts/dev.py +187 -0
- cadence_python_client-0.2.1/scripts/fix_pyi_imports.py +65 -0
- cadence_python_client-0.2.1/scripts/generate_proto.py +175 -0
- cadence_python_client-0.2.1/tests/cadence/_internal/activity/test_activity_executor.py +511 -0
- cadence_python_client-0.2.1/tests/cadence/_internal/activity/test_heartbeat.py +97 -0
- cadence_python_client-0.2.1/tests/cadence/_internal/rpc/test_error.py +198 -0
- cadence_python_client-0.2.1/tests/cadence/_internal/rpc/test_retry.py +190 -0
- cadence_python_client-0.2.1/tests/cadence/_internal/test_fn_signature.py +279 -0
- cadence_python_client-0.2.1/tests/cadence/_internal/workflow/statemachine/test_activity_state_machine.py +199 -0
- cadence_python_client-0.2.1/tests/cadence/_internal/workflow/statemachine/test_decision_manager.py +190 -0
- cadence_python_client-0.2.1/tests/cadence/_internal/workflow/statemachine/test_nondeterminism.py +398 -0
- cadence_python_client-0.2.1/tests/cadence/_internal/workflow/statemachine/test_timer_state_machine.py +75 -0
- cadence_python_client-0.2.1/tests/cadence/_internal/workflow/test_decision_events_iterator.py +165 -0
- cadence_python_client-0.2.1/tests/cadence/_internal/workflow/test_deterministic_event_loop.py +96 -0
- cadence_python_client-0.2.1/tests/cadence/_internal/workflow/test_history_event_iterator.py +180 -0
- cadence_python_client-0.2.1/tests/cadence/_internal/workflow/test_workflow_engine.py +94 -0
- cadence_python_client-0.2.1/tests/cadence/common_activities.py +80 -0
- cadence_python_client-0.2.1/tests/cadence/data_converter_test.py +104 -0
- cadence_python_client-0.2.1/tests/cadence/metrics/test_metrics.py +53 -0
- cadence_python_client-0.2.1/tests/cadence/metrics/test_prometheus.py +146 -0
- cadence_python_client-0.2.1/tests/cadence/test_activity.py +50 -0
- cadence_python_client-0.2.1/tests/cadence/test_client.py +183 -0
- cadence_python_client-0.2.1/tests/cadence/test_client_workflow.py +601 -0
- cadence_python_client-0.2.1/tests/cadence/worker/test_base_task_handler.py +117 -0
- cadence_python_client-0.2.1/tests/cadence/worker/test_decision_task_handler.py +457 -0
- cadence_python_client-0.2.1/tests/cadence/worker/test_decision_task_handler_integration.py +269 -0
- cadence_python_client-0.2.1/tests/cadence/worker/test_decision_worker_integration.py +312 -0
- cadence_python_client-0.2.1/tests/cadence/worker/test_poller.py +158 -0
- cadence_python_client-0.2.1/tests/cadence/worker/test_registry.py +296 -0
- cadence_python_client-0.2.1/tests/cadence/worker/test_task_handler_integration.py +379 -0
- cadence_python_client-0.2.1/tests/cadence/worker/test_worker.py +66 -0
- cadence_python_client-0.2.1/tests/conftest.py +16 -0
- cadence_python_client-0.2.1/tests/integration_tests/conftest.py +89 -0
- cadence_python_client-0.2.1/tests/integration_tests/docker-compose.yml +59 -0
- cadence_python_client-0.2.1/tests/integration_tests/helper.py +43 -0
- cadence_python_client-0.2.1/tests/integration_tests/nondeterminism/success.json +316 -0
- cadence_python_client-0.2.1/tests/integration_tests/nondeterminism/test_nondeterministic_workflows.py +571 -0
- cadence_python_client-0.2.1/tests/integration_tests/test_client.py +258 -0
- cadence_python_client-0.2.1/tests/integration_tests/workflow/test_activities.py +243 -0
- cadence_python_client-0.2.1/tests/integration_tests/workflow/test_continue_as_new.py +60 -0
- cadence_python_client-0.2.1/tests/integration_tests/workflow/test_heartbeat.py +118 -0
- cadence_python_client-0.2.1/tests/integration_tests/workflow/test_serialization.py +210 -0
- cadence_python_client-0.2.1/tests/integration_tests/workflow/test_timer.py +135 -0
- cadence_python_client-0.2.1/tests/integration_tests/workflow/test_workflows.py +123 -0
- cadence_python_client-0.2.1/uv.lock +2302 -0
- cadence_python_client-0.1.0/cadence/_internal/activity/__init__.py +0 -5
- cadence_python_client-0.1.0/cadence/_internal/activity/_context.py +0 -58
- cadence_python_client-0.1.0/cadence/_internal/workflow/decisions_helper.py +0 -312
- cadence_python_client-0.1.0/cadence/_internal/workflow/workflow_engine.py +0 -245
- cadence_python_client-0.1.0/cadence/_internal/workflow/workflow_intance.py +0 -44
- cadence_python_client-0.1.0/cadence/activity.py +0 -255
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/LICENSE +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/NOTICE +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/README.md +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/__init__.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/__init__.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/rpc/__init__.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/rpc/error.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/workflow/__init__.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/workflow/decision_events_iterator.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/workflow/history_event_iterator.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/workflow/statemachine/__init__.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/_internal/workflow/statemachine/event_dispatcher.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/__init__.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/api/v1/service_meta_pb2.pyi +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/metrics/__init__.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/metrics/constants.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/metrics/metrics.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/metrics/prometheus.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/sample/__init__.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/sample/client_example.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/sample/grpc_usage_example.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/sample/simple_usage_example.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/signal.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/worker/_activity.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/worker/_base_task_handler.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/worker/_decision.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/worker/_decision_task_handler.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/worker/_poller.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence/worker/_types.py +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence_python_client.egg-info/dependency_links.txt +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/cadence_python_client.egg-info/top_level.txt +0 -0
- {cadence_python_client-0.1.0 → cadence_python_client-0.2.1}/setup.cfg +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Cursor Rules for Cadence Python Client
|
|
2
|
+
|
|
3
|
+
## Package Management
|
|
4
|
+
- **Always use `uv` for Python package management**
|
|
5
|
+
- Use `uv run` for running Python commands instead of `python` directly
|
|
6
|
+
- Use `uv sync` for installing dependencies instead of `pip install`
|
|
7
|
+
- Use `uv tool run` for running development tools (pytest, mypy, ruff, etc.)
|
|
8
|
+
- Only use `pip` or `python` directly when specifically required by the tool or documentation
|
|
9
|
+
|
|
10
|
+
## Examples
|
|
11
|
+
```bash
|
|
12
|
+
# ✅ Correct
|
|
13
|
+
uv run python scripts/generate_proto.py
|
|
14
|
+
uv run python -m pytest tests/
|
|
15
|
+
uv tool run mypy cadence/
|
|
16
|
+
uv tool run ruff check
|
|
17
|
+
|
|
18
|
+
# ❌ Avoid
|
|
19
|
+
python scripts/generate_proto.py
|
|
20
|
+
pip install -e ".[dev]"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Virtual Environment
|
|
24
|
+
- The project uses `uv` for virtual environment management
|
|
25
|
+
- Always activate the virtual environment using `uv` commands
|
|
26
|
+
- Dependencies are managed through `pyproject.toml` and `uv.lock`
|
|
27
|
+
|
|
28
|
+
## Testing
|
|
29
|
+
- Run tests with `uv run python -m pytest`
|
|
30
|
+
- Use `uv run` for any Python script execution
|
|
31
|
+
- Development tools should be run with `uv tool run`
|
|
32
|
+
|
|
33
|
+
## Code Generation
|
|
34
|
+
- Use `uv run python scripts/generate_proto.py` for protobuf generation
|
|
35
|
+
- Use `uv run python scripts/dev.py` for development tasks
|
|
36
|
+
|
|
37
|
+
## Code Quality
|
|
38
|
+
- **ALWAYS run linter and type checker after making code changes**
|
|
39
|
+
- Run linter with auto-fix: `uv tool run ruff check --fix`
|
|
40
|
+
- Run type checking: `uv tool run mypy cadence/`
|
|
41
|
+
- Use `uv tool run ruff check --fix && uv tool run mypy cadence/` to run both together
|
|
42
|
+
- **Standard workflow**: Make changes → Run linter → Run type checker → Commit
|
|
43
|
+
|
|
44
|
+
## Development Workflow
|
|
45
|
+
1. Make code changes
|
|
46
|
+
2. Run `uv tool run ruff check --fix` (fixes formatting and linting issues)
|
|
47
|
+
3. Run `uv tool run mypy cadence/` (checks type safety)
|
|
48
|
+
4. Run `uv run python -m pytest` (run tests)
|
|
49
|
+
5. Commit changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!-- Describe what has changed in this PR -->
|
|
2
|
+
**What changed?**
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
<!-- Tell your future self why have you made these changes -->
|
|
6
|
+
**Why?**
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
<!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? -->
|
|
10
|
+
**How did you test it?**
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
<!-- Assuming the worst case, what can be broken when deploying this change to production? -->
|
|
14
|
+
**Potential risks**
|
|
15
|
+
|
|
16
|
+
<!-- Is it notable for release? e.g. schema updates, configuration or data migration required? If so, please mention it, and also update CHANGELOG.md -->
|
|
17
|
+
**Release notes**
|
|
18
|
+
|
|
19
|
+
<!-- Is there any documentation updates should be made for config, https://cadenceworkflow.io/docs/operation-guide/setup/ ? If so, please open an PR in https://github.com/cadence-workflow/cadence-docs -->
|
|
20
|
+
**Documentation Changes**
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
name: CI Checks
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
pull_request:
|
|
5
|
+
|
|
6
|
+
jobs:
|
|
7
|
+
lint:
|
|
8
|
+
name: Lint
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@v4
|
|
12
|
+
with:
|
|
13
|
+
submodules: true
|
|
14
|
+
- name: Set up Python
|
|
15
|
+
uses: actions/setup-python@v5
|
|
16
|
+
with:
|
|
17
|
+
python-version: "3.13"
|
|
18
|
+
- name: Set up uv
|
|
19
|
+
uses: astral-sh/setup-uv@v5
|
|
20
|
+
- name: Install dependencies
|
|
21
|
+
run: |
|
|
22
|
+
uv sync --extra dev
|
|
23
|
+
- name: Ensure Proto Files changes are committed
|
|
24
|
+
run: |
|
|
25
|
+
uv run python scripts/generate_proto.py
|
|
26
|
+
if [ -n "$(git status --porcelain 2>&1)" ]; then
|
|
27
|
+
echo "There are file changes after generating proto files."
|
|
28
|
+
echo "Please run this command and commit the changes:"
|
|
29
|
+
echo "\tuv run python scripts/generate_proto.py"
|
|
30
|
+
git status --porcelain
|
|
31
|
+
git --no-pager diff
|
|
32
|
+
exit 1
|
|
33
|
+
fi
|
|
34
|
+
- name: Run Ruff linter
|
|
35
|
+
run: |
|
|
36
|
+
uv tool run ruff check
|
|
37
|
+
uv tool run ruff format --check
|
|
38
|
+
|
|
39
|
+
type-check:
|
|
40
|
+
name: Type Safety Check
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
steps:
|
|
43
|
+
- uses: actions/checkout@v4
|
|
44
|
+
with:
|
|
45
|
+
submodules: true
|
|
46
|
+
- name: Set up Python
|
|
47
|
+
uses: actions/setup-python@v5
|
|
48
|
+
with:
|
|
49
|
+
python-version: "3.13"
|
|
50
|
+
- name: Set up uv
|
|
51
|
+
uses: astral-sh/setup-uv@v5
|
|
52
|
+
- name: Install dependencies
|
|
53
|
+
run: |
|
|
54
|
+
uv sync --extra dev --extra openai
|
|
55
|
+
- name: Run mypy type checker
|
|
56
|
+
run: |
|
|
57
|
+
uv run mypy cadence/
|
|
58
|
+
|
|
59
|
+
test:
|
|
60
|
+
name: Unit Tests
|
|
61
|
+
runs-on: ubuntu-latest
|
|
62
|
+
steps:
|
|
63
|
+
- uses: actions/checkout@v4
|
|
64
|
+
with:
|
|
65
|
+
submodules: true
|
|
66
|
+
- name: Set up Python
|
|
67
|
+
uses: actions/setup-python@v5
|
|
68
|
+
with:
|
|
69
|
+
python-version: "3.13"
|
|
70
|
+
- name: Set up uv
|
|
71
|
+
uses: astral-sh/setup-uv@v5
|
|
72
|
+
- name: Install dependencies
|
|
73
|
+
run: |
|
|
74
|
+
uv sync --extra dev
|
|
75
|
+
- name: Run unit tests
|
|
76
|
+
run: |
|
|
77
|
+
uv run pytest -v
|
|
78
|
+
|
|
79
|
+
integration_test:
|
|
80
|
+
name: Integration Tests
|
|
81
|
+
runs-on: ubuntu-latest
|
|
82
|
+
steps:
|
|
83
|
+
- uses: actions/checkout@v4
|
|
84
|
+
with:
|
|
85
|
+
submodules: true
|
|
86
|
+
- name: Set up Python
|
|
87
|
+
uses: actions/setup-python@v5
|
|
88
|
+
with:
|
|
89
|
+
python-version: "3.13"
|
|
90
|
+
- name: Set up uv
|
|
91
|
+
uses: astral-sh/setup-uv@v5
|
|
92
|
+
- name: Install dependencies
|
|
93
|
+
run: |
|
|
94
|
+
uv sync --extra dev
|
|
95
|
+
- name: Run unit tests
|
|
96
|
+
run: |
|
|
97
|
+
uv run pytest -v --integration-tests
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# This workflow will upload a Python Package to PyPI when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
|
|
3
|
+
|
|
4
|
+
name: Upload Python Package
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
release:
|
|
8
|
+
types:
|
|
9
|
+
- published
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
release-build:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Install uv
|
|
22
|
+
uses: astral-sh/setup-uv@v4
|
|
23
|
+
with:
|
|
24
|
+
enable-cache: true
|
|
25
|
+
cache-dependency-glob: "uv.lock"
|
|
26
|
+
|
|
27
|
+
- name: Set up Python
|
|
28
|
+
uses: actions/setup-python@v5
|
|
29
|
+
with:
|
|
30
|
+
python-version-file: "pyproject.toml"
|
|
31
|
+
|
|
32
|
+
- name: Build release distributions
|
|
33
|
+
run: uv build
|
|
34
|
+
|
|
35
|
+
- name: Upload distributions
|
|
36
|
+
uses: actions/upload-artifact@v4
|
|
37
|
+
with:
|
|
38
|
+
name: release-dists
|
|
39
|
+
path: dist/
|
|
40
|
+
|
|
41
|
+
pypi-publish:
|
|
42
|
+
runs-on: ubuntu-latest
|
|
43
|
+
needs:
|
|
44
|
+
- release-build
|
|
45
|
+
permissions:
|
|
46
|
+
# IMPORTANT: this permission is mandatory for trusted publishing
|
|
47
|
+
id-token: write
|
|
48
|
+
|
|
49
|
+
# Dedicated environments with protections for publishing are strongly recommended.
|
|
50
|
+
environment:
|
|
51
|
+
name: pypi
|
|
52
|
+
url: https://pypi.org/p/cadence-python-client
|
|
53
|
+
|
|
54
|
+
steps:
|
|
55
|
+
- name: Retrieve release distributions
|
|
56
|
+
uses: actions/download-artifact@v4
|
|
57
|
+
with:
|
|
58
|
+
name: release-dists
|
|
59
|
+
path: dist/
|
|
60
|
+
|
|
61
|
+
- name: Publish release distributions to PyPI
|
|
62
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
name: Semantic Pull Request
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types:
|
|
6
|
+
- opened
|
|
7
|
+
- edited
|
|
8
|
+
- synchronize
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
semantic-pr:
|
|
12
|
+
name: Validate PR title follows conventional commit format
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
# TODO: Remove this once we commit to conventional commits
|
|
15
|
+
continue-on-error: true
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Validate PR title
|
|
19
|
+
id: lint_pr_title
|
|
20
|
+
uses: amannn/action-semantic-pull-request@v5.4.0
|
|
21
|
+
with:
|
|
22
|
+
# Allow standard conventional commit types
|
|
23
|
+
types: |
|
|
24
|
+
fix
|
|
25
|
+
feat
|
|
26
|
+
docs
|
|
27
|
+
style
|
|
28
|
+
refactor
|
|
29
|
+
perf
|
|
30
|
+
test
|
|
31
|
+
chore
|
|
32
|
+
ci
|
|
33
|
+
build
|
|
34
|
+
# TODO: Remove this once we've decided on scopes
|
|
35
|
+
requireScope: false
|
|
36
|
+
# Skip validation for certain labels if needed
|
|
37
|
+
ignoreLabels: |
|
|
38
|
+
skip-commit-format
|
|
39
|
+
env:
|
|
40
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
41
|
+
|
|
42
|
+
- name: Comment on PR if validation fails
|
|
43
|
+
if: steps.lint_pr_title.outputs.error_message != null
|
|
44
|
+
uses: actions/github-script@v7
|
|
45
|
+
with:
|
|
46
|
+
script: |
|
|
47
|
+
github.rest.issues.createComment({
|
|
48
|
+
issue_number: context.issue.number,
|
|
49
|
+
owner: context.repo.owner,
|
|
50
|
+
repo: context.repo.repo,
|
|
51
|
+
body: `⚠️ **Semantic PR Check Failed**
|
|
52
|
+
|
|
53
|
+
**Error Details:**
|
|
54
|
+
\`\`\`
|
|
55
|
+
${{ steps.lint_pr_title.outputs.error_message }}
|
|
56
|
+
\`\`\`
|
|
57
|
+
|
|
58
|
+
**Required Format:**
|
|
59
|
+
\`\`\`
|
|
60
|
+
<type>: <description>
|
|
61
|
+
\`\`\`
|
|
62
|
+
|
|
63
|
+
**Allowed types:** fix, feat, docs, style, refactor, perf, test, chore, ci, build
|
|
64
|
+
|
|
65
|
+
**Examples:**
|
|
66
|
+
- \`feat: add user authentication system\`
|
|
67
|
+
- \`fix: resolve memory leak in worker pool\`
|
|
68
|
+
- \`docs: update API documentation\`
|
|
69
|
+
- \`test: add integration tests for auth flow\`
|
|
70
|
+
|
|
71
|
+
This is currently a **warning only** and won't block your PR from being merged.`
|
|
72
|
+
})
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Logs
|
|
59
|
+
*.log
|
|
60
|
+
|
|
61
|
+
# Environments
|
|
62
|
+
.env
|
|
63
|
+
.venv
|
|
64
|
+
env/
|
|
65
|
+
venv/
|
|
66
|
+
ENV/
|
|
67
|
+
env.bak/
|
|
68
|
+
venv.bak/
|
|
69
|
+
|
|
70
|
+
# mypy
|
|
71
|
+
.mypy_cache/
|
|
72
|
+
.dmypy.json
|
|
73
|
+
dmypy.json
|
|
74
|
+
|
|
75
|
+
# Pyre type checker
|
|
76
|
+
.pyre/
|
|
77
|
+
|
|
78
|
+
# pytype static type analyzer
|
|
79
|
+
.pytype/
|
|
80
|
+
|
|
81
|
+
# Cython debug symbols
|
|
82
|
+
cython_debug/
|
|
83
|
+
|
|
84
|
+
# PyCharm
|
|
85
|
+
.idea/
|
|
86
|
+
*.iml
|
|
87
|
+
*.ipr
|
|
88
|
+
*.iws
|
|
89
|
+
|
|
90
|
+
# VS Code
|
|
91
|
+
.vscode/
|
|
92
|
+
|
|
93
|
+
# macOS
|
|
94
|
+
.DS_Store
|
|
95
|
+
|
|
96
|
+
# Windows
|
|
97
|
+
Thumbs.db
|
|
98
|
+
ehthumbs.db
|
|
99
|
+
Desktop.ini
|
|
100
|
+
|
|
101
|
+
# Project specific
|
|
102
|
+
.temp_gen/
|
|
103
|
+
*.pb.py
|
|
104
|
+
*.pb.pyi
|
|
105
|
+
|
|
106
|
+
# bin
|
|
107
|
+
.bin/
|
|
108
|
+
|
|
109
|
+
# Claude Code files
|
|
110
|
+
CLAUDE.md
|
|
111
|
+
settings.local.json
|
|
112
|
+
.python-version
|
|
113
|
+
*.bak
|
|
114
|
+
.mcp.json
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Contributing to Cadence Python Client
|
|
2
|
+
|
|
3
|
+
This doc is intended for contributors to the Cadence Python Client. Thanks for considering to contribute ❤️
|
|
4
|
+
|
|
5
|
+
> 📚 **New to contributing to Cadence?** Check out our [Contributing Guide](https://cadenceworkflow.io/community/how-to-contribute/getting-started) for an overview of the contribution process across all Cadence repositories. This document contains Python client specific setup and development instructions.
|
|
6
|
+
|
|
7
|
+
Once you go through the rest of this doc and get familiar with local development setup, take a look at the list of issues labeled with
|
|
8
|
+
[good first issue](https://github.com/cadence-workflow/cadence-python-client/labels/good%20first%20issue).
|
|
9
|
+
These issues are a great way to start contributing to Cadence Python Client.
|
|
10
|
+
|
|
11
|
+
Join our community on the CNCF Slack workspace at [cloud-native.slack.com](https://communityinviter.com/apps/cloud-native/cncf) in the **#cadence-users** channel to reach out and discuss issues with the team.
|
|
12
|
+
|
|
13
|
+
## Submitting Pull Requests
|
|
14
|
+
|
|
15
|
+
1. Fork the repository
|
|
16
|
+
2. Create a feature branch from `main`
|
|
17
|
+
3. Make your changes following the code quality guidelines above
|
|
18
|
+
4. Write or update tests as needed
|
|
19
|
+
5. Ensure all tests pass and there are no linting/type errors
|
|
20
|
+
6. Submit a pull request with a clear description of your changes
|
|
21
|
+
|
|
22
|
+
## Getting Help
|
|
23
|
+
|
|
24
|
+
- **GitHub Issues**: [Report bugs or request features](https://github.com/cadence-workflow/cadence-python-client/issues/new)
|
|
25
|
+
- **CNCF Slack**: Join the **#cadence-users** channel at [cloud-native.slack.com](https://communityinviter.com/apps/cloud-native/cncf)
|
|
26
|
+
- **Stack Overflow**: Tag questions with `cadence-workflow`
|
|
27
|
+
|
|
28
|
+
## License
|
|
29
|
+
|
|
30
|
+
By contributing to Cadence Python Client, you agree that your contributions will be licensed under the Apache 2.0 License.
|
|
31
|
+
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
.PHONY: pr install lint type-check test integration-test clean generate help
|
|
2
|
+
|
|
3
|
+
# Run all PR checks locally
|
|
4
|
+
pr: install generate lint type-check test integration-test
|
|
5
|
+
@echo "All PR checks passed!"
|
|
6
|
+
|
|
7
|
+
# Install dependencies
|
|
8
|
+
install:
|
|
9
|
+
@echo "Installing dependencies..."
|
|
10
|
+
uv sync --extra dev
|
|
11
|
+
|
|
12
|
+
# Generate idl files
|
|
13
|
+
generate:
|
|
14
|
+
@echo "Generating type files based on IDL..."
|
|
15
|
+
uv run python scripts/generate_proto.py
|
|
16
|
+
|
|
17
|
+
# Run linter
|
|
18
|
+
lint:
|
|
19
|
+
@echo "Running Ruff linter and fixing lint issues..."
|
|
20
|
+
uv tool run ruff check --fix
|
|
21
|
+
uv tool run ruff format
|
|
22
|
+
|
|
23
|
+
# Run type checker
|
|
24
|
+
type-check:
|
|
25
|
+
@echo "Running mypy type checker..."
|
|
26
|
+
uv run mypy cadence/ tests/
|
|
27
|
+
|
|
28
|
+
# Run unit tests
|
|
29
|
+
test:
|
|
30
|
+
@echo "Running unit tests..."
|
|
31
|
+
uv run pytest -v
|
|
32
|
+
|
|
33
|
+
# Run integration tests
|
|
34
|
+
integration-test:
|
|
35
|
+
@echo "Running integration tests..."
|
|
36
|
+
uv run pytest -v --integration-tests
|
|
37
|
+
|
|
38
|
+
# Clean generated files and caches
|
|
39
|
+
clean:
|
|
40
|
+
@echo "Cleaning up..."
|
|
41
|
+
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
|
|
42
|
+
find . -type f -name "*.pyc" -delete 2>/dev/null || true
|
|
43
|
+
find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
|
|
44
|
+
|
|
45
|
+
# Show help
|
|
46
|
+
help:
|
|
47
|
+
@echo "Available targets:"
|
|
48
|
+
@echo " make pr - Run all PR checks (recommended before submitting PR)"
|
|
49
|
+
@echo " make install - Install dependencies"
|
|
50
|
+
@echo " make lint - Run Ruff linter"
|
|
51
|
+
@echo " make type-check - Run mypy type checker"
|
|
52
|
+
@echo " make test - Run unit tests"
|
|
53
|
+
@echo " make integration-test - Run integration tests"
|
|
54
|
+
@echo " make clean - Remove generated files and caches"
|
|
55
|
+
@echo " make help - Show this help message"
|
{cadence_python_client-0.1.0/cadence_python_client.egg-info → cadence_python_client-0.2.1}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cadence-python-client
|
|
3
|
-
Version: 0.1
|
|
3
|
+
Version: 0.2.1
|
|
4
4
|
Summary: Python framework for authoring Cadence workflows and activities
|
|
5
5
|
Author: Cadence
|
|
6
6
|
License: Apache-2.0
|
|
@@ -23,14 +23,14 @@ Requires-Python: <3.14,>=3.11
|
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
License-File: LICENSE
|
|
25
25
|
License-File: NOTICE
|
|
26
|
-
Requires-Dist: grpcio
|
|
27
|
-
Requires-Dist: grpcio-status>=1.
|
|
26
|
+
Requires-Dist: grpcio>=1.73.1
|
|
27
|
+
Requires-Dist: grpcio-status>=1.73.1
|
|
28
28
|
Requires-Dist: msgspec>=0.19.0
|
|
29
|
-
Requires-Dist: protobuf
|
|
29
|
+
Requires-Dist: protobuf<7.0.0,>=6.31.0
|
|
30
30
|
Requires-Dist: typing-extensions>=4.0.0
|
|
31
31
|
Requires-Dist: prometheus-client>=0.21.0
|
|
32
32
|
Provides-Extra: dev
|
|
33
|
-
Requires-Dist: grpcio-tools
|
|
33
|
+
Requires-Dist: grpcio-tools>=1.73.1; extra == "dev"
|
|
34
34
|
Requires-Dist: pytest>=8.4.1; extra == "dev"
|
|
35
35
|
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
36
36
|
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
@@ -40,6 +40,9 @@ Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
|
40
40
|
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
41
41
|
Requires-Dist: pre-commit>=3.0.0; extra == "dev"
|
|
42
42
|
Requires-Dist: pytest-docker>=3.2.3; extra == "dev"
|
|
43
|
+
Requires-Dist: opentelemetry-instrumentation-grpc==0.60b1; extra == "dev"
|
|
44
|
+
Requires-Dist: opentelemetry-sdk>=1.39.1; extra == "dev"
|
|
45
|
+
Requires-Dist: setuptools-scm[simple]>=9.2; extra == "dev"
|
|
43
46
|
Provides-Extra: docs
|
|
44
47
|
Requires-Dist: sphinx>=6.0.0; extra == "docs"
|
|
45
48
|
Requires-Dist: sphinx-rtd-theme>=1.2.0; extra == "docs"
|
|
@@ -47,6 +50,9 @@ Requires-Dist: myst-parser>=1.0.0; extra == "docs"
|
|
|
47
50
|
Provides-Extra: examples
|
|
48
51
|
Requires-Dist: requests>=2.28.0; extra == "examples"
|
|
49
52
|
Requires-Dist: aiohttp>=3.8.0; extra == "examples"
|
|
53
|
+
Provides-Extra: openai
|
|
54
|
+
Requires-Dist: openai>=0.27.10; extra == "openai"
|
|
55
|
+
Requires-Dist: openai-agents>=0.12.5; extra == "openai"
|
|
50
56
|
Dynamic: license-file
|
|
51
57
|
|
|
52
58
|
# Python framework for Cadence
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
from concurrent.futures import ThreadPoolExecutor
|
|
2
2
|
from logging import getLogger
|
|
3
3
|
from traceback import format_exception
|
|
4
|
-
from typing import Any, Callable
|
|
4
|
+
from typing import Any, Callable, Union, cast
|
|
5
5
|
from google.protobuf.duration import to_timedelta
|
|
6
6
|
from google.protobuf.timestamp import to_datetime
|
|
7
7
|
|
|
8
8
|
from cadence._internal.activity._context import _Context, _SyncContext
|
|
9
|
-
from cadence.activity import
|
|
9
|
+
from cadence._internal.activity._definition import BaseDefinition, ExecutionStrategy
|
|
10
|
+
from cadence._internal.activity._heartbeat import _HeartbeatSender
|
|
11
|
+
from cadence.activity import ActivityInfo, ActivityDefinition
|
|
10
12
|
from cadence.api.v1.common_pb2 import Failure
|
|
11
13
|
from cadence.api.v1.service_worker_pb2 import (
|
|
12
14
|
PollForActivityTaskResponse,
|
|
@@ -42,21 +44,37 @@ class ActivityExecutor:
|
|
|
42
44
|
result = await context.execute(task.input)
|
|
43
45
|
await self._report_success(task, result)
|
|
44
46
|
except Exception as e:
|
|
47
|
+
_logger.exception("Activity failed")
|
|
45
48
|
await self._report_failure(task, e)
|
|
46
49
|
|
|
47
|
-
def _create_context(
|
|
50
|
+
def _create_context(
|
|
51
|
+
self, task: PollForActivityTaskResponse
|
|
52
|
+
) -> Union[_Context, _SyncContext]:
|
|
48
53
|
activity_type = task.activity_type.name
|
|
49
54
|
try:
|
|
50
|
-
activity_def = self._registry(activity_type)
|
|
55
|
+
activity_def = cast(BaseDefinition, self._registry(activity_type))
|
|
51
56
|
except KeyError:
|
|
52
57
|
raise KeyError(f"Activity type not found: {activity_type}") from None
|
|
53
58
|
|
|
54
59
|
info = self._create_info(task)
|
|
60
|
+
heartbeat_sender = _HeartbeatSender(
|
|
61
|
+
self._client.worker_stub,
|
|
62
|
+
self._data_converter,
|
|
63
|
+
task.task_token,
|
|
64
|
+
self._identity,
|
|
65
|
+
task.heartbeat_details,
|
|
66
|
+
)
|
|
55
67
|
|
|
56
68
|
if activity_def.strategy == ExecutionStrategy.ASYNC:
|
|
57
|
-
return _Context(self._client, info, activity_def)
|
|
69
|
+
return _Context(self._client, info, activity_def, heartbeat_sender)
|
|
58
70
|
else:
|
|
59
|
-
return _SyncContext(
|
|
71
|
+
return _SyncContext(
|
|
72
|
+
self._client,
|
|
73
|
+
info,
|
|
74
|
+
activity_def,
|
|
75
|
+
self._thread_pool,
|
|
76
|
+
heartbeat_sender,
|
|
77
|
+
)
|
|
60
78
|
|
|
61
79
|
async def _report_failure(
|
|
62
80
|
self, task: PollForActivityTaskResponse, error: Exception
|