Skip to content

Commit 2748057

Browse files
committed
Merge remote-tracking branch 'remotes/origin/main' into in-workflow-util
# Conflicts: # tests/worker/test_workflow.py
2 parents e977604 + 7ffa822 commit 2748057

File tree

89 files changed

+9217
-1819
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+9217
-1819
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,8 @@ jobs:
109109
110110
# Runs the sdk features repo tests with this repo's current SDK code
111111
features-tests:
112-
uses: temporalio/features/.github/workflows/python.yaml@uv
112+
uses: temporalio/features/.github/workflows/python.yaml@main
113113
with:
114114
python-repo-path: ${{github.event.pull_request.head.repo.full_name}}
115115
version: ${{github.event.pull_request.head.ref}}
116116
version-is-repo-ref: true
117-
features-repo-ref: uv

README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ informal introduction to the features and their implementation.
9797
- [Worker Shutdown](#worker-shutdown)
9898
- [Testing](#testing-1)
9999
- [Workflow Replay](#workflow-replay)
100-
- [OpenTelemetry Support](#opentelemetry-support)
100+
- [Observability](#observability)
101+
- [Metrics](#metrics)
102+
- [OpenTelemetry Tracing](#opentelemetry-tracing)
101103
- [Protobuf 3.x vs 4.x](#protobuf-3x-vs-4x)
102104
- [Known Compatibility Issues](#known-compatibility-issues)
103105
- [gevent Patching](#gevent-patching)
@@ -1344,10 +1346,30 @@ async def check_past_histories(my_client: Client):
13441346
)
13451347
```
13461348

1347-
### OpenTelemetry Support
1349+
### Observability
13481350

1349-
OpenTelemetry support requires the optional `opentelemetry` dependencies which are part of the `opentelemetry` extra.
1350-
When using `pip`, running
1351+
See https://github.com/temporalio/samples-python/tree/main/open_telemetry for a sample demonstrating collection of
1352+
metrics and tracing data emitted by the SDK.
1353+
1354+
#### Metrics
1355+
1356+
The SDK emits various metrics by default: see https://docs.temporal.io/references/sdk-metrics. To configure additional
1357+
attributes to be emitted with all metrics, pass
1358+
[global_tags](https://python.temporal.io/temporalio.runtime.TelemetryConfig.html#global_tags) when creating the
1359+
[TelemetryConfig](https://python.temporal.io/temporalio.runtime.TelemetryConfig.html).
1360+
1361+
For emitting custom metrics, the SDK makes a metric meter available:
1362+
- In Workflow code, use https://python.temporal.io/temporalio.workflow.html#metric_meter
1363+
- In Activity code, use https://python.temporal.io/temporalio.activity.html#metric_meter
1364+
- In normal application code, use https://python.temporal.io/temporalio.runtime.Runtime.html#metric_meter
1365+
1366+
The attributes emitted by these default to `namespace`, `task_queue`, and `workflow_type`/`activity_type`; use
1367+
`with_additional_attributes` to create a meter emitting additional attributes.
1368+
1369+
#### OpenTelemetry Tracing
1370+
1371+
Tracing support requires the optional `opentelemetry` dependencies which are part of the `opentelemetry` extra. When
1372+
using `pip`, running
13511373

13521374
pip install 'temporalio[opentelemetry]'
13531375

scripts/_proto/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
FROM python:3.10
22

33
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
4+
ENV PATH="$PATH:/root/.local/bin"
45
RUN uv tool install poethepoet
56
VOLUME ["/api_new", "/bridge_new"]
67

78
COPY ./ ./
89

910
RUN mkdir -p ./temporalio/api
10-
RUN uv sync --all-extras
1111
RUN uv add "protobuf<4"
12+
RUN uv sync --all-extras
1213
RUN poe gen-protos
1314

1415
CMD cp -r ./temporalio/api/* /api_new && cp -r ./temporalio/bridge/proto/* /bridge_new

scripts/_proto/Dockerfile.dockerignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
.idea/
33
.mypy_cache/
44
.pytest_cache/
5+
.ruff_cache/
56
.venv/
67
build/
78
dist/
89
temporalio/api/
910
temporalio/bridge/**/target/
1011
temporalio/bridge/**/*.so
11-
Dockerfile
12+
Dockerfile
13+
.python-version

temporalio/activity.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ class Info:
116116
workflow_namespace: str
117117
workflow_run_id: str
118118
workflow_type: str
119+
priority: temporalio.common.Priority
119120
# TODO(cretz): Consider putting identity on here for "worker_id" for logger?
120121

121122
def _logger_details(self) -> Mapping[str, Any]:

temporalio/api/batch/v1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
BatchOperationReset,
66
BatchOperationSignal,
77
BatchOperationTermination,
8+
BatchOperationUnpauseActivities,
9+
BatchOperationUpdateWorkflowExecutionOptions,
810
)
911

1012
__all__ = [
@@ -14,4 +16,6 @@
1416
"BatchOperationReset",
1517
"BatchOperationSignal",
1618
"BatchOperationTermination",
19+
"BatchOperationUnpauseActivities",
20+
"BatchOperationUpdateWorkflowExecutionOptions",
1721
]

temporalio/api/batch/v1/message_pb2.py

Lines changed: 50 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

temporalio/api/batch/v1/message_pb2.pyi

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ import builtins
2828
import sys
2929

3030
import google.protobuf.descriptor
31+
import google.protobuf.duration_pb2
32+
import google.protobuf.field_mask_pb2
3133
import google.protobuf.message
3234
import google.protobuf.timestamp_pb2
3335

3436
import temporalio.api.common.v1.message_pb2
3537
import temporalio.api.enums.v1.batch_operation_pb2
3638
import temporalio.api.enums.v1.reset_pb2
39+
import temporalio.api.workflow.v1.message_pb2
3740

3841
if sys.version_info >= (3, 8):
3942
import typing as typing_extensions
@@ -262,3 +265,130 @@ class BatchOperationReset(google.protobuf.message.Message):
262265
) -> None: ...
263266

264267
global___BatchOperationReset = BatchOperationReset
268+
269+
class BatchOperationUpdateWorkflowExecutionOptions(google.protobuf.message.Message):
270+
"""BatchOperationUpdateWorkflowExecutionOptions sends UpdateWorkflowExecutionOptions requests to batch workflows.
271+
Keep the parameters in sync with temporalio.api.workflowservice.v1.UpdateWorkflowExecutionOptionsRequest.
272+
"""
273+
274+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
275+
276+
IDENTITY_FIELD_NUMBER: builtins.int
277+
WORKFLOW_EXECUTION_OPTIONS_FIELD_NUMBER: builtins.int
278+
UPDATE_MASK_FIELD_NUMBER: builtins.int
279+
identity: builtins.str
280+
"""The identity of the worker/client."""
281+
@property
282+
def workflow_execution_options(
283+
self,
284+
) -> temporalio.api.workflow.v1.message_pb2.WorkflowExecutionOptions:
285+
"""Workflow Execution options. Partial updates are accepted and controlled by update_mask."""
286+
@property
287+
def update_mask(self) -> google.protobuf.field_mask_pb2.FieldMask:
288+
"""Controls which fields from `workflow_execution_options` will be applied.
289+
To unset a field, set it to null and use the update mask to indicate that it should be mutated.
290+
"""
291+
def __init__(
292+
self,
293+
*,
294+
identity: builtins.str = ...,
295+
workflow_execution_options: temporalio.api.workflow.v1.message_pb2.WorkflowExecutionOptions
296+
| None = ...,
297+
update_mask: google.protobuf.field_mask_pb2.FieldMask | None = ...,
298+
) -> None: ...
299+
def HasField(
300+
self,
301+
field_name: typing_extensions.Literal[
302+
"update_mask",
303+
b"update_mask",
304+
"workflow_execution_options",
305+
b"workflow_execution_options",
306+
],
307+
) -> builtins.bool: ...
308+
def ClearField(
309+
self,
310+
field_name: typing_extensions.Literal[
311+
"identity",
312+
b"identity",
313+
"update_mask",
314+
b"update_mask",
315+
"workflow_execution_options",
316+
b"workflow_execution_options",
317+
],
318+
) -> None: ...
319+
320+
global___BatchOperationUpdateWorkflowExecutionOptions = (
321+
BatchOperationUpdateWorkflowExecutionOptions
322+
)
323+
324+
class BatchOperationUnpauseActivities(google.protobuf.message.Message):
325+
"""BatchOperationUnpauseActivities sends unpause requests to batch workflows."""
326+
327+
DESCRIPTOR: google.protobuf.descriptor.Descriptor
328+
329+
IDENTITY_FIELD_NUMBER: builtins.int
330+
TYPE_FIELD_NUMBER: builtins.int
331+
MATCH_ALL_FIELD_NUMBER: builtins.int
332+
RESET_ATTEMPTS_FIELD_NUMBER: builtins.int
333+
RESET_HEARTBEAT_FIELD_NUMBER: builtins.int
334+
JITTER_FIELD_NUMBER: builtins.int
335+
identity: builtins.str
336+
"""The identity of the worker/client."""
337+
type: builtins.str
338+
match_all: builtins.bool
339+
reset_attempts: builtins.bool
340+
"""Providing this flag will also reset the number of attempts."""
341+
reset_heartbeat: builtins.bool
342+
"""Providing this flag will also reset the heartbeat details."""
343+
@property
344+
def jitter(self) -> google.protobuf.duration_pb2.Duration:
345+
"""If set, the activity will start at a random time within the specified jitter
346+
duration, introducing variability to the start time.
347+
"""
348+
def __init__(
349+
self,
350+
*,
351+
identity: builtins.str = ...,
352+
type: builtins.str = ...,
353+
match_all: builtins.bool = ...,
354+
reset_attempts: builtins.bool = ...,
355+
reset_heartbeat: builtins.bool = ...,
356+
jitter: google.protobuf.duration_pb2.Duration | None = ...,
357+
) -> None: ...
358+
def HasField(
359+
self,
360+
field_name: typing_extensions.Literal[
361+
"activity",
362+
b"activity",
363+
"jitter",
364+
b"jitter",
365+
"match_all",
366+
b"match_all",
367+
"type",
368+
b"type",
369+
],
370+
) -> builtins.bool: ...
371+
def ClearField(
372+
self,
373+
field_name: typing_extensions.Literal[
374+
"activity",
375+
b"activity",
376+
"identity",
377+
b"identity",
378+
"jitter",
379+
b"jitter",
380+
"match_all",
381+
b"match_all",
382+
"reset_attempts",
383+
b"reset_attempts",
384+
"reset_heartbeat",
385+
b"reset_heartbeat",
386+
"type",
387+
b"type",
388+
],
389+
) -> None: ...
390+
def WhichOneof(
391+
self, oneof_group: typing_extensions.Literal["activity", b"activity"]
392+
) -> typing_extensions.Literal["type", "match_all"] | None: ...
393+
394+
global___BatchOperationUnpauseActivities = BatchOperationUnpauseActivities

0 commit comments

Comments
 (0)