Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9bccb27
Added the generated code of the Streams API.
moetemp Nov 14, 2026
c65cf7a
Regenerated the Streams API with append and close on the Workflow Str…
moetemp Nov 14, 2026
6635c70
Regenerated the Streams API with the new names of a polled read.
moetemp Nov 18, 2026
e0ba191
Regenerate the Streams API from the API's attempt names
moetemp Nov 20, 2026
17c637e
Regenerate the Streams API with a request id and Stream ids
moetemp Nov 21, 2026
983611e
Regenerate the Streams API with ids in each Producer kind
moetemp Nov 21, 2026
5b5bf8b
Regenerate the Streams API with the API's comments on a Store's rules
moetemp Nov 21, 2026
bd9690c
Leave the generated Stream code out of mypy
moetemp Nov 22, 2026
cfad2eb
Regenerate the bridge protos and the payload visitor
moetemp Nov 22, 2026
7f855d6
Regenerate the Streams API with no `producer` in Workflow code
moetemp Nov 23, 2026
2407868
Regenerate the API protos with refs in the Stream requests
moetemp Nov 24, 2026
bfaca8f
Regenerate the Streams API with refs in the requests
moetemp Nov 24, 2026
41b14e7
Regenerate the bridge protos from Core's Stream ledger
moetemp Nov 24, 2026
16be05f
Pin Core with the Stream protos and the Stream WIT
moetemp Nov 24, 2026
eb3b474
Regenerate the protos and the Streams API at the pinned Core
moetemp Nov 24, 2026
cf85123
Pin Core at the SDK and Store sets of the Stream protos
moetemp Nov 25, 2026
10dcd0e
Regenerate the protos and the Streams API with no close
moetemp Nov 25, 2026
523848f
Generate the Nexus system API with nexgen 0.2.14
moetemp Nov 26, 2026
3574894
Pin Core to the Streams protos with the read doc of api#895
moetemp Nov 26, 2026
2054714
Merge branch 'codex/review-1127-python-info' into codex/review-1127-p…
moetemp Nov 27, 2026
f89671d
Pin reviewed Stream contracts and the client poll generator
moetemp Nov 27, 2026
839a3e4
Clarify generated read limits and pin the final generator
moetemp Nov 27, 2026
5c8be99
Remove the temporary generator comment
moetemp Nov 27, 2026
4aaf5e6
Merge the reviewed Local Activity info
moetemp Nov 28, 2026
844bd0f
Regenerate Streams with reviewed creation and polling rules
moetemp Nov 28, 2026
207b339
Include the generated Stream binding helpers
moetemp Nov 28, 2026
e640fe1
Use `after_offset` in generated Stream requests
moetemp Nov 28, 2026
bf89eb0
Resume Stream reads after the last returned Record
moetemp Nov 30, 2026
8364e8e
Expose the Workflow Task ID on Stream Producers
moetemp Nov 30, 2026
91430ce
Use the original Local Activity IDs for Stream Producers
moetemp Nov 30, 2026
47492f8
Regenerate Stream polling without an explicit yield
moetemp Dec 1, 2026
4012aa0
Pin the generator without forced polling yields
moetemp Dec 1, 2026
8da7fe8
Report existing Streams without a Workflow logic flag
moetemp Dec 1, 2026
eb847f8
Pin the generator with typed client hooks for Stream calls
tconley1428 Dec 1, 2026
a5779b7
Include storage target support for SDK validation
tconley1428 Dec 1, 2026
2208e72
Generate the Stream API from API main
moetemp Dec 2, 2026
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
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,15 @@ exclude = [
# Ignore generated code
'temporalio/api',
'temporalio/bridge/proto',
'temporalio/nexus/system/stream_service',
'temporalio/nexus/system/workflow_service',
]

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

[tool.pydocstyle]
Expand Down
72 changes: 48 additions & 24 deletions scripts/gen_nexus_system_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
wit_deps_dir = wit_input_dir / "deps"
workflow_output_dir = base_dir / "temporalio" / "nexus" / "system" / "workflow_service"
notification_output_dir = base_dir / "temporalio" / "nexus" / "notifications"
stream_output_dir = base_dir / "temporalio" / "nexus" / "system" / "stream_service"
workflow_init_path = base_dir / "temporalio" / "workflow" / "__init__.py"
NEX_GEN_VERSION = "0.2.13"
NEX_GEN_REVISION = "4bf951e99c43a3e30838ea6af52ec30dedb31eac"
proto_files = [
gen_protos.api_proto_dir
/ "temporal"
Expand All @@ -39,31 +40,40 @@
/ "notificationservice"
/ "v1"
/ "request_response.proto",
gen_protos.api_proto_dir
/ "temporal"
/ "api"
/ "streamservice"
/ "v1"
/ "request_response.proto",
gen_protos.api_proto_dir / "temporal" / "api" / "sdk" / "v1" / "stream.proto",
]


def nex_gen_command() -> list[str]:
if bin_path := os.environ.get("NEX_GEN_BIN"):
return [bin_path]
if (
shutil.which("nexgen") is None
or subprocess.check_output(["nexgen", "--version"], text=True).strip()
!= f"nexgen {NEX_GEN_VERSION}"
):
install_dir = base_dir / "build" / "nexgen" / NEX_GEN_REVISION
binary = install_dir / "bin" / ("nexgen.exe" if os.name == "nt" else "nexgen")
if not binary.is_file():
subprocess.check_call(
[
"cargo",
"install",
"--locked",
"nexgen",
"--version",
NEX_GEN_VERSION,
"--git",
"https://github.com/temporalio/nexgen.git",
"--rev",
NEX_GEN_REVISION,
"--root",
str(install_dir),
"--features",
"advanced",
"--force",
]
)
return ["nexgen"]
return [str(binary)]


