File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
services/director-v2/src/simcore_service_director_v2/modules/comp_scheduler Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 1+ import contextlib
12import logging
23from typing import Final
34
45import networkx as nx
56from common_library .async_tools import cancel_wait_task
67from fastapi import FastAPI
78from models_library .projects import ProjectID
8- from models_library .projects_state import RunningState
99from models_library .users import UserID
1010from servicelib .background_task import create_periodic_task
1111from servicelib .exception_utils import suppress_exceptions
1414from servicelib .utils import limited_gather
1515from sqlalchemy .ext .asyncio import AsyncEngine
1616
17+ from ...core .errors import ComputationalRunNotFoundError
1718from ...models .comp_pipelines import CompPipelineAtDB
1819from ...models .comp_runs import RunMetadataDict
1920from ...models .comp_tasks import CompTaskAtDB
@@ -58,6 +59,18 @@ async def run_new_pipeline(
5859 )
5960 return
6061
62+ with contextlib .suppress (ComputationalRunNotFoundError ):
63+ # if the run already exists and is scheduled, do not schedule again.
64+ last_run = await CompRunsRepository .instance (db_engine ).get (
65+ user_id = user_id , project_id = project_id
66+ )
67+ if last_run .result .is_running ():
68+ _logger .warning (
69+ "run for project %s is already running. not scheduling it again." ,
70+ f"{ project_id = } " ,
71+ )
72+ return
73+
6174 new_run = await CompRunsRepository .instance (db_engine ).create (
6275 user_id = user_id ,
6376 project_id = project_id ,
You can’t perform that action at this time.
0 commit comments