Skip to content

Commit a1a906e

Browse files
author
Andrei Neagu
committed
refactor interface
1 parent 47f804c commit a1a906e

File tree

3 files changed

+50
-41
lines changed

3 files changed

+50
-41
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ._core import (
1+
from ._api import (
22
cancel_operation,
33
restart_create_operation_step_in_manual_intervention,
44
restart_revert_operation_step_in_error,
@@ -29,8 +29,6 @@
2929
"BaseStep",
3030
"cancel_operation",
3131
"get_generic_scheduler_lifespans",
32-
"restart_create_operation_step_in_manual_intervention",
33-
"restart_revert_operation_step_in_error",
3432
"get_opration_context_proxy",
3533
"get_step_group_proxy",
3634
"get_step_store_proxy",
@@ -41,6 +39,8 @@
4139
"ParallelStepGroup",
4240
"ProvidedOperationContext",
4341
"RequiredOperationContext",
42+
"restart_create_operation_step_in_manual_intervention",
43+
"restart_revert_operation_step_in_error",
4444
"ScheduleId",
4545
"SingleStepGroup",
4646
"start_operation",
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from fastapi import FastAPI
2+
3+
from ._core import get_core
4+
from ._models import (
5+
OperationContext,
6+
OperationName,
7+
ScheduleId,
8+
StepName,
9+
)
10+
11+
12+
async def start_operation(
13+
app: FastAPI,
14+
operation_name: OperationName,
15+
initial_operation_context: OperationContext,
16+
) -> ScheduleId:
17+
"""starts an operation by it's given name and initial context"""
18+
return await get_core(app).start_operation(
19+
operation_name, initial_operation_context
20+
)
21+
22+
23+
async def cancel_operation(app: FastAPI, schedule_id: ScheduleId) -> None:
24+
"""aborts an opration and triggers revert of all it's executed steps"""
25+
await get_core(app).cancel_schedule(schedule_id)
26+
27+
28+
async def restart_create_operation_step_in_manual_intervention(
29+
app: FastAPI, schedule_id: ScheduleId, step_name: StepName
30+
) -> None:
31+
"""
32+
restarts a step waiting for manual intervention
33+
NOTE: to be used only with steps with wait_for_manual_intervention=True
34+
and only to restart the `create`
35+
"""
36+
await get_core(app).restart_operation_step_in_error(
37+
schedule_id, step_name, in_manual_intervention=True
38+
)
39+
40+
41+
async def restart_revert_operation_step_in_error(
42+
app: FastAPI, schedule_id: ScheduleId, step_name: StepName
43+
) -> None:
44+
"""restarts a step stuck in `revert` in an error state"""
45+
await get_core(app).restart_operation_step_in_error(
46+
schedule_id, step_name, in_manual_intervention=False
47+
)

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

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -731,41 +731,3 @@ async def lifespan(app: FastAPI) -> AsyncIterator[State]:
731731
def get_core(app: FastAPI) -> Core:
732732
core: Core = app.state.generic_scheduler_core
733733
return core
734-
735-
736-
async def start_operation(
737-
app: FastAPI,
738-
operation_name: OperationName,
739-
initial_operation_context: OperationContext,
740-
) -> ScheduleId:
741-
"""starts an operation by it's given name and initial context"""
742-
return await get_core(app).start_operation(
743-
operation_name, initial_operation_context
744-
)
745-
746-
747-
async def cancel_operation(app: FastAPI, schedule_id: ScheduleId) -> None:
748-
"""aborts an opration and triggers revert of all it's executed steps"""
749-
await get_core(app).cancel_schedule(schedule_id)
750-
751-
752-
async def restart_create_operation_step_in_manual_intervention(
753-
app: FastAPI, schedule_id: ScheduleId, step_name: StepName
754-
) -> None:
755-
"""
756-
restarts a step waiting for manual intervention
757-
NOTE: to be used only with steps with wait_for_manual_intervention=True
758-
and only to restart the `create`
759-
"""
760-
await get_core(app).restart_operation_step_in_error(
761-
schedule_id, step_name, in_manual_intervention=True
762-
)
763-
764-
765-
async def restart_revert_operation_step_in_error(
766-
app: FastAPI, schedule_id: ScheduleId, step_name: StepName
767-
) -> None:
768-
"""restarts a step stuck in `revert` in an error state"""
769-
await get_core(app).restart_operation_step_in_error(
770-
schedule_id, step_name, in_manual_intervention=False
771-
)

0 commit comments

Comments
 (0)