Skip to content
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ jobs:
- run: uv add --dev --python 3.10 "googleapis-common-protos==1.70.0"
- run: uv add --python 3.10 "protobuf<4"
- run: uv sync --all-extras
- run: cargo install --locked nexgen --version 0.2.2 --features advanced --force
- run: cargo install --locked nexgen --version 0.2.3 --features advanced --force
- run: poe build-develop
- run: poe gen-protos
- name: Check generation unchanged
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ to include examples, links to docs, or any other relevant information.

### Changed

- System Nexus Signal-with-Start Workflow operations now use the typed
`WorkflowOutboundInterceptor.start_signal_with_start_workflow` interception point instead of
the generic `WorkflowOutboundInterceptor.start_nexus_operation` method.

### Deprecated

### :boom: Breaking Changes
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,13 @@ exclude = [
# Ignore generated code
'temporalio/api',
'temporalio/bridge/proto',
'temporalio/nexus/system/workflow_service',
]

[[tool.mypy.overrides]]
module = "temporalio.nexus.system.workflow_service.*"
ignore_errors = true

[tool.pydocstyle]
convention = "google"
# https://github.com/PyCQA/pydocstyle/issues/363#issuecomment-625563088
Expand Down
3 changes: 2 additions & 1 deletion scripts/gen_nexus_system_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
/ "v1"
/ "request_response.proto"
)
NEX_GEN_VERSION = "0.2.2"
NEX_GEN_VERSION = "0.2.3"


