Skip to content

Commit 3ee4fd9

Browse files
committed
Merge branch 'master' into mai/pydantic-upgrade-repo-wide
2 parents 4d7efc8 + 2bdc986 commit 3ee4fd9

File tree

5 files changed

+267
-6
lines changed

5 files changed

+267
-6
lines changed

api/specs/web-server/_computations.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
from models_library.api_schemas_webserver.computations import (
77
ComputationCollectionRunListQueryParams,
88
ComputationCollectionRunPathParams,
9+
ComputationCollectionRunRestGet,
910
ComputationCollectionRunTaskListQueryParams,
11+
ComputationCollectionRunTaskRestGet,
1012
ComputationGet,
1113
ComputationPathParams,
1214
ComputationRunIterationsLatestListQueryParams,
@@ -102,7 +104,7 @@ async def list_computations_latest_iteration_tasks(
102104

103105
@router.get(
104106
"/computation-collection-runs",
105-
response_model=Page[ComputationTaskRestGet],
107+
response_model=Page[ComputationCollectionRunRestGet],
106108
)
107109
async def list_computation_collection_runs(
108110
_query: Annotated[as_query(ComputationCollectionRunListQueryParams), Depends()],
@@ -111,7 +113,7 @@ async def list_computation_collection_runs(
111113

112114
@router.get(
113115
"/computation-collection-runs/{collection_run_id}/tasks",
114-
response_model=Page[ComputationTaskRestGet],
116+
response_model=Page[ComputationCollectionRunTaskRestGet],
115117
)
116118
async def list_computation_collection_run_tasks(
117119
_query: Annotated[as_query(ComputationCollectionRunTaskListQueryParams), Depends()],

services/director-v2/src/simcore_service_director_v2/api/rpc/_computations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ async def list_computation_collection_runs_page(
114114
collection_run_ids = await comp_runs_repo.list_all_collection_run_ids_for_user_currently_running_computations(
115115
product_name=product_name, user_id=user_id
116116
)
117+
if collection_run_ids == []:
118+
return ComputationCollectionRunRpcGetPage(items=[], total=0)
117119

118120
total, comp_runs_output = await comp_runs_repo.list_group_by_collection_run_id(
119121
product_name=product_name,

services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_runs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,13 @@ async def list_group_by_collection_run_id(
458458
& (comp_runs.c.metadata["product_name"].astext == product_name)
459459
)
460460

461-
if project_ids_or_none:
461+
if project_ids_or_none is not None:
462462
base_select_query = base_select_query.where(
463463
comp_runs.c.project_uuid.in_(
464464
[f"{project_id}" for project_id in project_ids_or_none]
465465
)
466466
)
467-
if collection_run_ids_or_none:
467+
if collection_run_ids_or_none is not None:
468468
base_select_query = base_select_query.where(
469469
comp_runs.c.collection_run_id.in_(
470470
[

services/director-v2/tests/unit/with_dbs/comp_scheduler/test_api_rpc_computations.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,3 +341,82 @@ async def test_rpc_list_computation_collection_runs_page_and_collection_run_task
341341
assert len(output.items) == 1
342342
assert isinstance(output, ComputationCollectionRunRpcGetPage)
343343
assert len(output.items[0].project_ids) == 2
344+
345+
346+
async def test_rpc_list_computation_collection_runs_empty_ids_when_user_has_already_run_history(
347+
fake_workbench_without_outputs: dict[str, Any], # <-- Has 4 nodes
348+
fake_workbench_adjacency: dict[str, Any],
349+
create_registered_user: Callable[..., dict[str, Any]],
350+
create_project: Callable[..., Awaitable[ProjectAtDB]],
351+
create_pipeline: Callable[..., Awaitable[CompPipelineAtDB]],
352+
create_tasks_from_project: Callable[..., Awaitable[list[CompTaskAtDB]]],
353+
create_comp_run_snapshot_tasks: Callable[
354+
..., Awaitable[list[CompRunSnapshotTaskDBGet]]
355+
],
356+
create_comp_run: Callable[..., Awaitable[CompRunsAtDB]],
357+
rpc_client: RabbitMQRPCClient,
358+
faker: Faker,
359+
with_product: dict[str, Any],
360+
):
361+
user = create_registered_user()
362+
proj = await create_project(user, workbench=fake_workbench_without_outputs)
363+
364+
await create_pipeline(
365+
project_id=f"{proj.uuid}",
366+
dag_adjacency_list=fake_workbench_adjacency,
367+
)
368+
await create_tasks_from_project(
369+
user=user, project=proj, state=RunningState.SUCCESS, progress=None
370+
)
371+
run = await create_comp_run(
372+
user=user,
373+
project=proj,
374+
result=RunningState.SUCCESS,
375+
started=datetime.now(tz=UTC) - timedelta(minutes=120),
376+
ended=datetime.now(tz=UTC) - timedelta(minutes=100),
377+
iteration=1,
378+
dag_adjacency_list=fake_workbench_adjacency,
379+
)
380+
await create_comp_run_snapshot_tasks(
381+
user=user,
382+
project=proj,
383+
run_id=run.run_id,
384+
)
385+
386+
output = await rpc_computations.list_computation_collection_runs_page(
387+
rpc_client, product_name="osparc", user_id=user["id"], project_ids=None
388+
)
389+
assert output.total == 1
390+
assert len(output.items) == 1
391+
assert isinstance(output, ComputationCollectionRunRpcGetPage)
392+
393+
# Test filtering only running collection runs
394+
output = await rpc_computations.list_computation_collection_runs_page(
395+
rpc_client,
396+
product_name="osparc",
397+
user_id=user["id"],
398+
project_ids=None,
399+
filter_only_running=True, # <-- This is the tested filter
400+
)
401+
assert output.total == 0
402+
assert len(output.items) == 0
403+
404+
405+
async def test_rpc_list_computation_collection_runs_empty_ids_when_user_do_not_have_run_history(
406+
create_registered_user: Callable[..., dict[str, Any]],
407+
rpc_client: RabbitMQRPCClient,
408+
with_product: dict[str, Any],
409+
):
410+
user = create_registered_user()
411+
412+
# Test with empty collection_run_ids
413+
output = await rpc_computations.list_computation_collection_runs_page(
414+
rpc_client,
415+
product_name="osparc",
416+
user_id=user["id"],
417+
project_ids=None,
418+
filter_only_running=True, # This will result in empty collection_run_ids
419+
)
420+
assert output.total == 0
421+
assert len(output.items) == 0
422+
assert isinstance(output, ComputationCollectionRunRpcGetPage)

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 180 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2820,7 +2820,7 @@ paths:
28202820
content:
28212821
application/json:
28222822
schema:
2823-
$ref: '#/components/schemas/Page_ComputationTaskRestGet_'
2823+
$ref: '#/components/schemas/Page_ComputationCollectionRunRestGet_'
28242824
/v0/computation-collection-runs/{collection_run_id}/tasks:
28252825
get:
28262826
tags:
@@ -2856,7 +2856,7 @@ paths:
28562856
content:
28572857
application/json:
28582858
schema:
2859-
$ref: '#/components/schemas/Page_ComputationTaskRestGet_'
2859+
$ref: '#/components/schemas/Page_ComputationCollectionRunTaskRestGet_'
28602860
/v0/projects/{project_id}:xport:
28612861
post:
28622862
tags:
@@ -9384,6 +9384,108 @@ components:
93849384
required:
93859385
- version
93869386
title: CompatibleService
9387+
ComputationCollectionRunRestGet:
9388+
properties:
9389+
collectionRunId:
9390+
type: string
9391+
format: uuid
9392+
title: Collectionrunid
9393+
projectIds:
9394+
items:
9395+
type: string
9396+
type: array
9397+
title: Projectids
9398+
state:
9399+
$ref: '#/components/schemas/RunningState'
9400+
info:
9401+
type: object
9402+
title: Info
9403+
submittedAt:
9404+
type: string
9405+
format: date-time
9406+
title: Submittedat
9407+
startedAt:
9408+
anyOf:
9409+
- type: string
9410+
format: date-time
9411+
- type: 'null'
9412+
title: Startedat
9413+
endedAt:
9414+
anyOf:
9415+
- type: string
9416+
format: date-time
9417+
- type: 'null'
9418+
title: Endedat
9419+
name:
9420+
type: string
9421+
title: Name
9422+
type: object
9423+
required:
9424+
- collectionRunId
9425+
- projectIds
9426+
- state
9427+
- info
9428+
- submittedAt
9429+
- startedAt
9430+
- endedAt
9431+
- name
9432+
title: ComputationCollectionRunRestGet
9433+
ComputationCollectionRunTaskRestGet:
9434+
properties:
9435+
projectUuid:
9436+
type: string
9437+
format: uuid
9438+
title: Projectuuid
9439+
nodeId:
9440+
type: string
9441+
format: uuid
9442+
title: Nodeid
9443+
state:
9444+
$ref: '#/components/schemas/RunningState'
9445+
progress:
9446+
type: number
9447+
title: Progress
9448+
image:
9449+
type: object
9450+
title: Image
9451+
startedAt:
9452+
anyOf:
9453+
- type: string
9454+
format: date-time
9455+
- type: 'null'
9456+
title: Startedat
9457+
endedAt:
9458+
anyOf:
9459+
- type: string
9460+
format: date-time
9461+
- type: 'null'
9462+
title: Endedat
9463+
logDownloadLink:
9464+
anyOf:
9465+
- type: string
9466+
- type: 'null'
9467+
title: Logdownloadlink
9468+
osparcCredits:
9469+
anyOf:
9470+
- type: string
9471+
- type: 'null'
9472+
title: Osparccredits
9473+
name:
9474+
type: string
9475+
title: Name
9476+
type: object
9477+
required:
9478+
- projectUuid
9479+
- nodeId
9480+
- state
9481+
- progress
9482+
- image
9483+
- startedAt
9484+
- endedAt
9485+
- logDownloadLink
9486+
- osparcCredits
9487+
- name
9488+
title: ComputationCollectionRunTaskRestGet
93879489
ComputationGet:
93889490
properties:
93899491
id:
@@ -13837,6 +13939,82 @@ components:
1383713939
- _links
1383813940
- data
1383913941
title: Page[CatalogLatestServiceGet]
13942+
Page_ComputationCollectionRunRestGet_:
13943+
properties:
13944+
items:
13945+
items:
13946+
$ref: '#/components/schemas/ComputationCollectionRunRestGet'
13947+
type: array
13948+
title: Items
13949+
total:
13950+
anyOf:
13951+
- type: integer
13952+
minimum: 0
13953+
- type: 'null'
13954+
title: Total
13955+
page:
13956+
anyOf:
13957+
- type: integer
13958+
minimum: 1
13959+
- type: 'null'
13960+
title: Page
13961+
size:
13962+
anyOf:
13963+
- type: integer
13964+
minimum: 1
13965+
- type: 'null'
13966+
title: Size
13967+
pages:
13968+
anyOf:
13969+
- type: integer
13970+
minimum: 0
13971+
- type: 'null'
13972+
title: Pages
13973+
type: object
13974+
required:
13975+
- items
13976+
- total
13977+
- page
13978+
- size
13979+
title: Page[ComputationCollectionRunRestGet]
13980+
Page_ComputationCollectionRunTaskRestGet_:
13981+
properties:
13982+
items:
13983+
items:
13984+
$ref: '#/components/schemas/ComputationCollectionRunTaskRestGet'
13985+
type: array
13986+
title: Items
13987+
total:
13988+
anyOf:
13989+
- type: integer
13990+
minimum: 0
13991+
- type: 'null'
13992+
title: Total
13993+
page:
13994+
anyOf:
13995+
- type: integer
13996+
minimum: 1
13997+
- type: 'null'
13998+
title: Page
13999+
size:
14000+
anyOf:
14001+
- type: integer
14002+
minimum: 1
14003+
- type: 'null'
14004+
title: Size
14005+
pages:
14006+
anyOf:
14007+
- type: integer
14008+
minimum: 0
14009+
- type: 'null'
14010+
title: Pages
14011+
type: object
14012+
required:
14013+
- items
14014+
- total
14015+
- page
14016+
- size
14017+
title: Page[ComputationCollectionRunTaskRestGet]
1384014018
Page_ComputationRunRestGet_:
1384114019
properties:
1384214020
items:

0 commit comments

Comments
 (0)