Skip to content

Commit 719a530

Browse files
author
Andrei Neagu
committed
refactor
1 parent 4bc004e commit 719a530

File tree

2 files changed

+9
-8
lines changed
  • services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/services/generic_scheduler

2 files changed

+9
-8
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
safe_event,
2525
set_unexpected_opration_state,
2626
start_and_mark_as_started,
27-
start_steps_and_get_count,
27+
start_steps_which_were_not_started,
2828
)
2929
from ._deferred_runner import DeferredRunner
3030
from ._dependencies import enqueue_schedule_event
@@ -288,12 +288,11 @@ async def _on_schedule_event(self, schedule_id: ScheduleId) -> None:
288288
)
289289

290290
# 1) ensure all steps in the group are started
291-
started_steps_couunt = await start_steps_and_get_count(
291+
if await start_steps_which_were_not_started(
292292
group_step_proxies,
293293
is_creating=is_creating,
294294
group_step_count=len(step_group),
295-
)
296-
if started_steps_couunt > 0:
295+
):
297296
# since steps were started, we wait for next event to check their status
298297
return
299298

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,14 @@ async def _get_steps_to_start(
165165
return [proxy for was_started, proxy in result if was_started is False]
166166

167167

168-
async def start_steps_and_get_count(
168+
async def start_steps_which_were_not_started(
169169
group_step_proxies: dict[StepName, StepStoreProxy],
170170
*,
171171
is_creating: bool,
172172
group_step_count: NonNegativeInt,
173-
) -> NonNegativeInt:
173+
) -> bool:
174+
"""retruns True if any step was started"""
175+
started_count: NonNegativeInt = 0
174176
if to_start_step_proxies := await _get_steps_to_start(group_step_proxies.values()):
175177
steps_to_start_names = [
176178
step_proxy.step_name for step_proxy in to_start_step_proxies
@@ -191,8 +193,8 @@ async def start_steps_and_get_count(
191193
),
192194
limit=PARALLEL_STATUS_REQUESTS,
193195
)
194-
return len(to_start_step_proxies)
195-
return 0
196+
started_count = len(to_start_step_proxies)
197+
return started_count > 0
196198

197199

198200
async def cleanup_after_finishing(

0 commit comments

Comments
 (0)