Skip to content

Commit 67c2183

Browse files
fix: workbench
1 parent 2bc186d commit 67c2183

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

services/web/server/src/simcore_service_webserver/director_v2/_computations_service.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
from ..projects.api import (
3939
batch_get_project_name,
4040
check_user_project_permission,
41-
get_project_dict_legacy,
4241
)
4342
from ..projects.projects_metadata_service import (
4443
get_project_custom_metadata_or_empty_dict,
@@ -48,6 +47,13 @@
4847
from ._comp_runs_collections_service import get_comp_run_collection_or_none_by_id
4948

5049

50+
async def _wrap_with_id(
51+
project_id: ProjectID, coro: Awaitable[list[tuple[NodeID, Node]]]
52+
) -> tuple[ProjectID, dict[NodeID, Node]]:
53+
nodes = await coro
54+
return project_id, dict(nodes)
55+
56+
5157
async def _get_projects_metadata(
5258
app: web.Application,
5359
project_uuids: list[ProjectID],
@@ -253,12 +259,6 @@ async def list_computations_latest_iteration_tasks(
253259
# Fetch projects metadata concurrently
254260
# NOTE: MD: can be improved with a single batch call
255261

256-
async def _wrap_with_id(
257-
project_id: ProjectID, coro: Awaitable[list[tuple[NodeID, Node]]]
258-
) -> tuple[ProjectID, dict[NodeID, Node]]:
259-
nodes = await coro
260-
return project_id, dict(nodes)
261-
262262
results = await limited_gather(
263263
*[
264264
_wrap_with_id(project_uuid, get_by_project(app, project_id=project_uuid))
@@ -299,7 +299,7 @@ async def _wrap_with_id(
299299
ended_at=item.ended_at,
300300
log_download_link=item.log_download_link,
301301
node_name=project_uuid_to_workbench[item.project_uuid][item.node_id].label
302-
or "",
302+
or "Unknown",
303303
osparc_credits=credits_or_none,
304304
)
305305
for item, credits_or_none in zip(
@@ -421,15 +421,16 @@ async def list_computation_collection_run_tasks(
421421
# Get unique set of all project_uuids from comp_tasks
422422
unique_project_uuids = {task.project_uuid for task in _tasks_get.items}
423423
# NOTE: MD: can be improved with a single batch call
424-
project_dicts = await limited_gather(
424+
results = await limited_gather(
425425
*[
426-
get_project_dict_legacy(app, project_uuid=project_uuid)
426+
_wrap_with_id(project_uuid, get_by_project(app, project_id=project_uuid))
427427
for project_uuid in unique_project_uuids
428428
],
429429
limit=20,
430430
)
431+
431432
# Build a dict: project_uuid -> workbench
432-
project_uuid_to_workbench = {prj["uuid"]: prj["workbench"] for prj in project_dicts}
433+
project_uuid_to_workbench: dict[ProjectID, dict[NodeID, Node]] = dict(results)
433434

434435
# Fetch projects metadata concurrently
435436
_projects_metadata = await _get_projects_metadata(
@@ -466,9 +467,7 @@ async def list_computation_collection_run_tasks(
466467
log_download_link=item.log_download_link,
467468
name=(
468469
custom_metadata.get("job_name")
469-
or project_uuid_to_workbench[f"{item.project_uuid}"][
470-
f"{item.node_id}"
471-
].get("label")
470+
or project_uuid_to_workbench[item.project_uuid][item.node_id].label
472471
or "Unknown"
473472
),
474473
osparc_credits=credits_or_none,

0 commit comments

Comments
 (0)