Skip to content

Commit f03af79

Browse files
author
Andrei Neagu
committed
added notes
1 parent 3797194 commit f03af79

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
)
3030

3131

32-
def _get_step_store_proxy(context: DeferredContext) -> StepStoreProxy:
32+
def get_step_store_proxy(context: DeferredContext) -> StepStoreProxy:
3333
app: FastAPI = context["app"]
3434
schedule_id: ScheduleId = context["schedule_id"]
3535
operation_name: OperationName = context["operation_name"]
@@ -48,7 +48,7 @@ def _get_step_store_proxy(context: DeferredContext) -> StepStoreProxy:
4848
)
4949

5050

51-
def _get_step_group_proxy(context: DeferredContext) -> StepGroupProxy:
51+
def get_step_group_proxy(context: DeferredContext) -> StepGroupProxy:
5252
app: FastAPI = context["app"]
5353
schedule_id: ScheduleId = context["schedule_id"]
5454
operation_name: OperationName = context["operation_name"]
@@ -90,7 +90,7 @@ async def _send_group_done_check_event(context: DeferredContext) -> None:
9090
expected_steps_count: NonNegativeInt = context["expected_steps_count"]
9191

9292
if (
93-
await _get_step_group_proxy(context).increment_and_get_done_steps_count()
93+
await get_step_group_proxy(context).increment_and_get_done_steps_count()
9494
== expected_steps_count
9595
):
9696
await enqueue_schedule_event(app, schedule_id)
@@ -161,7 +161,7 @@ async def get_timeout(cls, context: DeferredContext) -> timedelta:
161161

162162
@classmethod
163163
async def on_created(cls, task_uid: TaskUID, context: DeferredContext) -> None:
164-
await _get_step_store_proxy(context).set_multiple(
164+
await get_step_store_proxy(context).set_multiple(
165165
{"deferred_task_uid": task_uid, "status": StepStatus.CREATED}
166166
)
167167

@@ -170,7 +170,7 @@ async def run(cls, context: DeferredContext) -> None:
170170
app = context["app"]
171171
is_creating = context["is_creating"]
172172

173-
await _get_step_store_proxy(context).set("status", StepStatus.RUNNING)
173+
await get_step_store_proxy(context).set("status", StepStatus.RUNNING)
174174

175175
step = _get_step(context)
176176

@@ -208,22 +208,22 @@ async def run(cls, context: DeferredContext) -> None:
208208
@classmethod
209209
async def on_result(cls, result: None, context: DeferredContext) -> None:
210210
_ = result
211-
await _get_step_store_proxy(context).set("status", StepStatus.SUCCESS)
211+
await get_step_store_proxy(context).set("status", StepStatus.SUCCESS)
212212

213213
await _send_group_done_check_event(context)
214214

215215
@classmethod
216216
async def on_finished_with_error(
217217
cls, error: TaskResultError, context: DeferredContext
218218
) -> None:
219-
await _get_step_store_proxy(context).set_multiple(
219+
await get_step_store_proxy(context).set_multiple(
220220
{"status": StepStatus.FAILED, "error_traceback": error.format_error()}
221221
)
222222

223223
await _send_group_done_check_event(context)
224224

225225
@classmethod
226226
async def on_cancelled(cls, context: DeferredContext) -> None:
227-
await _get_step_store_proxy(context).set("status", StepStatus.CANCELLED)
227+
await get_step_store_proxy(context).set("status", StepStatus.CANCELLED)
228228

229229
await _send_group_done_check_event(context)

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,23 @@ def get_create_provides_context_keys(cls) -> set[str]:
5858

5959
@classmethod
6060
async def get_create_retries(cls, context: DeferredContext) -> int:
61-
"""[optional] amount of retires in case of creation"""
61+
"""
62+
[optional] amount of retires in case of creation
63+
HINT: you can use `get_step_group_proxy(context)` and `get_step_store_proxy(context)`
64+
to implement custom retry strategy
65+
"""
6266
assert context # nosec
6367
return _DEFAULT_STEP_RETRIES
6468

6569
@classmethod
6670
async def get_create_wait_between_attempts(
6771
cls, context: DeferredContext
6872
) -> timedelta:
69-
"""[optional] wait time between retires case of creation"""
73+
"""
74+
[optional] wait time between retires case of creation
75+
HINT: you can use `get_step_group_proxy(context)` and `get_step_store_proxy(context)`
76+
to implement custom retry strategy
77+
"""
7078
assert context # nosec
7179
return _DEFAULT_STEP_TIMEOUT
7280

@@ -110,15 +118,23 @@ def get_revert_provides_context_keys(cls) -> set[str]:
110118

111119
@classmethod
112120
async def get_revert_retries(cls, context: DeferredContext) -> int:
113-
"""[optional] amount of retires in case of failure"""
121+
"""
122+
[optional] amount of retires in case of failure
123+
HINT: you can use `get_step_group_proxy(context)` and `get_step_store_proxy(context)`
124+
to implement custom retry strategy
125+
"""
114126
assert context # nosec
115127
return _DEFAULT_STEP_RETRIES
116128

117129
@classmethod
118130
async def get_revert_wait_between_attempts(
119131
cls, context: DeferredContext
120132
) -> timedelta:
121-
"""[optional] timeout between retires in case of failure"""
133+
"""
134+
[optional] timeout between retires in case of failure
135+
HINT: you can use `get_step_group_proxy(context)` and `get_step_store_proxy(context)`
136+
to implement custom retry strategy
137+
"""
122138
assert context # nosec
123139
return _DEFAULT_STEP_TIMEOUT
124140

0 commit comments

Comments
 (0)