forked from ITISFoundation/osparc-simcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 6865-ensure-backwards-compatibility-of-api…
…-server
- Loading branch information
Showing
7 changed files
with
102 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...s/dynamic-scheduler/src/simcore_service_dynamic_scheduler/services/scheduler_interface.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from fastapi import FastAPI | ||
from models_library.api_schemas_directorv2.dynamic_services import DynamicServiceGet | ||
from models_library.api_schemas_dynamic_scheduler.dynamic_services import ( | ||
DynamicServiceStart, | ||
DynamicServiceStop, | ||
) | ||
from models_library.api_schemas_webserver.projects_nodes import NodeGet, NodeGetIdle | ||
from models_library.projects_nodes_io import NodeID | ||
|
||
from ..core.settings import ApplicationSettings | ||
from .director_v2 import DirectorV2Client | ||
from .service_tracker import set_request_as_running, set_request_as_stopped | ||
|
||
|
||
async def get_service_status( | ||
app: FastAPI, *, node_id: NodeID | ||
) -> NodeGet | DynamicServiceGet | NodeGetIdle: | ||
settings: ApplicationSettings = app.state.settings | ||
if settings.DYNAMIC_SCHEDULER_USE_INTERNAL_SCHEDULER: | ||
raise NotImplementedError | ||
|
||
director_v2_client = DirectorV2Client.get_from_app_state(app) | ||
response: NodeGet | DynamicServiceGet | NodeGetIdle = ( | ||
await director_v2_client.get_status(node_id) | ||
) | ||
return response | ||
|
||
|
||
async def run_dynamic_service( | ||
app: FastAPI, *, dynamic_service_start: DynamicServiceStart | ||
) -> NodeGet | DynamicServiceGet: | ||
settings: ApplicationSettings = app.state.settings | ||
if settings.DYNAMIC_SCHEDULER_USE_INTERNAL_SCHEDULER: | ||
raise NotImplementedError | ||
|
||
director_v2_client = DirectorV2Client.get_from_app_state(app) | ||
response: NodeGet | DynamicServiceGet = ( | ||
await director_v2_client.run_dynamic_service(dynamic_service_start) | ||
) | ||
|
||
await set_request_as_running(app, dynamic_service_start) | ||
return response | ||
|
||
|
||
async def stop_dynamic_service( | ||
app: FastAPI, *, dynamic_service_stop: DynamicServiceStop | ||
) -> None: | ||
settings: ApplicationSettings = app.state.settings | ||
if settings.DYNAMIC_SCHEDULER_USE_INTERNAL_SCHEDULER: | ||
raise NotImplementedError | ||
|
||
director_v2_client = DirectorV2Client.get_from_app_state(app) | ||
await director_v2_client.stop_dynamic_service( | ||
node_id=dynamic_service_stop.node_id, | ||
simcore_user_agent=dynamic_service_stop.simcore_user_agent, | ||
save_state=dynamic_service_stop.save_state, | ||
timeout=settings.DYNAMIC_SCHEDULER_STOP_SERVICE_TIMEOUT, | ||
) | ||
|
||
await set_request_as_stopped(app, dynamic_service_stop) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters