cadence-python-client 0.2.2__tar.gz → 0.2.3__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.
Files changed (191) hide show
  1. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/.github/workflows/ci_checks.yml +7 -2
  2. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/Makefile +14 -8
  3. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/PKG-INFO +49 -48
  4. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/README.md +47 -47
  5. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/rpc/error.py +24 -24
  6. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/rpc/retry.py +17 -13
  7. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/rpc/yarpc.py +7 -8
  8. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/workflow_engine.py +26 -2
  9. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/workflow_instance.py +33 -0
  10. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/client.py +311 -3
  11. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/contrib/openai/cadence_tool.py +6 -0
  12. cadence_python_client-0.2.3/cadence/query.py +103 -0
  13. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/worker/_decision_task_handler.py +93 -15
  14. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/workflow.py +91 -8
  15. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence_python_client.egg-info/PKG-INFO +49 -48
  16. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence_python_client.egg-info/SOURCES.txt +5 -0
  17. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence_python_client.egg-info/requires.txt +1 -0
  18. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/pyproject.toml +3 -0
  19. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/rpc/test_error.py +7 -5
  20. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/rpc/test_retry.py +7 -5
  21. cadence_python_client-0.2.3/tests/cadence/_internal/workflow/test_query_handling.py +545 -0
  22. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/workflow/test_retry_policy.py +15 -16
  23. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/workflow/test_waiter.py +4 -2
  24. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/test_client.py +26 -0
  25. cadence_python_client-0.2.3/tests/cadence/test_schedule.py +321 -0
  26. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/worker/test_decision_task_handler.py +8 -3
  27. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/worker/test_decision_task_handler_integration.py +5 -5
  28. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/worker/test_task_handler_integration.py +17 -10
  29. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/integration_tests/docker-compose.yml +1 -0
  30. cadence_python_client-0.2.3/tests/integration_tests/test_schedule.py +165 -0
  31. cadence_python_client-0.2.3/tests/integration_tests/workflow/test_query.py +435 -0
  32. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/integration_tests/workflow/test_retry_policy.py +2 -2
  33. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/uv.lock +14 -0
  34. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/.cursorrules +0 -0
  35. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/.github/dco.yml +0 -0
  36. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/.github/pull_request_template.md +0 -0
  37. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/.github/workflows/python-publish.yml +0 -0
  38. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/.github/workflows/semantic-pr.yml +0 -0
  39. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/.gitignore +0 -0
  40. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/.gitmodules +0 -0
  41. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/CONTRIBUTING.md +0 -0
  42. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/LICENSE +0 -0
  43. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/NOTICE +0 -0
  44. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/__init__.py +0 -0
  45. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/__init__.py +0 -0
  46. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/activity/__init__.py +0 -0
  47. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/activity/_activity_executor.py +0 -0
  48. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/activity/_context.py +0 -0
  49. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/activity/_definition.py +0 -0
  50. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/activity/_heartbeat.py +0 -0
  51. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/fn_signature.py +0 -0
  52. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/rpc/__init__.py +0 -0
  53. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/__init__.py +0 -0
  54. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/active_cluster_selection_policy.py +0 -0
  55. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/context.py +0 -0
  56. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/decision_events_iterator.py +0 -0
  57. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/deterministic_event_loop.py +0 -0
  58. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/history_event_iterator.py +0 -0
  59. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/retry_policy.py +0 -0
  60. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/statemachine/__init__.py +0 -0
  61. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/statemachine/activity_state_machine.py +0 -0
  62. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/statemachine/cancellation.py +0 -0
  63. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/statemachine/completion_state_machine.py +0 -0
  64. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/statemachine/decision_manager.py +0 -0
  65. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/statemachine/decision_state_machine.py +0 -0
  66. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/statemachine/event_dispatcher.py +0 -0
  67. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/statemachine/nondeterminism.py +0 -0
  68. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/statemachine/timer_state_machine.py +0 -0
  69. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/_internal/workflow/waiter.py +0 -0
  70. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/activity.py +0 -0
  71. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/__init__.py +0 -0
  72. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/common_pb2.py +0 -0
  73. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/common_pb2.pyi +0 -0
  74. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/common_pb2_grpc.py +0 -0
  75. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/decision_pb2.py +0 -0
  76. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/decision_pb2.pyi +0 -0
  77. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/decision_pb2_grpc.py +0 -0
  78. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/domain_pb2.py +0 -0
  79. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/domain_pb2.pyi +0 -0
  80. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/domain_pb2_grpc.py +0 -0
  81. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/error_pb2.py +0 -0
  82. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/error_pb2.pyi +0 -0
  83. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/error_pb2_grpc.py +0 -0
  84. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/history_pb2.py +0 -0
  85. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/history_pb2.pyi +0 -0
  86. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/history_pb2_grpc.py +0 -0
  87. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/query_pb2.py +0 -0
  88. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/query_pb2.pyi +0 -0
  89. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/query_pb2_grpc.py +0 -0
  90. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/schedule_pb2.py +0 -0
  91. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/schedule_pb2.pyi +0 -0
  92. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/schedule_pb2_grpc.py +0 -0
  93. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_domain_pb2.py +0 -0
  94. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_domain_pb2.pyi +0 -0
  95. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_domain_pb2_grpc.py +0 -0
  96. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_meta_pb2.py +0 -0
  97. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_meta_pb2.pyi +0 -0
  98. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_meta_pb2_grpc.py +0 -0
  99. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_schedule_pb2.py +0 -0
  100. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_schedule_pb2.pyi +0 -0
  101. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_schedule_pb2_grpc.py +0 -0
  102. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_visibility_pb2.py +0 -0
  103. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_visibility_pb2.pyi +0 -0
  104. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_visibility_pb2_grpc.py +0 -0
  105. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_worker_pb2.py +0 -0
  106. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_worker_pb2.pyi +0 -0
  107. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_worker_pb2_grpc.py +0 -0
  108. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_workflow_pb2.py +0 -0
  109. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_workflow_pb2.pyi +0 -0
  110. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/service_workflow_pb2_grpc.py +0 -0
  111. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/tasklist_pb2.py +0 -0
  112. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/tasklist_pb2.pyi +0 -0
  113. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/tasklist_pb2_grpc.py +0 -0
  114. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/visibility_pb2.py +0 -0
  115. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/visibility_pb2.pyi +0 -0
  116. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/visibility_pb2_grpc.py +0 -0
  117. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/workflow_pb2.py +0 -0
  118. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/workflow_pb2.pyi +0 -0
  119. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/api/v1/workflow_pb2_grpc.py +0 -0
  120. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/contrib/__init__.py +0 -0
  121. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/contrib/openai/README.md +0 -0
  122. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/contrib/openai/__init__.py +0 -0
  123. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/contrib/openai/cadence_agent_runner.py +0 -0
  124. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/contrib/openai/cadence_handoff.py +0 -0
  125. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/contrib/openai/cadence_model.py +0 -0
  126. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/contrib/openai/cadence_registry.py +0 -0
  127. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/contrib/openai/images/cadence-web-agent-run.jpg +0 -0
  128. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/contrib/openai/openai_activities.py +0 -0
  129. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/contrib/openai/pydantic_data_converter.py +0 -0
  130. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/data_converter.py +0 -0
  131. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/error.py +0 -0
  132. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/metrics/__init__.py +0 -0
  133. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/metrics/constants.py +0 -0
  134. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/metrics/metrics.py +0 -0
  135. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/metrics/prometheus.py +0 -0
  136. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/sample/__init__.py +0 -0
  137. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/sample/client_example.py +0 -0
  138. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/sample/grpc_usage_example.py +0 -0
  139. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/sample/simple_usage_example.py +0 -0
  140. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/signal.py +0 -0
  141. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/worker/__init__.py +0 -0
  142. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/worker/_activity.py +0 -0
  143. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/worker/_base_task_handler.py +0 -0
  144. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/worker/_decision.py +0 -0
  145. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/worker/_poller.py +0 -0
  146. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/worker/_registry.py +0 -0
  147. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/worker/_types.py +0 -0
  148. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence/worker/_worker.py +0 -0
  149. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence_python_client.egg-info/dependency_links.txt +0 -0
  150. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/cadence_python_client.egg-info/top_level.txt +0 -0
  151. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/scripts/dev.py +0 -0
  152. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/scripts/fix_pyi_imports.py +0 -0
  153. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/scripts/generate_proto.py +0 -0
  154. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/setup.cfg +0 -0
  155. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/activity/test_activity_executor.py +0 -0
  156. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/activity/test_heartbeat.py +0 -0
  157. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/test_fn_signature.py +0 -0
  158. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/workflow/statemachine/test_activity_state_machine.py +0 -0
  159. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/workflow/statemachine/test_decision_manager.py +0 -0
  160. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/workflow/statemachine/test_nondeterminism.py +0 -0
  161. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/workflow/statemachine/test_timer_state_machine.py +0 -0
  162. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/workflow/test_context_retry_policy.py +0 -0
  163. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/workflow/test_decision_events_iterator.py +0 -0
  164. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/workflow/test_deterministic_event_loop.py +0 -0
  165. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/workflow/test_history_event_iterator.py +0 -0
  166. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/workflow/test_signal_handling.py +0 -0
  167. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/_internal/workflow/test_workflow_engine.py +0 -0
  168. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/common_activities.py +0 -0
  169. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/data_converter_test.py +0 -0
  170. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/metrics/test_metrics.py +0 -0
  171. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/metrics/test_prometheus.py +0 -0
  172. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/test_activity.py +0 -0
  173. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/test_client_workflow.py +0 -0
  174. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/worker/test_base_task_handler.py +0 -0
  175. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/worker/test_decision_worker_integration.py +0 -0
  176. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/worker/test_poller.py +0 -0
  177. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/worker/test_registry.py +0 -0
  178. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/cadence/worker/test_worker.py +0 -0
  179. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/conftest.py +0 -0
  180. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/integration_tests/conftest.py +0 -0
  181. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/integration_tests/helper.py +0 -0
  182. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/integration_tests/nondeterminism/success.json +0 -0
  183. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/integration_tests/nondeterminism/test_nondeterministic_workflows.py +0 -0
  184. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/integration_tests/test_client.py +0 -0
  185. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/integration_tests/workflow/test_activities.py +0 -0
  186. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/integration_tests/workflow/test_continue_as_new.py +0 -0
  187. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/integration_tests/workflow/test_heartbeat.py +0 -0
  188. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/integration_tests/workflow/test_serialization.py +0 -0
  189. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/integration_tests/workflow/test_signals.py +0 -0
  190. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/integration_tests/workflow/test_timer.py +0 -0
  191. {cadence_python_client-0.2.2 → cadence_python_client-0.2.3}/tests/integration_tests/workflow/test_workflows.py +0 -0
@@ -54,7 +54,7 @@ jobs:
54
54
  uv sync --extra dev --extra openai
55
55
  - name: Run mypy type checker
56
56
  run: |
57
- uv run mypy cadence/
57
+ uv run mypy cadence/ tests/
58
58
 
59
59
  test:
60
60
  name: Unit Tests
@@ -74,7 +74,12 @@ jobs:
74
74
  uv sync --extra dev
75
75
  - name: Run unit tests
76
76
  run: |
77
- uv run pytest -v
77
+ uv run pytest --integration-tests --cov --cov-branch --cov-report=xml
78
+ - name: Upload coverage reports to Codecov
79
+ uses: codecov/codecov-action@v5
80
+ with:
81
+ token: ${{ secrets.CODECOV_TOKEN }}
82
+ slug: cadence-workflow/cadence-python-client
78
83
 
79
84
  integration_test:
80
85
  name: Integration Tests
@@ -35,21 +35,27 @@ integration-test:
35
35
  @echo "Running integration tests..."
36
36
  uv run pytest -v --integration-tests
37
37
 
38
+ integration-test-keep:
39
+ @echo "Running integration tests with cadence alive..."
40
+ uv run pytest -v --integration-tests --keep-cadence-alive
41
+
38
42
  # Clean generated files and caches
