Skip to content

Commit 8d2ff4c

Browse files
author
Andrei Neagu
committed
added exceptions
1 parent 243667a commit 8d2ff4c

File tree

2 files changed

+26
-6
lines changed
  • services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/services/generic_scheduler

2 files changed

+26
-6
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
CannotCancelWhileWaitingForManualInterventionError,
2121
InitialOperationContextKeyNotAllowedError,
2222
KeyNotFoundInHashError,
23+
StepNameNotInCurrentGroupError,
24+
StepNotInErrorStateError,
25+
StepNotWaitingForManualInterventionError,
2326
UnexpectedStepHandlingError,
2427
)
2528
from ._models import (
@@ -348,8 +351,11 @@ async def restart_operation_step_in_error(
348351
if step_name not in {
349352
step.get_step_name() for step in step_group.get_step_subgroup_to_run()
350353
}:
351-
msg = f"step_name='{step_name}' not in current step_group_name='{step_group_name}' of operation_name='{operation_name}'"
352-
raise ValueError(msg)
354+
raise StepNameNotInCurrentGroupError(
355+
step_name=step_name,
356+
step_group_name=step_group_name,
357+
operation_name=operation_name,
358+
)
353359

354360
step_proxy = StepStoreProxy(
355361
store=self._store,
@@ -363,8 +369,7 @@ async def restart_operation_step_in_error(
363369
try:
364370
await step_proxy.get("error_traceback")
365371
except KeyNotFoundInHashError as exc:
366-
msg = f"Step '{step_name}' is not in error state and cannot be restarted"
367-
raise ValueError(msg) from exc
372+
raise StepNotInErrorStateError(step_name=step_name) from exc
368373

369374
if in_manual_intervention:
370375
requires_manual_intervention: bool = False
@@ -374,8 +379,7 @@ async def restart_operation_step_in_error(
374379
)
375380

376381
if requires_manual_intervention is False:
377-
msg = f"Step '{step_name}' is not waiting for manual intervention"
378-
raise ValueError(msg)
382+
raise StepNotWaitingForManualInterventionError(step_name=step_name)
379383

380384
await step_proxy.delete("error_traceback", "requires_manual_intervention")
381385
else:

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,19 @@ class CannotCancelWhileWaitingForManualInterventionError(BaseGenericSchedulerErr
5252
msg_template: str = (
5353
"Cannot cancel schedule_id='{schedule_id}' while one or more steps are waiting for manual intervention."
5454
)
55+
56+
57+
class StepNameNotInCurrentGroupError(BaseGenericSchedulerError):
58+
msg_template: str = (
59+
"step_name='{step_name}' not in current step_group_name='{step_group_name}' of operation_name='{operation_name}'"
60+
)
61+
62+
63+
class StepNotInErrorStateError(BaseGenericSchedulerError):
64+
msg_template: str = (
65+
"step_name='{step_name}' is not in an error state and cannot be restarted"
66+
)
67+
68+
69+
class StepNotWaitingForManualInterventionError(BaseGenericSchedulerError):
70+
msg_template: str = "step_name='{step_name}' is not waiting for manual intervention"

0 commit comments

Comments
 (0)