Skip to content

Commit e8481de

Browse files
authored
Provide standalone activity run ID to external storage (#1417)
1 parent f0e8518 commit e8481de

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

temporalio/worker/_activity.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ async def _handle_start_activity_task(
349349
store_target = StorageDriverActivityInfo(
350350
id=start.activity_id or None,
351351
type=start.activity_type or None,
352+
run_id=start.run_id or None,
352353
namespace=ns,
353354
)
354355
data_converter = self._data_converter._with_contexts(

tests/contrib/aws/s3driver/test_s3driver_worker.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,17 @@ async def test_s3_driver_standalone_activity_input_key(
210210
start_to_close_timeout=timedelta(seconds=5),
211211
)
212212
keys = await _list_keys(aioboto3_client)
213-
# Input and output are the same LARGE bytes, so they deduplicate to one key.
214-
assert len(keys) == 1
215-
# Keyed under the activity, not a workflow.
216-
assert f"/ns/default/at/large_io_activity/ai/{activity_id}/ri/null/" in keys[0]
217-
assert "/wt/" not in keys[0]
213+
# Input and output are the same LARGE bytes but stored under different keys.
214+
assert len(keys) == 2
215+
# Both keyed under the activity, not a workflow.
216+
assert all(
217+
f"/ns/default/at/large_io_activity/ai/{activity_id}/ri/" in k for k in keys
218+
)
219+
assert all("/wt/" not in k for k in keys)
220+
# Client-side store does not have run ID information
221+
assert sum(1 for k in keys if "/ri/null/" in k) == 1
222+
# Worker-side store does have run ID information
223+
assert sum(1 for k in keys if "/ri/null/" not in k) == 1
218224

219225

220226
async def test_s3_driver_standalone_activity_output_key(
@@ -238,7 +244,8 @@ async def test_s3_driver_standalone_activity_output_key(
238244
keys = await _list_keys(aioboto3_client)
239245
# Only the output is large; keyed under the activity.
240246
assert len(keys) == 1
241-
assert f"/ns/default/at/large_output_activity/ai/{activity_id}/ri/null/" in keys[0]
247+
assert f"/ns/default/at/large_output_activity/ai/{activity_id}/ri/" in keys[0]
248+
assert "/ri/null/" not in keys[0]
242249
assert "/wt/" not in keys[0]
243250

244251

tests/worker/test_extstore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1350,7 +1350,7 @@ async def test_store_metadata_standalone_activity(env: WorkflowEnvironment) -> N
13501350
assert execute_ctx.target.namespace == client.namespace
13511351
assert execute_ctx.target.id == activity_id
13521352
assert execute_ctx.target.type == "echo_activity"
1353-
assert execute_ctx.target.run_id is None
1353+
assert execute_ctx.target.run_id is not None
13541354

13551355

13561356
@workflow.defn

0 commit comments

Comments
 (0)