Skip to content

Commit 700426b

Browse files
author
Andrei Neagu
committed
corrected key
1 parent 285839e commit 700426b

File tree

2 files changed

+17
-6
lines changed
  • services/dynamic-scheduler
    • src/simcore_service_dynamic_scheduler/services/generic_scheduler
    • tests/unit/service_generic_scheduler

2 files changed

+17
-6
lines changed

services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/services/generic_scheduler/_store.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,21 @@ def _get_step_hash_key(
3737
operation_name: OperationName,
3838
group: StepGroupName,
3939
step_name: StepName,
40+
is_creating: bool,
4041
) -> str:
41-
# SCHEDULE_NAMESPACE:SCHEDULE_ID:STEPS:OPERATION_NAME:GROUP_INDEX:STEP_NAME:KEY
42+
# SCHEDULE_NAMESPACE:SCHEDULE_ID:STEPS:OPERATION_NAME:GROUP_INDEX:STEP_NAME:IS_CREATING:KEY
4243
# - SCHEDULE_NAMESPACE: something short to identify tgis
4344
# - SCHEDULE_ID: the unique scheudle_id assigned
4445
# - STEPS: the constant "STEPS"
4546
# - OPERATION_NAME form the vairble's name during registration
4647
# - GROUP_INDEX
4748
# -> "{index}(S|P)[R]": S=single or P=parallel and optinally, "R" if steps should be repeated forever
49+
# - IS_CREATING: "C" or "D" for creation or destruction
4850
# - STEP_NAME form it's class
4951
# Example:
50-
# - SCH:00000000-0000-0000-0000-000000000000:STEPS:START_SERVICE:0S:BS1
51-
return f"{_SCHEDULE_NAMESPACE}:{schedule_id}:{_STEPS_KEY}:{operation_name}:{group}:{step_name}"
52+
# - SCH:00000000-0000-0000-0000-000000000000:STEPS:START_SERVICE:0S:C:BS1
53+
is_creating_str = "C" if is_creating else "D"
54+
return f"{_SCHEDULE_NAMESPACE}:{schedule_id}:{_STEPS_KEY}:{operation_name}:{group}:{is_creating_str}:{step_name}"
5255

5356

5457
def _dumps(obj: Any) -> str:
@@ -186,19 +189,22 @@ def __init__(
186189
operation_name: OperationName,
187190
step_group_name: StepGroupName,
188191
step_name: StepName,
192+
is_creating: bool,
189193
) -> None:
190194
self._store = store
191195
self._schedule_id = schedule_id
192196
self._operation_name = operation_name
193197
self._group = step_group_name
194198
self._step_name = step_name
199+
self._is_creating = is_creating
195200

196201
def _get_hash_key(self) -> str:
197202
return _get_step_hash_key(
198203
schedule_id=self._schedule_id,
199204
operation_name=self._operation_name,
200205
group=self._group,
201206
step_name=self._step_name,
207+
is_creating=self._is_creating,
202208
)
203209

204210
@overload

services/dynamic-scheduler/tests/unit/service_generic_scheduler/test__store.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,21 @@ async def test_schedule_data_store_proxy_workflow(
159159
await _assert_keys_in_hash(store, hash_key, set())
160160

161161

162-
async def test_step_store_proxy_workflow(store: Store, schedule_id: ScheduleId):
162+
@pytest.mark.parametrize("is_creating", [True, False])
163+
async def test_step_store_proxy_workflow(
164+
store: Store, schedule_id: ScheduleId, is_creating: bool
165+
):
163166
step_name = "MyStep"
164167
proxy = StepStoreProxy(
165168
store=store,
166169
schedule_id=schedule_id,
167170
operation_name="op1",
168171
step_group_name="sg1",
169172
step_name=step_name,
173+
is_creating=is_creating,
170174
)
171-
hash_key = f"SCH:{schedule_id}:STEPS:op1:sg1:{step_name}"
175+
is_creating_str = "C" if is_creating else "D"
176+
hash_key = f"SCH:{schedule_id}:STEPS:op1:sg1:{is_creating_str}:{step_name}"
172177

173178
# set
174179
await proxy.set("status", StepStatus.RUNNING)
@@ -191,6 +196,6 @@ async def test_step_store_proxy_workflow(store: Store, schedule_id: ScheduleId):
191196
await _assert_keys_in_hash(store, hash_key, {"status", "deferred_task_uid"})
192197

193198
# remove all keys an even missing ones
194-
await proxy.delete("status")
199+
await proxy.delete("status", "deferred_task_uid")
195200
await _assert_keys(store, set())
196201
await _assert_keys_in_hash(store, hash_key, set())

0 commit comments

Comments
 (0)