Skip to content

Commit ea40f0c

Browse files
committed
Default sandbox sample activities to unversioned
1 parent a2480f5 commit ea40f0c

5 files changed

Lines changed: 18 additions & 7 deletions

File tree

durabletask-azuremanaged/durabletask/azuremanaged/preview/sandboxes/worker_profiles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class Activity:
6161
def add_activity(
6262
self,
6363
activity: str | Callable[..., Any],
64-
version: Optional[str]) -> None:
64+
version: Optional[str] = None) -> None:
6565
"""Add an activity to the sandbox worker profile worker_profile."""
6666
activity_name = task.get_name(activity) if callable(activity) else activity
6767
self.activities.append(SandboxActivity(

examples/sandboxes/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ the pushed image reference. `RemoteWorkerProfile.configure()` declares CPU,
4545
memory, max concurrency, customer environment variables, and sandbox activity
4646
identities with `options.image.image_ref`,
4747
`options.image.managed_identity_client_id`, and
48-
`options.add_activity(name, version)`. This sample uses an unversioned activity
49-
identity (`version=None`) because Python orchestrations currently schedule
50-
activities by name. The declarer and remote worker both use `activities.py` so
51-
they stay in sync.
48+
`options.add_activity(name)`. This sample uses an unversioned activity identity
49+
because Python orchestrations currently schedule activities by name. The sandbox
50+
metadata API can carry an optional activity version for future activity-version
51+
support, but this sample intentionally omits it. The declarer and remote worker
52+
both use `activities.py` so they stay in sync.
5253

5354
The remote worker code cannot pass Durable Task Scheduler runtime settings to the SDK. In a
5455
sandbox, `SandboxWorker()` reads `DTS_ENDPOINT`,

examples/sandboxes/main_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def configure(self, options) -> None:
8686
options.memory = "2048Mi"
8787
options.max_concurrent_activities = 1
8888
options.environment_variables["SANDBOX_SAMPLE_MARKER"] = "sandboxes-python-sample-marker"
89-
options.add_activity(REMOTE_HELLO.name, version=REMOTE_HELLO.version)
89+
options.add_activity(REMOTE_HELLO.name)
9090

9191

9292
print(f"Using taskhub: {taskhub_name}")

examples/sandboxes/remote_worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def _remote_hello(ctx: task.ActivityContext, name: str) -> str:
2020

2121

2222
with SandboxWorker() as worker:
23-
worker.add_activity(_remote_hello, version=REMOTE_HELLO.version)
23+
worker.add_activity(_remote_hello)
2424
worker.start()
2525
print("Python sandbox remote worker is running. Press Ctrl+C to stop.")
2626
try:

tests/durabletask-azuremanaged/test_sandboxes_extension.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,16 @@ def test_profile_options_add_activities_accepts_activity_range() -> None:
144144
]
145145

146146

147+
def test_profile_options_add_activity_defaults_to_unversioned() -> None:
148+
options = SandboxWorkerProfileOptions(worker_profile_id="pytest-unversioned-profile")
149+
150+
options.add_activity("RemoteHello")
151+
152+
assert resolve_activities(options.activities) == [
153+
SandboxActivity("RemoteHello", None),
154+
]
155+
156+
147157
def test_sandbox_worker_profile_requires_activity() -> None:
148158
try:
149159
try:

0 commit comments

Comments
 (0)