|
75 | 75 | compute_pipeline_details, |
76 | 76 | compute_pipeline_started_timestamp, |
77 | 77 | compute_pipeline_stopped_timestamp, |
78 | | - compute_pipeline_submitted_timestamp, |
79 | 78 | create_complete_dag, |
80 | 79 | create_complete_dag_from_tasks, |
81 | 80 | create_minimal_computational_graph_based_on_selection, |
@@ -396,9 +395,7 @@ async def create_computation( # noqa: PLR0913 # pylint: disable=too-many-positi |
396 | 395 | stopped=compute_pipeline_stopped_timestamp( |
397 | 396 | minimal_computational_dag, comp_tasks |
398 | 397 | ), |
399 | | - submitted=compute_pipeline_submitted_timestamp( |
400 | | - minimal_computational_dag, comp_tasks |
401 | | - ), |
| 398 | + submitted=last_run.created if last_run else None, |
402 | 399 | ) |
403 | 400 |
|
404 | 401 | except ProjectNotFoundError as e: |
@@ -498,7 +495,7 @@ async def get_computation( |
498 | 495 | result=None, |
499 | 496 | started=compute_pipeline_started_timestamp(pipeline_dag, all_tasks), |
500 | 497 | 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, |
502 | 499 | ) |
503 | 500 |
|
504 | 501 |
|
@@ -554,26 +551,29 @@ async def stop_computation( |
554 | 551 | ) |
555 | 552 |
|
556 | 553 | # 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, |
561 | 574 | ) |
562 | 575 |
|
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() |
577 | 577 |
|
578 | 578 | except ProjectNotFoundError as e: |
579 | 579 | raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"{e}") from e |
|
0 commit comments