Skip to content

Commit e22f580

Browse files
fix
1 parent fbb6cac commit e22f580

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ async def create_comp_run_collection(
3232
)
3333
.returning(comp_runs_collections.c.collection_run_id)
3434
)
35-
collection_id_tuple: tuple[UUID] = await result.first()
35+
collection_id_tuple: tuple[UUID] = result.one()
3636
return TypeAdapter(CollectionRunID).validate_python(collection_id_tuple[0])
3737

3838

@@ -44,7 +44,7 @@ async def get_comp_run_collection_or_none_by_id(
4444
comp_runs_collections.c.collection_run_id == f"{collection_run_id}"
4545
)
4646
)
47-
row = await result.first()
47+
row = result.one_or_none()
4848
if row is None:
4949
return None
5050
return CompRunCollectionDBGet.model_validate(row)
@@ -59,7 +59,7 @@ async def get_comp_run_collection_or_none_by_client_generated_id(
5959
== client_or_system_generated_id
6060
)
6161
)
62-
row = await result.one_or_none()
62+
row = result.one_or_none()
6363
if row is None:
6464
return None
6565
return CompRunCollectionDBGet.model_validate(row)

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
from aiohttp import web
44
from models_library.computations import CollectionRunID
5+
from simcore_postgres_database.utils_repos import transaction_context
56

6-
from ..db.plugin import get_database_engine_legacy
7+
from ..db.plugin import get_asyncpg_engine
78
from . import _comp_runs_collections_repository
89
from ._comp_runs_collections_models import CompRunCollectionDBGet
910

@@ -17,8 +18,7 @@ async def create_comp_run_collection(
1718
client_or_system_generated_display_name: str,
1819
is_generated_by_system: bool,
1920
) -> CollectionRunID:
20-
"""raises: ProjectNotFoundError"""
21-
async with get_database_engine_legacy(app).acquire() as conn:
21+
async with transaction_context(get_asyncpg_engine(app)) as conn:
2222
return await _comp_runs_collections_repository.create_comp_run_collection(
2323
conn=conn,
2424
client_or_system_generated_id=client_or_system_generated_id,
@@ -30,7 +30,7 @@ async def create_comp_run_collection(
3030
async def get_comp_run_collection_or_none_by_id(
3131
app: web.Application, *, collection_run_id: CollectionRunID
3232
) -> CompRunCollectionDBGet | None:
33-
async with get_database_engine_legacy(app).acquire() as conn:
33+
async with transaction_context(get_asyncpg_engine(app)) as conn:
3434
return await _comp_runs_collections_repository.get_comp_run_collection_or_none_by_id(
3535
conn=conn, collection_run_id=collection_run_id
3636
)
@@ -41,7 +41,7 @@ async def get_comp_run_collection_or_none_by_client_generated_id(
4141
*,
4242
client_or_system_generated_id: str,
4343
) -> CompRunCollectionDBGet | None:
44-
async with get_database_engine_legacy(app).acquire() as conn:
44+
async with transaction_context(get_asyncpg_engine(app)) as conn:
4545
return await _comp_runs_collections_repository.get_comp_run_collection_or_none_by_client_generated_id(
4646
conn=conn, client_or_system_generated_id=client_or_system_generated_id
4747
)

0 commit comments

Comments
 (0)