def build_descriptor_set(descriptor_path: Path) -> None:
Expand All @@ -85,11 +95,11 @@ def generate_package(
output_dir: Path,
descriptor_path: Path,
*,
native_api: bool,
targets: str | None,
) -> None:
args = [*command, "python", str(wit_input_dir / wit_name), str(wit_deps_dir)]
if native_api:
args.extend(["--targets", "workflow"])
if targets:
args.extend(["--targets", targets])
subprocess.check_call(
[
*args,
Expand Down Expand Up @@ -132,17 +142,28 @@ def replace_marker_block(


def generate_workflow_exports() -> None:
exports = generated_exports(workflow_output_dir / "__init__.py")
import_block = [
"# BEGIN GENERATED NEXUS SYSTEM EXPORTS\n",
"from temporalio.nexus.system.workflow_service import (\n",
*[f" {export},\n" for export in exports],
")\n",
"# END GENERATED NEXUS SYSTEM EXPORTS\n",
packages = [
(
"temporalio.nexus.system.stream_service.workflow",
stream_output_dir / "workflow" / "__init__.py",
),
(
"temporalio.nexus.system.workflow_service",
workflow_output_dir / "__init__.py",
),
]
exports = [(module, generated_exports(path)) for module, path in packages]
import_block = ["# BEGIN GENERATED NEXUS SYSTEM EXPORTS\n"]
for module, names in exports:
import_block += [
f"from {module} import (\n",
*[f" {name},\n" for name in names],
")\n",
]
import_block.append("# END GENERATED NEXUS SYSTEM EXPORTS\n")
all_block = [
" # BEGIN GENERATED NEXUS SYSTEM __ALL__\n",
*[f' "{export}",\n' for export in exports],
*[f' "{name}",\n' for _, names in exports for name in names],
" # END GENERATED NEXUS SYSTEM __ALL__\n",
]
content = workflow_init_path.read_text()
Expand All @@ -163,6 +184,7 @@ def generate_nexus_system_api() -> None:
required_paths = [
wit_input_dir / "workflow-service.wit",
wit_input_dir / "notification-service.wit",
wit_input_dir / "stream-service.wit",
wit_deps_dir,
*proto_files,
]
Expand All @@ -173,9 +195,10 @@ def generate_nexus_system_api() -> None:
descriptor_path = Path(temp_dir) / "temporal_api.bin"
build_descriptor_set(descriptor_path)
command = nex_gen_command()
for wit_name, output_dir, native_api in (
("workflow-service.wit", workflow_output_dir, True),
("notification-service.wit", notification_output_dir, False),
for wit_name, output_dir, targets in (
("workflow-service.wit", workflow_output_dir, "workflow"),
("notification-service.wit", notification_output_dir, None),
("stream-service.wit", stream_output_dir, "workflow,client"),
):
shutil.rmtree(output_dir, ignore_errors=True)
output_dir.parent.mkdir(parents=True, exist_ok=True)
Expand All @@ -184,13 +207,14 @@ def generate_nexus_system_api() -> None:
wit_name,
output_dir,
descriptor_path,
native_api=native_api,
targets=targets,
)
workflow_output_dir.parent.joinpath("__init__.py").touch()
generate_workflow_exports()
format_paths = [
str(workflow_output_dir),
str(notification_output_dir),
str(stream_output_dir),
str(workflow_init_path),
]
subprocess.check_call(
Expand Down
6 changes: 6 additions & 0 deletions temporalio/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ class Info:
This API is experimental and unstable.
"""

_scheduled_event_id: int = 0
"""Allow Stream writes when the task token has no scheduling event ID."""

_local_activity_origin: tuple[int, str] | None = None
"""Keep the original task and Activity IDs when a retry gets a new sequence number."""

@property
def in_workflow(self) -> bool:
"""Was this activity started by a workflow?"""
Expand Down
2 changes: 1 addition & 1 deletion temporalio/api/activity/v1/message_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class ActivityExecutionInfo(google.protobuf.message.Message):

@property
def last_started_time(self) -> google.protobuf.timestamp_pb2.Timestamp:
"""Time the last attempt was started."""
"""Time the current attempt started, or the final attempt if the activity has closed; unset while waiting for a retry."""

@property
def execution_duration(self) -> google.protobuf.duration_pb2.Duration:
Expand Down
6 changes: 6 additions & 0 deletions temporalio/api/batch/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from .message_pb2 import (
BatchOperationCancelActivities,
BatchOperationCancellation,
BatchOperationCancelNexusOperations,
BatchOperationDeleteActivities,
BatchOperationDeleteNexusOperations,
BatchOperationDeletion,
BatchOperationInfo,
BatchOperationReset,
BatchOperationResetActivities,
BatchOperationSignal,
BatchOperationTerminateActivities,
BatchOperationTerminateNexusOperations,
BatchOperationTermination,
BatchOperationTriggerWorkflowRule,
BatchOperationUnpauseActivities,
Expand All @@ -17,14 +20,17 @@

__all__ = [
"BatchOperationCancelActivities",
"BatchOperationCancelNexusOperations",
"BatchOperationCancellation",
"BatchOperationDeleteActivities",
"BatchOperationDeleteNexusOperations",
"BatchOperationDeletion",
"BatchOperationInfo",
"BatchOperationReset",
"BatchOperationResetActivities",
"BatchOperationSignal",
"BatchOperationTerminateActivities",
"BatchOperationTerminateNexusOperations",
"BatchOperationTermination",
"BatchOperationTriggerWorkflowRule",
"BatchOperationUnpauseActivities",
Expand Down
52 changes: 29 additions & 23 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.

Loading
Loading