39
43
  clean:
40
44
  @echo "Cleaning up..."
41
45
  find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
42
46
  find . -type f -name "*.pyc" -delete 2>/dev/null || true
43
47
  find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
48
+ rm -rf .mypy_cache
44
49
 
45
50
  # Show help
46
51
  help:
47
52
  @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"
53
+ @echo " make pr - Run all PR checks (recommended before submitting PR)"
54
+ @echo " make install - Install dependencies"
55
+ @echo " make lint - Run Ruff linter"
56
+ @echo " make type-check - Run mypy type checker"
57
+ @echo " make test - Run unit tests"
58
+ @echo " make integration-test - Run integration tests"
59
+ @echo " make integration-test-keep - Run integration tests with cadence alive"
60
+ @echo " make clean - Remove generated files and caches"
61
+ @echo " make help - Show this help message"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cadence-python-client
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Python framework for authoring Cadence workflows and activities
5
5
  Author: Cadence
6
6
  License: Apache-2.0
@@ -31,6 +31,7 @@ Requires-Dist: typing-extensions>=4.0.0
31
31
  Requires-Dist: prometheus-client>=0.21.0
32
32
  Provides-Extra: dev
33
33
  Requires-Dist: grpcio-tools>=1.73.1; extra == "dev"
34
+ Requires-Dist: grpc-stubs>=1.53.0.6; extra == "dev"
34
35
  Requires-Dist: pytest>=8.4.1; extra == "dev"
35
36
  Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
36
37
  Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
@@ -68,11 +69,26 @@ If you'd like to propose a new feature, first join the [CNCF Slack workspace](ht
68
69
  **This SDK is currently an early work-in-progress (WIP) and is NOT ready for production use.**
69
70
 
70
71
  - This project is still in active development
71
- - It has not been published to any package repository (PyPI, etc.)
72
72
  - APIs and interfaces are subject to change without notice
73
73
 
74
74
  ## Installation
75
75
 