def nex_gen_command() -> list[str]:
Expand Down Expand Up @@ -131,6 +131,7 @@ def generate_nexus_system_api() -> None:
str(wit_path),
str(wit_deps_dir),
"--native-api",
"--system-nexus",
"--support-file",
str(python_support_path),
"--descriptors",
Expand Down
30 changes: 18 additions & 12 deletions temporalio/bridge/Cargo.lock

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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ class ScheduleLocalActivity(google.protobuf.message.Message):
RETRY_POLICY_FIELD_NUMBER: builtins.int
LOCAL_RETRY_THRESHOLD_FIELD_NUMBER: builtins.int
CANCELLATION_TYPE_FIELD_NUMBER: builtins.int
INCLUDE_ARGUMENTS_INTO_MARKER_FIELD_NUMBER: builtins.int
seq: builtins.int
"""Lang's incremental sequence number, used as the operation identifier"""
activity_id: builtins.str
Expand Down Expand Up @@ -684,6 +685,11 @@ class ScheduleLocalActivity(google.protobuf.message.Message):
confirmed. Lang should default this to `WAIT_CANCELLATION_COMPLETED`, even though proto
will default to `TRY_CANCEL` automatically.
"""
include_arguments_into_marker: builtins.bool
"""If set, the local activity arguments will be included in the resulting marker under the
`input` key. This is disabled by default to avoid increasing history size unless the lang
SDK explicitly chooses to expose it.
"""
def __init__(
self,
*,
Expand All @@ -706,6 +712,7 @@ class ScheduleLocalActivity(google.protobuf.message.Message):
retry_policy: temporalio.api.common.v1.message_pb2.RetryPolicy | None = ...,
local_retry_threshold: google.protobuf.duration_pb2.Duration | None = ...,
cancellation_type: global___ActivityCancellationType.ValueType = ...,
include_arguments_into_marker: builtins.bool = ...,
) -> None: ...
def HasField(
self,
Expand Down Expand Up @@ -739,6 +746,8 @@ class ScheduleLocalActivity(google.protobuf.message.Message):
b"cancellation_type",
"headers",
b"headers",
"include_arguments_into_marker",
b"include_arguments_into_marker",
"local_retry_threshold",
b"local_retry_threshold",
"original_schedule_time",
Expand Down
2 changes: 1 addition & 1 deletion temporalio/bridge/sdk-core
Submodule sdk-core updated 93 files
+3 −2 .cargo/config.toml
+14 −0 .github/workflows/changelog.yml
+53 −1 .github/workflows/per-pr.yml
+40 −0 CHANGELOG.md
+15 −0 README.md
+1 −1 crates/client/Cargo.toml
+7 −8 crates/client/src/async_activity_handle.rs
+59 −63 crates/client/src/envconfig.rs
+245 −2 crates/client/src/errors.rs
+22 −6 crates/client/src/grpc.rs
+130 −2 crates/client/src/interceptors.rs
+857 −122 crates/client/src/lib.rs
+142 −8 crates/client/src/options_structs.rs
+2 −0 crates/client/src/schedules.rs
+45 −24 crates/client/src/worker.rs
+146 −100 crates/client/src/workflow_handle.rs
+25 −56 crates/common-wasm/src/data_converters.rs
+16 −11 crates/common-wasm/src/data_converters/failure_converter.rs
+3 −11 crates/common-wasm/src/error.rs
+10 −5 crates/common-wasm/src/lib.rs
+7 −16 crates/common-wasm/src/memo.rs
+3 −1 crates/common-wasm/src/priority.rs
+2 −8 crates/common-wasm/src/search_attributes.rs
+3 −1 crates/common-wasm/src/worker.rs
+15 −4 crates/common/src/envconfig.rs
+44 −1 crates/common/src/telemetry/prometheus_meter.rs
+1 −0 crates/common/src/telemetry/prometheus_server.rs
+6 −4 crates/common/src/worker.rs
+3 −3 crates/macros/src/workflow_definitions.rs
+1 −1 crates/protos/Cargo.toml
+4 −4 crates/protos/protos/api_upstream/Makefile
+5 −14 crates/protos/protos/api_upstream/buf.lock
+14 −15 crates/protos/protos/api_upstream/buf.yaml
+24 −13 crates/protos/protos/api_upstream/nexus/deps/nexus-temporal-types/model.wit
+2 −2 crates/protos/protos/api_upstream/nexus/workflow-service.wit
+4 −0 crates/protos/protos/local/temporal/sdk/core/workflow_commands/workflow_commands.proto
+6 −1 crates/protos/src/protos/task_token.rs
+6 −0 crates/protos/src/protos/utilities.rs
+1 −1 crates/sdk-core-c-bridge/Cargo.toml
+36 −23 crates/sdk-core-c-bridge/src/envconfig.rs
+4 −4 crates/sdk-core-c-bridge/src/worker.rs
+32 −0 crates/sdk-core/CHANGELOG.md
+5 −0 crates/sdk-core/src/abstractions.rs
+152 −5 crates/sdk-core/src/core_tests/activity_tasks.rs
+4 −4 crates/sdk-core/src/core_tests/queries.rs
+2 −2 crates/sdk-core/src/core_tests/updates.rs
+4 −4 crates/sdk-core/src/core_tests/workers.rs
+17 −17 crates/sdk-core/src/core_tests/workflow_tasks.rs
+6 −7 crates/sdk-core/src/histfetch.rs
+3 −1 crates/sdk-core/src/protosext/mod.rs
+5 −3 crates/sdk-core/src/replay/mod.rs
+2 −0 crates/sdk-core/src/telemetry/metrics.rs
+2 −2 crates/sdk-core/src/test_help/integ_helpers.rs
+45 −22 crates/sdk-core/src/worker/activities.rs
+1 −1 crates/sdk-core/src/worker/activities/activity_heartbeat_manager.rs
+11 −11 crates/sdk-core/src/worker/activities/local_activities.rs
+893 −22 crates/sdk-core/src/worker/client.rs
+1 −0 crates/sdk-core/src/worker/client/mocks.rs
+12 −16 crates/sdk-core/src/worker/heartbeat.rs
+38 −16 crates/sdk-core/src/worker/mod.rs
+3 −3 crates/sdk-core/src/worker/nexus.rs
+22 −12 crates/sdk-core/src/worker/workflow/machines/local_activity_state_machine.rs
+4 −4 crates/sdk-core/src/worker/workflow/machines/workflow_machines.rs
+51 −4 crates/sdk-core/src/worker/workflow/mod.rs
+87 −7 crates/sdk-core/src/worker/workflow/wft_poller.rs
+200 −0 crates/sdk-core/tests/cloud_namespace/mod.rs
+82 −32 crates/sdk-core/tests/common/mod.rs
+25 −25 crates/sdk-core/tests/heavy_tests.rs
+1 −1 crates/sdk-core/tests/integ_tests/data_converter_tests.rs
+21 −16 crates/sdk-core/tests/integ_tests/metrics_tests.rs
+18 −20 crates/sdk-core/tests/integ_tests/polling_tests.rs
+78 −84 crates/sdk-core/tests/integ_tests/queries_tests.rs
+204 −41 crates/sdk-core/tests/integ_tests/update_tests.rs
+12 −14 crates/sdk-core/tests/integ_tests/worker_heartbeat_tests.rs
+53 −0 crates/sdk-core/tests/integ_tests/worker_tests.rs
+32 −28 crates/sdk-core/tests/integ_tests/worker_versioning_tests.rs
+55 −51 crates/sdk-core/tests/integ_tests/workflow_tests.rs
+87 −19 crates/sdk-core/tests/integ_tests/workflow_tests/local_activities.rs
+9 −10 crates/sdk-core/tests/integ_tests/workflow_tests/modify_wf_properties.rs
+1 −4 crates/sdk-core/tests/integ_tests/workflow_tests/nexus.rs
+30 −35 crates/sdk-core/tests/manual_tests.rs
+48 −3 crates/sdk-core/tests/runner.rs
+29 −25 crates/sdk-core/tests/shared_tests/priority.rs
+8 −14 crates/sdk/src/activities.rs
+1 −21 crates/sdk/src/interceptors.rs
+9 −24 crates/sdk/src/lib.rs
+2 −4 crates/sdk/src/testing.rs
+2 −4 crates/sdk/src/workflow_registry.rs
+1 −4 crates/workflow/src/runtime/entry.rs
+6 −12 crates/workflow/src/runtime/instance.rs
+28 −44 crates/workflow/src/workflow_context.rs
+45 −15 crates/workflow/src/workflow_context/options.rs
+1 −4 crates/workflow/src/workflow_interceptors.rs
5 changes: 5 additions & 0 deletions temporalio/bridge/src/envconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ fn data_source_to_dict(py: Python, ds: &DataSource) -> PyResult<Py<PyAny>> {
match ds {
DataSource::Path(p) => dict.set_item("path", p)?,
DataSource::Data(d) => dict.set_item("data", PyBytes::new(py, d))?,
_ => {
return Err(PyRuntimeError::new_err(
"unsupported configuration data source",
))
}
};
Ok(dict.into())
}
Expand Down
8 changes: 4 additions & 4 deletions temporalio/bridge/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -900,10 +900,10 @@ fn convert_versioning_strategy(
WorkerVersioningStrategy::DeploymentBased(options) => {
temporalio_sdk_core::WorkerVersioningStrategy::WorkerDeploymentBased(
temporalio_common::worker::WorkerDeploymentOptions::new(
temporalio_common::worker::WorkerDeploymentVersion {
deployment_name: options.version.deployment_name,
build_id: options.version.build_id,
},
temporalio_common::worker::WorkerDeploymentVersion::builder()
.deployment_name(options.version.deployment_name)
.build_id(options.version.build_id)
.build(),
)
.use_worker_versioning(options.use_worker_versioning)
.maybe_default_versioning_behavior(if options.use_worker_versioning {
Expand Down
36 changes: 36 additions & 0 deletions temporalio/contrib/opentelemetry/_interceptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import temporalio.client
import temporalio.converter
import temporalio.exceptions
import temporalio.nexus.system.workflow_service.models
import temporalio.worker
import temporalio.workflow
from temporalio.exceptions import ApplicationError, ApplicationErrorCategory
Expand Down Expand Up @@ -433,6 +434,10 @@ class _InputWithStringHeaders(Protocol):
headers: Mapping[str, str] | None


class _InputWithModelHeaders(Protocol):
headers: Mapping[str, Any] | None


class _InputWithOperationContext(Generic[_ContextT], Protocol):
ctx: _ContextT

Expand Down Expand Up @@ -684,13 +689,26 @@ def _context_carrier_to_headers(
}
return headers

def _context_carrier_to_model_headers(
self,
carrier: _CarrierDict,
headers: Mapping[str, Any] | None,
) -> Mapping[str, Any]:
if carrier:
return {
**(headers or {}),
self.header_key: carrier,
}
return headers or {}

def _completed_span(
self,
span_name: str,
*,
link_context_carrier: _CarrierDict | None = None,
add_to_outbound: _InputWithHeaders | None = None,
add_to_outbound_str: _InputWithStringHeaders | None = None,
add_to_outbound_model: _InputWithModelHeaders | None = None,
new_span_even_on_replay: bool = False,
additional_attributes: opentelemetry.util.types.Attributes = None,
exception: Exception | None = None,
Expand Down Expand Up @@ -742,6 +760,11 @@ def _completed_span(
updated_context_carrier, add_to_outbound_str.headers
)

if add_to_outbound_model:
add_to_outbound_model.headers = self._context_carrier_to_model_headers(
updated_context_carrier, add_to_outbound_model.headers
)

def _set_on_context(
self, context: opentelemetry.context.Context
) -> opentelemetry.context.Context:
Expand Down Expand Up @@ -830,6 +853,19 @@ async def start_nexus_operation(

return await super().start_nexus_operation(input)

async def start_signal_with_start_workflow(
self,
request: temporalio.nexus.system.workflow_service.models.SignalWithStartWorkflowRequest,
) -> temporalio.workflow.NexusOperationHandle[
temporalio.nexus.system.workflow_service.models.SignalWithStartWorkflowResponse
]:
self.root._completed_span(
"SignalWithStartWorkflow",
kind=opentelemetry.trace.SpanKind.CLIENT,
add_to_outbound_model=request,
)
return await super().start_signal_with_start_workflow(request)


def _carrier_to_nexus_headers(
carrier: _CarrierDict, initial: Mapping[str, str] | None = None
Expand Down
13 changes: 13 additions & 0 deletions temporalio/contrib/opentelemetry/_otel_interceptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import temporalio.api.common.v1
import temporalio.client
import temporalio.converter
import temporalio.nexus.system.workflow_service.models
import temporalio.worker
import temporalio.workflow
from temporalio.contrib.opentelemetry._tracer_provider import (
Expand Down Expand Up @@ -600,3 +601,15 @@ async def start_nexus_operation(
):
input.headers = _context_to_nexus_headers(input.headers or {})
return await super().start_nexus_operation(input)

async def start_signal_with_start_workflow(
self,
request: temporalio.nexus.system.workflow_service.models.SignalWithStartWorkflowRequest,
) -> temporalio.workflow.NexusOperationHandle[
temporalio.nexus.system.workflow_service.models.SignalWithStartWorkflowResponse
]:
with self._workflow_maybe_span(
"SignalWithStartWorkflow", kind=opentelemetry.trace.SpanKind.CLIENT
):
request.headers = _context_to_headers(request.headers or {})
return await super().start_signal_with_start_workflow(request)
2 changes: 1 addition & 1 deletion temporalio/nexus/system/workflow_service/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by nexgen v0.2.2. DO NOT EDIT!
# Generated by nexgen v0.2.3. DO NOT EDIT!

from __future__ import annotations

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by nexgen v0.2.2. DO NOT EDIT!
# Generated by nexgen v0.2.3. DO NOT EDIT!

from __future__ import annotations

Expand Down
Loading
Loading