Skip to content

Commit 49467d0

Browse files
authored
the pipeline shall still be created even when no computational service is in the pipeline (#2105)
1 parent 8501538 commit 49467d0

File tree

2 files changed

+50
-7
lines changed

2 files changed

+50
-7
lines changed

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

+6-7
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,6 @@ async def create_computation(
132132
detail=f"Project {job.project_id} is not a valid directed acyclic graph!",
133133
)
134134

135-
if not dag_graph.nodes():
136-
# there is nothing else to be run here, so we are done
137-
raise HTTPException(
138-
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
139-
detail=f"Project {job.project_id} has no computational services",
140-
)
141-
142135
# ok so put the tasks in the db
143136
await computation_pipelines.upsert_pipeline(
144137
project.uuid, dag_graph, job.start_pipeline
@@ -150,6 +143,12 @@ async def create_computation(
150143
)
151144

152145
if job.start_pipeline:
146+
if not dag_graph.nodes():
147+
# there is nothing else to be run here, so we are done
148+
raise HTTPException(
149+
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY,
150+
detail=f"Project {job.project_id} has no computational services",
151+
)
153152
# trigger celery
154153
task = celery_client.send_computation_task(job.user_id, job.project_id)
155154
background_tasks.add_task(background_on_message, task)

services/director-v2/tests/integration/test_computation_api.py

+44
Original file line numberDiff line numberDiff line change
@@ -587,3 +587,47 @@ def test_update_and_delete_computation(
587587
assert (
588588
response.status_code == status.HTTP_204_NO_CONTENT
589589
), f"response code is {response.status_code}, error: {response.text}"
590+
591+
592+
def test_pipeline_with_no_comp_services_still_create_correct_comp_tasks(
593+
client: TestClient,
594+
user_id: PositiveInt,
595+
project: Callable,
596+
jupyter_service: Dict[str, str],
597+
):
598+
# create a workbench with just a dynamic service
599+
project_with_dynamic_node = project(
600+
workbench={
601+
"39e92f80-9286-5612-85d1-639fa47ec57d": {
602+
"key": jupyter_service["image"]["name"],
603+
"version": jupyter_service["image"]["tag"],
604+
"label": "my sole dynamic service",
605+
}
606+
}
607+
)
608+
609+
# this pipeline is not runnable as there are no computational services
610+
response = client.post(
611+
COMPUTATION_URL,
612+
json={
613+
"user_id": user_id,
614+
"project_id": str(project_with_dynamic_node.uuid),
615+
"start_pipeline": True,
616+
},
617+
)
618+
assert (
619+
response.status_code == status.HTTP_422_UNPROCESSABLE_ENTITY
620+
), f"response code is {response.status_code}, error: {response.text}"
621+
622+
# still this pipeline shall be createable if we do not want to start it
623+
response = client.post(
624+
COMPUTATION_URL,
625+
json={
626+
"user_id": user_id,
627+
"project_id": str(project_with_dynamic_node.uuid),
628+
"start_pipeline": False,
629+
},
630+
)
631+
assert (
632+
response.status_code == status.HTTP_201_CREATED
633+
), f"response code is {response.status_code}, error: {response.text}"

0 commit comments

Comments
 (0)