Skip to content

Commit 9e306a5

Browse files
committed
Use nex-gen support file option
1 parent 46e1d56 commit 9e306a5

2 files changed

Lines changed: 12 additions & 38 deletions

File tree

scripts/gen_nexus_system_api.py

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def nex_gen_command() -> list[str]:
4949
return [bin_path]
5050

5151
if shutil.which("nex-gen") is None:
52-
subprocess.check_call(["cargo", "install", "--locked", "nex-gen"])
52+
subprocess.check_call(["cargo", "install", "--locked", "nex-gen", "--force"])
5353
return ["nex-gen"]
5454

5555

@@ -113,30 +113,6 @@ def generate_workflow_exports() -> None:
113113
workflow_init_path.write_text(content[:start] + "".join(all_block) + content[end:])
114114

115115

116-
def prepare_wit_workspace(temp_dir: Path) -> tuple[Path, Path]:
117-
workspace_input_dir = temp_dir / "nexus"
118-
shutil.copytree(wit_input_dir, workspace_input_dir)
119-
120-
model_path = workspace_input_dir / "deps" / "nexus-temporal-types" / "model.wit"
121-
model_content = model_path.read_text()
122-
if "@nexus.support" not in model_content:
123-
support_path = (
124-
workspace_input_dir
125-
/ "deps"
126-
/ "nexus-temporal-types"
127-
/ "python"
128-
/ python_support_path.name
129-
)
130-
support_path.parent.mkdir(parents=True, exist_ok=True)
131-
shutil.copy2(python_support_path, support_path)
132-
model_path.write_text(
133-
'/// @nexus.support python="python/temporal_model_converters.py"\n'
134-
+ model_content
135-
)
136-
137-
return workspace_input_dir / "workflow-service.wit", workspace_input_dir / "deps"
138-
139-
140116
def generate_nexus_system_api() -> None:
141117
if not wit_path.exists():
142118
raise RuntimeError(f"missing WIT source: {wit_path}")
@@ -146,9 +122,7 @@ def generate_nexus_system_api() -> None:
146122
raise RuntimeError(f"missing Python support source: {python_support_path}")
147123

148124
with tempfile.TemporaryDirectory(dir=base_dir) as temp_dir:
149-
temp_path = Path(temp_dir)
150-
descriptor_path = temp_path / "temporal_api.bin"
151-
workspace_wit_path, workspace_wit_deps_dir = prepare_wit_workspace(temp_path)
125+
descriptor_path = Path(temp_dir) / "temporal_api.bin"
152126
build_descriptor_set(descriptor_path)
153127
command = nex_gen_command()
154128

@@ -161,9 +135,11 @@ def generate_nexus_system_api() -> None:
161135
"--lang",
162136
"python",
163137
"--input",
164-
str(workspace_wit_path),
138+
str(wit_path),
165139
"--input",
166-
str(workspace_wit_deps_dir),
140+
str(wit_deps_dir),
141+
"--support-file",
142+
str(python_support_path),
167143
"--descriptors",
168144
str(descriptor_path),
169145
"--output",

temporalio/workflow/__init__.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
"""Utilities that can decorate or be called inside workflows."""
22

3-
# ruff: noqa: I001
4-
53
from __future__ import annotations
64

5+
# BEGIN GENERATED NEXUS SYSTEM EXPORTS
6+
from temporalio.nexus.system.workflow_service import (
7+
signal_with_start_workflow,
8+
)
9+
10+
# END GENERATED NEXUS SYSTEM EXPORTS
711
from ..types import (
812
AnyType,
913
CallableAsyncNoParam,
@@ -169,12 +173,6 @@
169173
start_child_workflow,
170174
)
171175

172-
# BEGIN GENERATED NEXUS SYSTEM EXPORTS
173-
from temporalio.nexus.system.workflow_service import (
174-
signal_with_start_workflow,
175-
)
176-
# END GENERATED NEXUS SYSTEM EXPORTS
177-
178176
__all__ = [
179177
"ActivityCancellationType",
180178
"ActivityConfig",

0 commit comments

Comments
 (0)