|
1 | | -""" CRUD operations on a "computation" resource |
| 1 | +"""CRUD operations on a "computation" resource |
2 | 2 |
|
3 | 3 | A computation is a resource that represents a running pipeline of computational services in a give project |
4 | 4 | Therefore, |
|
15 | 15 | # pylint: disable=too-many-arguments |
16 | 16 | # pylint: disable=too-many-statements |
17 | 17 |
|
18 | | - |
19 | 18 | import contextlib |
20 | 19 | import logging |
21 | 20 | from typing import Annotated, Any, Final |
@@ -551,29 +550,26 @@ async def stop_computation( |
551 | 550 | ) |
552 | 551 |
|
553 | 552 | # get run details if any |
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, |
| 553 | + last_run: CompRunsAtDB | None = None |
| 554 | + with contextlib.suppress(ComputationalRunNotFoundError): |
| 555 | + last_run = await comp_runs_repo.get( |
| 556 | + user_id=computation_stop.user_id, project_id=project_id |
574 | 557 | ) |
575 | 558 |
|
576 | | - return await _create_computation_response() |
| 559 | + return ComputationGet( |
| 560 | + id=project_id, |
| 561 | + state=pipeline_state, |
| 562 | + pipeline_details=await compute_pipeline_details( |
| 563 | + complete_dag, pipeline_dag, tasks |
| 564 | + ), |
| 565 | + url=TypeAdapter(AnyHttpUrl).validate_python(f"{request.url}"), |
| 566 | + stop_url=None, |
| 567 | + iteration=last_run.iteration if last_run else None, |
| 568 | + result=None, |
| 569 | + started=compute_pipeline_started_timestamp(pipeline_dag, tasks), |
| 570 | + stopped=compute_pipeline_stopped_timestamp(pipeline_dag, tasks), |
| 571 | + submitted=last_run.created if last_run else None, |
| 572 | + ) |
577 | 573 |
|
578 | 574 | except ProjectNotFoundError as e: |
579 | 575 | raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=f"{e}") from e |
|
0 commit comments