Skip to content

Commit b6c9aee

Browse files
author
Andrei Neagu
committed
update comments
1 parent e1c2f85 commit b6c9aee

File tree

1 file changed

+27
-24
lines changed
  • services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/services/generic_scheduler

1 file changed

+27
-24
lines changed

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

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ async def _on_schedule_event(self, schedule_id: ScheduleId) -> None:
287287
is_creating=is_creating,
288288
)
289289

290-
# 1. ensure all steps in the group are started
290+
# 1) ensure all steps in the group are started
291291
started_steps_couunt = await start_steps_and_get_count(
292292
group_step_proxies,
293293
is_creating=is_creating,
@@ -300,7 +300,7 @@ async def _on_schedule_event(self, schedule_id: ScheduleId) -> None:
300300
steps_statuses = await get_steps_statuses(group_step_proxies.values())
301301
_logger.debug("DETECTED: steps_statuses=%s", steps_statuses)
302302

303-
# 2. wait for all steps to finish before continuing
303+
# 2) wait for all steps to finish before continuing
304304
if is_operation_in_progress_status(steps_statuses):
305305
_logger.debug(
306306
"Operation '%s' has not finished: steps_statuses='%s'",
@@ -309,13 +309,12 @@ async def _on_schedule_event(self, schedule_id: ScheduleId) -> None:
309309
)
310310
return
311311

312-
# 3. all steps are in a final state, process them
312+
# 3) all steps are in a final state, process them
313313
_logger.debug("steps_statuses=%s in final state in operation", steps_statuses)
314314

315315
if step_group.repeat_steps is True and is_creating:
316-
# Meaning check:
317-
# 3A1. if any of the repeating steps was cancelled -> move to revert
318-
# 3A2. otherwise restart all steps in the group
316+
# 3A1) if any of the repeating steps was cancelled -> move to revert
317+
# 3A2) otherwise restart all steps in the group
319318
await self._continue_as_repeating_group(
320319
schedule_data_proxy,
321320
schedule_id,
@@ -325,10 +324,11 @@ async def _on_schedule_event(self, schedule_id: ScheduleId) -> None:
325324
group_step_proxies,
326325
)
327326
elif is_creating:
328-
# Meaning check:
329-
# 3B1. if all steps in group in SUUCESS -> move to next group
330-
# 3B2. if manual intervention is required -> do nothing else
331-
# 3B3. if any step in CANCELLED or FAILED(and not in manual intervention) -> move to revert
327+
# 3B1) if all steps in group in SUUCESS
328+
# - 3B1a) move to next group
329+
# - 3B1b) reached the end of the CREATE operation, remove all created data
330+
# 3B2) if manual intervention is required -> do nothing else
331+
# 3B3) if any step in CANCELLED or FAILED(and not in manual intervention) -> move to revert
332332
await self._continue_as_creation(
333333
steps_statuses,
334334
schedule_data_proxy,
@@ -339,10 +339,11 @@ async def _on_schedule_event(self, schedule_id: ScheduleId) -> None:
339339
operation,
340340
)
341341
else:
342-
# Meaning check:
343-
# 3C1. if all steps in gorup in SUUCESS -> go back to previous group untill done
344-
# 3C2. it is unexpected to have a FAILED step -> do nothing else
345-
# 3C3. it is unexpected to have a CANCELLED step -> do nothing else
342+
# 3C1) if all steps in gorup in SUUCESS
343+
# - 3C1a) reached the end of the REVERT operation, remove all created data
344+
# - 3C1b) go back to previous group untill done
345+
# 3C2) it is unexpected to have a FAILED step -> do nothing else
346+
# 3C3) it is unexpected to have a CANCELLED step -> do nothing else
346347
await self._continue_as_reverting(
347348
steps_statuses,
348349
schedule_data_proxy,
@@ -375,14 +376,14 @@ async def _continue_as_repeating_group(
375376
# since a cancellation request might have been requested
376377
steps_stauses = await get_steps_statuses(step_proxies)
377378

378-
# 3A1. if any of the repeating steps was cancelled -> move to revert
379+
# 3A1) if any of the repeating steps was cancelled -> move to revert
379380
if any(status == StepStatus.CANCELLED for status in steps_stauses.values()):
380381
# NOTE:
381382
await schedule_data_proxy.set("is_creating", value=False)
382383
await enqueue_schedule_event(self.app, schedule_id)
383384
return
384385

385-
# 3A2. otherwise restart all steps in the group
386+
# 3A2) otherwise restart all steps in the group
386387
await limited_gather(
387388
*(x.remove() for x in step_proxies), limit=PARALLEL_STATUS_REQUESTS
388389
)
@@ -406,23 +407,24 @@ async def _continue_as_creation(
406407
current_step_group: BaseStepGroup,
407408
operation: Operation,
408409
) -> None:
409-
# 3B1. if all steps in group in SUUCESS -> move to next group
410+
# 3B1) if all steps in group in SUUCESS
410411
if all(status == StepStatus.SUCCESS for status in steps_statuses.values()):
412+
# 3B1a) move to next group
411413
try:
412414
next_group_index = group_index + 1
413415
# does a next group exist?
414416
_ = operation[next_group_index]
415417
await schedule_data_proxy.set("group_index", value=next_group_index)
416418
await enqueue_schedule_event(self.app, schedule_id)
417419
except IndexError:
418-
# reached the end of the CREATE operation, remove all created data
420+
# 3B1b) reached the end of the CREATE operation, remove all created data
419421
await cleanup_after_finishing(
420422
self._store, schedule_id=schedule_id, is_creating=True
421423
)
422424

423425
return
424426

425-
# 3B2. if manual intervention is required -> do nothing else
427+
# 3B2) if manual intervention is required -> do nothing else
426428
manual_intervention_step_names: set[StepName] = set()
427429
current_step_group.get_step_subgroup_to_run()
428430
for step in current_step_group.get_step_subgroup_to_run():
@@ -452,7 +454,7 @@ async def _continue_as_creation(
452454
)
453455
return
454456

455-
# 3B3. if any step in CANCELLED or FAILED(and not in manual intervention) -> move to revert
457+
# 3B3) if any step in CANCELLED or FAILED(and not in manual intervention) -> move to revert
456458
if any(
457459
s in {StepStatus.FAILED, StepStatus.CANCELLED}
458460
for s in steps_statuses.values()
@@ -479,21 +481,22 @@ async def _continue_as_reverting(
479481
group_index: NonNegativeInt,
480482
current_step_group: BaseStepGroup,
481483
) -> None:
482-
# 3C1. if all steps in gorup in SUUCESS -> go back to previous group untill done
484+
# 3C1) if all steps in gorup in SUUCESS
483485
if all(s == StepStatus.SUCCESS for s in steps_statuses.values()):
484486
previous_group_index = group_index - 1
485487
if previous_group_index < 0:
486-
# reached the end of the REVERT operation, remove all created data
488+
# 3C1a) reached the end of the REVERT operation, remove all created data
487489
await cleanup_after_finishing(
488490
self._store, schedule_id=schedule_id, is_creating=False
489491
)
490492
return
491493

494+
# 3C1b) go back to previous group untill done
492495
await schedule_data_proxy.set("group_index", value=previous_group_index)
493496
await enqueue_schedule_event(self.app, schedule_id)
494497
return
495498

496-
# 3C2. it is unexpected to have a FAILED step -> do nothing else
499+
# 3C2) it is unexpected to have a FAILED step -> do nothing else
497500
if failed_step_names := [
498501
n for n, s in steps_statuses.items() if s == StepStatus.FAILED
499502
]:
@@ -527,7 +530,7 @@ async def _continue_as_reverting(
527530
)
528531
return
529532

530-
# 3C3. it is unexpected to have a CANCELLED step -> do nothing else
533+
# 3C3) it is unexpected to have a CANCELLED step -> do nothing else
531534
if cancelled_step_names := [
532535
n for n, s in steps_statuses.items() if s == StepStatus.CANCELLED
533536
]:

0 commit comments

Comments
 (0)