76
+ Install from [PyPI](https://pypi.org/project/cadence-python-client/):
77
+
78
+ ```bash
79
+ pip install cadence-python-client
80
+ ```
81
+
82
+ Or with `uv`:
83
+
84
+ ```bash
85
+ uv add cadence-python-client
86
+ ```
87
+
88
+ The core package supports Python `>=3.11,<3.14`.
89
+
90
+ Clone the repository if you want to develop locally:
91
+
76
92
  ```bash
77
93
  git clone https://github.com/cadence-workflow/cadence-python-client.git
78
94
  cd cadence-python-client
@@ -103,8 +119,7 @@ cd cadence-python-client
103
119
 
104
120
  3. **Create virtual environment and install dependencies:**
105
121
  ```bash
106
- uv venv
107
- uv pip install -e ".[dev]"
122
+ uv sync --all-extras
108
123
  ```
109
124
 
110
125
  Or if you prefer traditional pip:
@@ -116,70 +131,56 @@ cd cadence-python-client
116
131
 
117
132
  ### Generate Protobuf and gRPC Files
118
133
 
119
- Run the generation script:
134
+ Run the generation script only if you change files under `idls/proto/`:
135
+
120
136
  ```bash
121
- # Using uv (recommended)
122
- uv sync --extra dev
123
- uv run python scripts/generate_proto.py
137
+ # Recommended
138
+ make generate
124
139
 
125
- # Or using traditional Python
126
- python scripts/generate_proto.py
140
+ # Or run the script directly
141
+ uv run python scripts/generate_proto.py
127
142
  ```
128
143
 
129
144
  This will:
130
- - Download protoc 29.1 binary
131
- - Install grpcio-tools if needed
132
145
  - Generate Python protobuf files in `cadence/api/v1/`
133
146
  - Generate gRPC service files in `cadence/api/v1/`
134
- - Create proper package structure with both protobuf and gRPC imports
147
+ - Refresh the package imports for the generated modules
135
148
 
136
149
  ### Test
137
150
 
138
- Verify the generated files work:
139
- ```bash
140
- # Using uv (recommended)
141
- uv run python cadence/sample/simple_usage_example.py
142
- uv run python cadence/sample/grpc_usage_example.py
151
+ Run the main checks:
143
152
 
144
- # Or using traditional Python
145
- python cadence/sample/simple_usage_example.py
146
- python test_grpc_with_examples.py
153
+ ```bash
154
+ make lint
155
+ make type-check
156
+ make test
147
157
  ```
148
158
 
149
- ### Development Script
150
-
151
- The project includes a development script that provides convenient commands for common tasks:
159
+ Run integration tests with Docker:
152
160
 
153
161
  ```bash
154
- # Generate protobuf files
155
- uv run python scripts/dev.py protobuf
156
-
157
- # Run tests
158
- uv run python scripts/dev.py test
159
-
160
- # Run tests with coverage
161
- uv run python scripts/dev.py test-cov
162
-
163
- # Run linting
164
- uv run python scripts/dev.py lint
165
-
166
- # Format code
167
- uv run python scripts/dev.py format
162
+ make integration-test
163
+ ```
168
164
 
169
- # Install in development mode
170
- uv run python scripts/dev.py install
165
+ You can also verify the generated files manually:
171
166
 
172
- # Install with dev dependencies
173
- uv run python scripts/dev.py install-dev
167
+ ```bash
168
+ uv run python cadence/sample/simple_usage_example.py
169
+ uv run python cadence/sample/grpc_usage_example.py
170
+ ```
174
171
 
175
- # Build package
176
- uv run python scripts/dev.py build
172
+ ### Development Commands
177
173
 
178
- # Clean build artifacts
179
- uv run python scripts/dev.py clean
174
+ The current repository workflow is centered on `make` targets:
180
175
 
181
- # Run all checks (lint + test)
182
- uv run python scripts/dev.py check
176
+ ```bash
177
+ make install
178
+ make generate
179
+ make lint
180
+ make type-check
181
+ make test
182
+ make integration-test
183
+ make pr
183
184
  ```
184
185
 
185
186
  ## License
@@ -10,11 +10,26 @@ If you'd like to propose a new feature, first join the [CNCF Slack workspace](ht
10
10
  **This SDK is currently an early work-in-progress (WIP) and is NOT ready for production use.**
11
11
 
12
12
  - This project is still in active development
13
- - It has not been published to any package repository (PyPI, etc.)
14
13
  - APIs and interfaces are subject to change without notice
15
14
 
16
15
  ## Installation
17
16
 
17
+ Install from [PyPI](https://pypi.org/project/cadence-python-client/):
18
+
19
+ ```bash
20
+ pip install cadence-python-client
21
+ ```
22
+
23
+ Or with `uv`:
24
+
25
+ ```bash
26
+ uv add cadence-python-client
27
+ ```
28
+
29
+ The core package supports Python `>=3.11,<3.14`.
30
+
31
+ Clone the repository if you want to develop locally:
32
+
18
33
  ```bash
19
34
  git clone https://github.com/cadence-workflow/cadence-python-client.git
20
35
  cd cadence-python-client
@@ -45,8 +60,7 @@ cd cadence-python-client
45
60
 
46
61
  3. **Create virtual environment and install dependencies:**
47
62
  ```bash
48
- uv venv
49
- uv pip install -e ".[dev]"
63
+ uv sync --all-extras
50
64
  ```
51
65
 
52
66
  Or if you prefer traditional pip:
@@ -58,70 +72,56 @@ cd cadence-python-client
58
72
 
59
73
  ### Generate Protobuf and gRPC Files
60
74
 
61
- Run the generation script:
75
+ Run the generation script only if you change files under `idls/proto/`:
76
+
62
77
  ```bash
63
- # Using uv (recommended)
64
- uv sync --extra dev
65
- uv run python scripts/generate_proto.py
78
+ # Recommended
79
+ make generate
66
80
 
67
- # Or using traditional Python
68
- python scripts/generate_proto.py
81
+ # Or run the script directly
82
+ uv run python scripts/generate_proto.py
69
83
  ```
70
84
 
71
85
  This will:
72
- - Download protoc 29.1 binary
73
- - Install grpcio-tools if needed
74
86
  - Generate Python protobuf files in `cadence/api/v1/`
75
87
  - Generate gRPC service files in `cadence/api/v1/`
76
- - Create proper package structure with both protobuf and gRPC imports
88
+ - Refresh the package imports for the generated modules
77
89
 
78
90
  ### Test
79
91
 
80
- Verify the generated files work:
81
- ```bash
82
- # Using uv (recommended)
83
- uv run python cadence/sample/simple_usage_example.py
84
- uv run python cadence/sample/grpc_usage_example.py
92
+ Run the main checks:
85
93
 
86
- # Or using traditional Python
87
- python cadence/sample/simple_usage_example.py
88
- python test_grpc_with_examples.py
94
+ ```bash
95
+ make lint
96
+ make type-check
97
+ make test
89
98
  ```
90
99
 
91
- ### Development Script
92
-
93
- The project includes a development script that provides convenient commands for common tasks:
100
+ Run integration tests with Docker:
94
101
 
95
102
  ```bash
96
- # Generate protobuf files
97
- uv run python scripts/dev.py protobuf
98
-
99
- # Run tests
100
- uv run python scripts/dev.py test
101
-
102
- # Run tests with coverage
103
- uv run python scripts/dev.py test-cov
104
-
105
- # Run linting
106
- uv run python scripts/dev.py lint
107
-
108
- # Format code
109
- uv run python scripts/dev.py format
103
+ make integration-test
104
+ ```
110
105
 
111
- # Install in development mode
112
- uv run python scripts/dev.py install
106
+ You can also verify the generated files manually:
113
107
 
114
- # Install with dev dependencies
115
- uv run python scripts/dev.py install-dev
108
+ ```bash
109
+ uv run python cadence/sample/simple_usage_example.py
110
+ uv run python cadence/sample/grpc_usage_example.py
111
+ ```
116
112
 
117
- # Build package
118
- uv run python scripts/dev.py build
113
+ ### Development Commands
119
114
 
120
- # Clean build artifacts
121
- uv run python scripts/dev.py clean
115
+ The current repository workflow is centered on `make` targets:
122
116
 
123
- # Run all checks (lint + test)
124
- uv run python scripts/dev.py check
117
+ ```bash
118
+ make install
119
+ make generate
120
+ make lint
121
+ make type-check
122
+ make test
123
+ make integration-test
124
+ make pr
125
125
  ```
126
126
 
127
127
  ## License
@@ -1,7 +1,7 @@
1
- from typing import Callable, Any, Optional, Generator, TypeVar
1
+ from typing import Callable, Any, Optional, Generator, TypeVar, cast
2
2
 
3
3
  import grpc
4
- from google.rpc.status_pb2 import Status # type: ignore
4
+ from google.rpc.status_pb2 import Status
5
5
  from grpc.aio import (
6
6
  UnaryUnaryClientInterceptor,
7
7
  ClientCallDetails,
@@ -9,7 +9,7 @@ from grpc.aio import (
9
9
  UnaryUnaryCall,
10
10
  Metadata,
11
11
  )
12
- from grpc_status.rpc_status import from_call # type: ignore
12
+ from grpc_status.rpc_status import from_call
13
13
 
14
14
  from cadence.api.v1 import error_pb2
15
15
  from cadence import error
@@ -46,22 +46,22 @@ class CadenceErrorUnaryUnaryCall(UnaryUnaryCall[RequestType, ResponseType]):
46
46
  return await self._wrapped.code()
47
47
 
48
48
  async def details(self) -> str:
49
- return await self._wrapped.details() # type: ignore
49
+ return await self._wrapped.details()
50
50
 
51
51
  async def wait_for_connection(self) -> None:
52
52
  await self._wrapped.wait_for_connection()
53
53
 
54
54
  def cancelled(self) -> bool:
55
- return self._wrapped.cancelled() # type: ignore
55
+ return self._wrapped.cancelled()
56
56
 
57
57
  def done(self) -> bool:
58
- return self._wrapped.done() # type: ignore
58
+ return self._wrapped.done()
59
59
 
60
60
  def time_remaining(self) -> Optional[float]:
61
- return self._wrapped.time_remaining() # type: ignore
61
+ return self._wrapped.time_remaining()
62
62
 
63
63
  def cancel(self) -> bool:
64
- return self._wrapped.cancel() # type: ignore
64
+ return self._wrapped.cancel()
65
65
 
66
66
  def add_done_callback(self, callback: DoneCallbackType) -> None:
67
67
  self._wrapped.add_done_callback(callback)
@@ -79,16 +79,18 @@ class CadenceErrorInterceptor(UnaryUnaryClientInterceptor):
79
79
 
80
80
 
81
81
  def map_error(e: AioRpcError) -> error.CadenceRpcError:
82
- status: Status | None = from_call(e)
82
+ # AioRpcError implements the grpc.Call interface but doesn't inherit from it in the type stubs
83
+ status: Status | None = from_call(cast(grpc.Call, e))
84
+ message = e.details() or ""
83
85
  if not status or not status.details:
84
- return error.CadenceRpcError(e.details(), e.code())
86
+ return error.CadenceRpcError(message, e.code())
85
87
 
86
88
  details = status.details[0]
87
89
  if details.Is(error_pb2.WorkflowExecutionAlreadyStartedError.DESCRIPTOR):
88
90
  already_started = error_pb2.WorkflowExecutionAlreadyStartedError()
89
91
  details.Unpack(already_started)
90
92
  return error.WorkflowExecutionAlreadyStartedError(
91
- e.details(),
93
+ message,
92
94
  e.code(),
93
95
  already_started.start_request_id,
94
96
  already_started.run_id,
@@ -97,19 +99,19 @@ def map_error(e: AioRpcError) -> error.CadenceRpcError:
97
99
  not_exists = error_pb2.EntityNotExistsError()
98
100
  details.Unpack(not_exists)
99
101
  return error.EntityNotExistsError(
100
- e.details(),
102
+ message,
101
103
  e.code(),
102
104
  not_exists.current_cluster,
103
105
  not_exists.active_cluster,
104
106
  list(not_exists.active_clusters),
105
107
  )
106
108
  elif details.Is(error_pb2.WorkflowExecutionAlreadyCompletedError.DESCRIPTOR):
107
- return error.WorkflowExecutionAlreadyCompletedError(e.details(), e.code())
109
+ return error.WorkflowExecutionAlreadyCompletedError(message, e.code())
108
110
  elif details.Is(error_pb2.DomainNotActiveError.DESCRIPTOR):
109
111
  not_active = error_pb2.DomainNotActiveError()
110
112
  details.Unpack(not_active)
111
113
  return error.DomainNotActiveError(
112
- e.details(),
114
+ message,
113
115
  e.code(),
114
116
  not_active.domain,
115
117
  not_active.current_cluster,
@@ -120,7 +122,7 @@ def map_error(e: AioRpcError) -> error.CadenceRpcError:
120
122
  not_supported = error_pb2.ClientVersionNotSupportedError()
121
123
  details.Unpack(not_supported)
122
124
  return error.ClientVersionNotSupportedError(
123
- e.details(),
125
+ message,
124
126
  e.code(),
125
127
  not_supported.feature_version,
126
128
  not_supported.client_impl,
@@ -129,20 +131,18 @@ def map_error(e: AioRpcError) -> error.CadenceRpcError:
129
131
  elif details.Is(error_pb2.FeatureNotEnabledError.DESCRIPTOR):
130
132
  not_enabled = error_pb2.FeatureNotEnabledError()
131
133
  details.Unpack(not_enabled)
132
- return error.FeatureNotEnabledError(
133
- e.details(), e.code(), not_enabled.feature_flag
134
- )
134
+ return error.FeatureNotEnabledError(message, e.code(), not_enabled.feature_flag)
135
135
  elif details.Is(error_pb2.CancellationAlreadyRequestedError.DESCRIPTOR):
136
- return error.CancellationAlreadyRequestedError(e.details(), e.code())
136
+ return error.CancellationAlreadyRequestedError(message, e.code())
137
137
  elif details.Is(error_pb2.DomainAlreadyExistsError.DESCRIPTOR):
138
- return error.DomainAlreadyExistsError(e.details(), e.code())
138
+ return error.DomainAlreadyExistsError(message, e.code())
139
139
  elif details.Is(error_pb2.LimitExceededError.DESCRIPTOR):
140
- return error.LimitExceededError(e.details(), e.code())
140
+ return error.LimitExceededError(message, e.code())
141
141
  elif details.Is(error_pb2.QueryFailedError.DESCRIPTOR):
142
- return error.QueryFailedError(e.details(), e.code())
142
+ return error.QueryFailedError(message, e.code())
143
143
  elif details.Is(error_pb2.ServiceBusyError.DESCRIPTOR):
144
144
  service_busy = error_pb2.ServiceBusyError()
145
145
  details.Unpack(service_busy)
146
- return error.ServiceBusyError(e.details(), e.code(), service_busy.reason)
146
+ return error.ServiceBusyError(message, e.code(), service_busy.reason)
147
147
  else:
148
- return error.CadenceRpcError(e.details(), e.code())
148
+ return error.CadenceRpcError(message, e.code())
@@ -1,6 +1,6 @@
1
1
  import asyncio
2
2
  from dataclasses import dataclass
3
- from typing import Callable, Any
3
+ from typing import Callable, Any, cast
4
4
 
5
5
  from grpc import StatusCode
6
6
  from grpc.aio import UnaryUnaryClientInterceptor, ClientCallDetails
@@ -59,19 +59,23 @@ class RetryInterceptor(UnaryUnaryClientInterceptor):
59
59
  request: Any,
60
60
  ) -> Any:
61
61
  loop = asyncio.get_running_loop()
62
- expiration_interval = client_call_details.timeout
63
- if expiration_interval is None:
64
- expiration_interval = float("inf")
62
+ expiration_interval = (
63
+ client_call_details.timeout
64
+ if client_call_details.timeout is not None
65
+ else float("inf")
66
+ )
65
67
  start_time = loop.time()
66
68
  deadline = start_time + expiration_interval
67
69
 
68
70
  attempts = 0
69
71
  while True:
70
72
  remaining = deadline - loop.time()
71
- # Namedtuple methods start with an underscore to avoid conflicts and aren't actually private
72
- # noinspection PyProtectedMember
73
- call_details = client_call_details._replace( # type: ignore[attr-defined]
74
- timeout=remaining
73
+ call_details = ClientCallDetails(
74
+ method=client_call_details.method,
75
+ timeout=remaining,
76
+ metadata=client_call_details.metadata,
77
+ credentials=client_call_details.credentials,
78
+ wait_for_ready=client_call_details.wait_for_ready,
75
79
  )
76
80
  rpc_call = await continuation(call_details, request)
77
81
  try:
@@ -98,11 +102,11 @@ class RetryInterceptor(UnaryUnaryClientInterceptor):
98
102
 
99
103
 
100
104
  def is_retryable(err: CadenceRpcError, call_details: ClientCallDetails) -> bool:
101
- # Handle requests to the passive side, matching the Go and Java Clients
102
- if (
103
- call_details.method == GET_WORKFLOW_HISTORY # type: ignore[comparison-overlap]
104
- and isinstance(err, EntityNotExistsError)
105
- ):
105
+ # Handle requests to the passive side, matching the Go and Java Clients.
106
+ # grpc-stubs types method as str, but grpcio corrected it to bytes in v1.75.0
107
+ # (grpc/grpc#39405). Cast to bytes to match the actual runtime type.
108
+ method = cast(bytes, call_details.method)
109
+ if method == GET_WORKFLOW_HISTORY and isinstance(err, EntityNotExistsError):
106
110
  return (
107
111
  err.active_cluster is not None
108
112
  and err.current_cluster is not None
@@ -1,4 +1,4 @@
1
- from typing import Any, Callable, cast
1
+ from typing import Any, Callable
2
2
 
3
3
  from grpc.aio import Metadata
4
4
  from grpc.aio import UnaryUnaryClientInterceptor, ClientCallDetails
@@ -38,11 +38,10 @@ class YarpcMetadataInterceptor(UnaryUnaryClientInterceptor):
38
38
  else:
39
39
  metadata += self._metadata
40
40
 
41
- # Namedtuple methods start with an underscore to avoid conflicts and aren't actually private
42
- # noinspection PyProtectedMember
43
- return cast(
44
- ClientCallDetails,
45
- client_call_details._replace( # type: ignore[attr-defined]
46
- metadata=metadata, timeout=client_call_details.timeout or 60.0
47
- ),
41
+ return ClientCallDetails(
42
+ method=client_call_details.method,
43
+ timeout=client_call_details.timeout or 60.0,
44
+ metadata=metadata,
45
+ credentials=client_call_details.credentials,
46
+ wait_for_ready=client_call_details.wait_for_ready,
48
47
  )
@@ -25,6 +25,11 @@ from cadence.api.v1.history_pb2 import (
25
25
  WorkflowExecutionSignaledEventAttributes,
26
26
  WorkflowExecutionStartedEventAttributes,
27
27
  )
28
+ from cadence.api.v1.query_pb2 import (
29
+ WorkflowQuery,
30
+ WorkflowQueryResult,
31
+ QUERY_RESULT_TYPE_ANSWERED,
32
+ )
28
33
  from cadence.api.v1.tasklist_pb2 import TaskList
29
34
  from cadence.error import ContinueAsNewError
30
35
  from cadence.workflow import WorkflowDefinition, WorkflowInfo
@@ -35,6 +40,7 @@ logger = logging.getLogger(__name__)
35
40
  @dataclass
36
41
  class DecisionResult:
37
42
  decisions: list[Decision]
43
+ query_result: Optional[WorkflowQueryResult] = None
38
44
 
39
45
 
40
46
  class WorkflowEngine:
@@ -51,6 +57,7 @@ class WorkflowEngine:
51
57
  def process_decision(
52
58
  self,
53
59
  events: List[HistoryEvent],
60
+ query: Optional[WorkflowQuery] = None,
54
61
  ) -> DecisionResult:
55
62
  """
56
63
  Process a decision task and generate decisions using DecisionEventsIterator.
@@ -59,7 +66,7 @@ class WorkflowEngine:
59
66
  to drive the decision processing pipeline with proper replay handling.
60
67
 
61
68
  Args:
62
- decision_task: The PollForDecisionTaskResponse from the service
69
+ events: The workflow history events.
63
70
 
64
71
  Returns:
65
72
  DecisionResult containing the list of decisions
@@ -74,6 +81,7 @@ class WorkflowEngine:
74
81
  "workflow_type": ctx.info().workflow_type,
75
82
  "workflow_id": ctx.info().workflow_id,
76
83
  "run_id": ctx.info().workflow_run_id,
84
+ "query": query.query_type if query else None,
77
85
  },
78
86
  )
79
87
 
@@ -83,11 +91,15 @@ class WorkflowEngine:
83
91
  # Process decision events using iterator-driven approach
84
92
  self._process_decision_events(ctx, events_iterator)
85
93
 
94
+ if query:
95
+ return self._execute_query(query)
96
+
86
97
  # Collect all pending decisions from state machines
87
98
  decisions = self._decision_manager.collect_pending_decisions()
88
99
 
89
- return DecisionResult(decisions=decisions)
100
+ return DecisionResult(decisions=decisions, query_result=None)
90
101
 
102
+ # TODO: reevaluate if this is needed to log error here or in the caller
91
103
  except Exception as e:
92
104
  # Log decision task failure with full context (matches Java ReplayDecisionTaskHandler)
93
105
  logger.error(
@@ -103,6 +115,18 @@ class WorkflowEngine:
103
115
  # Re-raise the exception so the handler can properly handle the failure
104
116
  raise
105
117
 
118
+ def _execute_query(self, query: WorkflowQuery) -> DecisionResult:
119
+ result_payload = self._workflow_instance.handle_query(
120
+ query.query_type, query.query_args
121
+ )
122
+ return DecisionResult(
123
+ decisions=[],
124
+ query_result=WorkflowQueryResult(
125
+ result_type=QUERY_RESULT_TYPE_ANSWERED,
126
+ answer=result_payload,
127
+ ),
128
+ )
129
+
106
130
  def is_done(self) -> bool:
107
131
  return self._workflow_instance.is_done()
108
132
 
@@ -96,6 +96,39 @@ class WorkflowInstance:
96
96
  if inspect.iscoroutine(result):
97
97
  await result
98
98
 
99
+ def handle_query(self, query_type: str, query_args: Payload) -> Payload:
100
+ """Execute a query handler and return the serialized result.
101
+
102
+ The query runs synchronously against the current workflow state
103
+ (after replay has caught up). It must not mutate state.
104
+
105
+ Args:
106
+ query_type: The registered query type name.
107
+ query_args: Serialized query arguments.
108
+
109
+ Returns:
110
+ Serialized query result as a Payload.
111
+
112
+ Raises:
113
+ ValueError: If the query type is not registered.
114
+ Exception: If the query handler raises.
115
+ """
116
+ query_def = self._definition.queries.get(query_type)
117
+ if query_def is None:
118
+ raise ValueError(
119
+ f"Unknown query type '{query_type}'. "
120
+ f"Known types: {list(self._definition.queries.keys())}"
121
+ )
122
+
123
+ args = query_def.params_from_payload(self._data_converter, query_args)
124
+ result = query_def(self._instance, *args)
125
+ if inspect.iscoroutine(result):
126
+ result.close()
127
+ raise TypeError(
128
+ f"Query handler '{query_type}' must be synchronous, got async function"
129
+ )
130
+ return self._data_converter.to_data([result])
131
+
99
132
  def _on_signal_task_done(self, task: Task[Any], signal_name: str) -> None:
100
133
  self._signal_tasks.discard(task)
101
134
  if task.cancelled():