Skip to content

Commit 410d166

Browse files
committed
corrected return submitted datetime
1 parent 9b27178 commit 410d166

File tree

2 files changed

+23
-34
lines changed

2 files changed

+23
-34
lines changed

services/director-v2/src/simcore_service_director_v2/api/routes/computations.py

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
compute_pipeline_details,
7676
compute_pipeline_started_timestamp,
7777
compute_pipeline_stopped_timestamp,
78-
compute_pipeline_submitted_timestamp,
7978
create_complete_dag,
8079
create_complete_dag_from_tasks,
8180
create_minimal_computational_graph_based_on_selection,
@@ -396,9 +395,7 @@ async def create_computation( # noqa: PLR0913 # pylint: disable=too-many-positi
396395
stopped=compute_pipeline_stopped_timestamp(
397396
minimal_computational_dag, comp_tasks
398397
),
399-
submitted=compute_pipeline_submitted_timestamp(
400-
minimal_computational_dag, comp_tasks
401-
),
398+
submitted=last_run.created if last_run else None,
402399
)
403400

404401
except ProjectNotFoundError as e:
@@ -498,7 +495,7 @@ async def get_computation(
498495
result=None,
499496
started=compute_pipeline_started_timestamp(pipeline_dag, all_tasks),
500497
stopped=compute_pipeline_stopped_timestamp(pipeline_dag, all_tasks),
501-
submitted=compute_pipeline_submitted_timestamp(pipeline_dag, all_tasks),
498+
submitted=last_run.created if last_run else None,
502499
)
503500

504501

@@ -554,26 +551,29 @@ async def stop_computation(
554551
)
555552

556553
# get run details if any
557-
last_run: CompRunsAtDB | None = None
558-
with contextlib.suppress(ComputationalRunNotFoundError):
559-
last_run = await comp_runs_repo.get(
560-
user_id=computation_stop.user_id, project_id=project_id
554+
async def _create_computation_response() -> ComputationGet:
555+
last_run: CompRunsAtDB | None = None
556+
with contextlib.suppress(ComputationalRunNotFoundError):
557+
last_run = await comp_runs_repo.get(
558+
user_id=computation_stop.user_id, project_id=project_id
559+
)
560+
561+
return ComputationGet(
562+
id=project_id,
563+
state=pipeline_state,
564+
pipeline_details=await compute_pipeline_details(
565+
complete_dag, pipeline_dag, tasks
566+
),
567+
url=TypeAdapter(AnyHttpUrl).validate_python(f"{request.url}"),
568+
stop_url=None,
569+
iteration=last_run.iteration if last_run else None,
570+
result=None,
571+
started=compute_pipeline_started_timestamp(pipeline_dag, tasks),
572+
stopped=compute_pipeline_stopped_timestamp(pipeline_dag, tasks),
573+
submitted=last_run.created if last_run else None,
561574
)
562575

563-
return ComputationGet(
564-
id=project_id,
565-
state=pipeline_state,
566-
pipeline_details=await compute_pipeline_details(
567-
complete_dag, pipeline_dag, tasks
568-
),
569-
url=TypeAdapter(AnyHttpUrl).validate_python(f"{request.url}"),
570-
stop_url=None,
571-
iteration=last_run.iteration if last_run else None,
572-
result=None,
573-
started=compute_pipeline_started_timestamp(pipeline_dag, tasks),
574-
stopped=compute_pipeline_stopped_timestamp(pipeline_dag, tasks),
575-
submitted=compute_pipeline_submitted_timestamp(pipeline_dag, tasks),
576-
)
576+
return await _create_computation_response()
577577

578578
except ProjectNotFoundError as e:
579579
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"{e}") from e

services/director-v2/src/simcore_service_director_v2/utils/dags.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -217,17 +217,6 @@ def compute_pipeline_stopped_timestamp(
217217
return pipeline_stopped_at
218218

219219

220-
def compute_pipeline_submitted_timestamp(
221-
pipeline_dag: nx.DiGraph, comp_tasks: list[CompTaskAtDB]
222-
) -> datetime.datetime | None:
223-
if not pipeline_dag.nodes:
224-
return None
225-
node_id_to_comp_task: dict[NodeIDStr, CompTaskAtDB] = {
226-
NodeIDStr(f"{task.node_id}"): task for task in comp_tasks
227-
}
228-
return max(node_id_to_comp_task[node_id].submit for node_id in pipeline_dag.nodes)
229-
230-
231220
async def compute_pipeline_details(
232221
complete_dag: nx.DiGraph, pipeline_dag: nx.DiGraph, comp_tasks: list[CompTaskAtDB]
233222
) -> PipelineDetails:

0 commit comments

Comments
 (0)