Skip to content

Workflow/Activity Priorities #802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/_proto/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
FROM python:3.10

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

COPY ./ ./

RUN mkdir -p ./temporalio/api
RUN uv sync --all-extras
RUN uv add "protobuf<4"
RUN uv sync --all-extras
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can delete line 11 right?

Copy link
Member Author

@Sushisource Sushisource Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably Yes

RUN poe gen-protos

CMD cp -r ./temporalio/api/* /api_new && cp -r ./temporalio/bridge/proto/* /bridge_new
4 changes: 3 additions & 1 deletion scripts/_proto/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
.idea/
.mypy_cache/
.pytest_cache/
.ruff_cache/
.venv/
build/
dist/
temporalio/api/
temporalio/bridge/**/target/
temporalio/bridge/**/*.so
Dockerfile
Dockerfile
.python-version
1 change: 1 addition & 0 deletions temporalio/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class Info:
workflow_namespace: str
workflow_run_id: str
workflow_type: str
priority: temporalio.common.Priority
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is priority always non-null in proto for activity task and workflow start event?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it's not, but we decided that just means default. Not personally a huge fan of that, but, the information conveyed is the same temporalio/sdk-java#2453 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me. When it comes to us passing it in, does server care whether we send a null priority or a non-null one with default values? The reason I ask about that direction is because if we want always output to be non-Optional, we might as well never accept Optional input and just default to a fixed immutable Priority.default. So there's no such thing as Optional[Priority] anywhere (kinda touched on in another comment).

# TODO(cretz): Consider putting identity on here for "worker_id" for logger?

def _logger_details(self) -> Mapping[str, Any]:
Expand Down
4 changes: 4 additions & 0 deletions temporalio/api/batch/v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
BatchOperationReset,
BatchOperationSignal,
BatchOperationTermination,
BatchOperationUnpauseActivities,
BatchOperationUpdateWorkflowExecutionOptions,
)

__all__ = [
Expand All @@ -14,4 +16,6 @@
"BatchOperationReset",
"BatchOperationSignal",
"BatchOperationTermination",
"BatchOperationUnpauseActivities",
"BatchOperationUpdateWorkflowExecutionOptions",
]
63 changes: 50 additions & 13 deletions temporalio/api/batch/v1/message_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

130 changes: 130 additions & 0 deletions temporalio/api/batch/v1/message_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ import builtins
import sys

import google.protobuf.descriptor
import google.protobuf.duration_pb2
import google.protobuf.field_mask_pb2
import google.protobuf.message
import google.protobuf.timestamp_pb2

import temporalio.api.common.v1.message_pb2
import temporalio.api.enums.v1.batch_operation_pb2
import temporalio.api.enums.v1.reset_pb2
import temporalio.api.workflow.v1.message_pb2

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

global___BatchOperationReset = BatchOperationReset

class BatchOperationUpdateWorkflowExecutionOptions(google.protobuf.message.Message):
"""BatchOperationUpdateWorkflowExecutionOptions sends UpdateWorkflowExecutionOptions requests to batch workflows.
Keep the parameters in sync with temporalio.api.workflowservice.v1.UpdateWorkflowExecutionOptionsRequest.
"""

DESCRIPTOR: google.protobuf.descriptor.Descriptor

IDENTITY_FIELD_NUMBER: builtins.int
WORKFLOW_EXECUTION_OPTIONS_FIELD_NUMBER: builtins.int
UPDATE_MASK_FIELD_NUMBER: builtins.int
identity: builtins.str
"""The identity of the worker/client."""
@property
def workflow_execution_options(
self,
) -> temporalio.api.workflow.v1.message_pb2.WorkflowExecutionOptions:
"""Workflow Execution options. Partial updates are accepted and controlled by update_mask."""
@property
def update_mask(self) -> google.protobuf.field_mask_pb2.FieldMask:
"""Controls which fields from `workflow_execution_options` will be applied.
To unset a field, set it to null and use the update mask to indicate that it should be mutated.
"""
def __init__(
self,
*,
identity: builtins.str = ...,
workflow_execution_options: temporalio.api.workflow.v1.message_pb2.WorkflowExecutionOptions
| None = ...,
update_mask: google.protobuf.field_mask_pb2.FieldMask | None = ...,
) -> None: ...
def HasField(
self,
field_name: typing_extensions.Literal[
"update_mask",
b"update_mask",
"workflow_execution_options",
b"workflow_execution_options",
],
) -> builtins.bool: ...
def ClearField(
self,
field_name: typing_extensions.Literal[
"identity",
b"identity",
"update_mask",
b"update_mask",
"workflow_execution_options",
b"workflow_execution_options",
],
) -> None: ...

global___BatchOperationUpdateWorkflowExecutionOptions = (
BatchOperationUpdateWorkflowExecutionOptions
)

class BatchOperationUnpauseActivities(google.protobuf.message.Message):
"""BatchOperationUnpauseActivities sends unpause requests to batch workflows."""

DESCRIPTOR: google.protobuf.descriptor.Descriptor

IDENTITY_FIELD_NUMBER: builtins.int
TYPE_FIELD_NUMBER: builtins.int
MATCH_ALL_FIELD_NUMBER: builtins.int
RESET_ATTEMPTS_FIELD_NUMBER: builtins.int
RESET_HEARTBEAT_FIELD_NUMBER: builtins.int
JITTER_FIELD_NUMBER: builtins.int
identity: builtins.str
"""The identity of the worker/client."""
type: builtins.str
match_all: builtins.bool
reset_attempts: builtins.bool
"""Providing this flag will also reset the number of attempts."""
reset_heartbeat: builtins.bool
"""Providing this flag will also reset the heartbeat details."""
@property
def jitter(self) -> google.protobuf.duration_pb2.Duration:
"""If set, the activity will start at a random time within the specified jitter
duration, introducing variability to the start time.
"""
def __init__(
self,
*,
identity: builtins.str = ...,
type: builtins.str = ...,
match_all: builtins.bool = ...,
reset_attempts: builtins.bool = ...,
reset_heartbeat: builtins.bool = ...,
jitter: google.protobuf.duration_pb2.Duration | None = ...,
) -> None: ...
def HasField(
self,
field_name: typing_extensions.Literal[
"activity",
b"activity",
"jitter",
b"jitter",
"match_all",
b"match_all",
"type",
b"type",
],
) -> builtins.bool: ...
def ClearField(
self,
field_name: typing_extensions.Literal[
"activity",
b"activity",
"identity",
b"identity",
"jitter",
b"jitter",
"match_all",
b"match_all",
"reset_attempts",
b"reset_attempts",
"reset_heartbeat",
b"reset_heartbeat",
"type",
b"type",
],
) -> None: ...
def WhichOneof(
self, oneof_group: typing_extensions.Literal["activity", b"activity"]
) -> typing_extensions.Literal["type", "match_all"] | None: ...

global___BatchOperationUnpauseActivities = BatchOperationUnpauseActivities
Loading
Loading