File tree Expand file tree Collapse file tree 3 files changed +22
-20
lines changed
packages/postgres-database/src/simcore_postgres_database
services/storage/src/simcore_service_storage Expand file tree Collapse file tree 3 files changed +22
-20
lines changed Original file line number Diff line number Diff line change 77from sqlalchemy .ext .asyncio import AsyncConnection
88
99from .models .projects import projects
10- from .utils_repos import transaction_context
10+ from .utils_repos import pass_or_acquire_connection , transaction_context
1111
1212
1313class DBBaseProjectError (OsparcErrorMixin , Exception ):
@@ -22,6 +22,23 @@ class ProjectsRepo:
2222 def __init__ (self , engine ):
2323 self .engine = engine
2424
25+ async def exists (
26+ self ,
27+ project_uuid : uuid .UUID ,
28+ * ,
29+ connection : AsyncConnection | None = None ,
30+ ) -> bool :
31+ async with pass_or_acquire_connection (self .engine , connection ) as conn :
32+ return (
33+ await conn .scalar (
34+ sa .select (1 )
35+ .select_from (projects )
36+ .where (projects .c .uuid == project_uuid )
37+ .limit (1 )
38+ )
39+ is not None
40+ )
41+
2542 async def get_project_last_change_date (
2643 self ,
2744 project_uuid : uuid .UUID ,
Original file line number Diff line number Diff line change @@ -33,22 +33,6 @@ async def list_valid_projects_in(
3333 with suppress (ValidationError ):
3434 yield ProjectAtDB .model_validate (row )
3535
36- async def project_exists (
37- self ,
38- * ,
39- connection : AsyncConnection | None = None ,
40- project_uuid : ProjectID ,
41- ) -> bool :
42- async with pass_or_acquire_connection (self .db_engine , connection ) as conn :
43- return bool (
44- await conn .scalar (
45- sa .select (sa .func .count ())
46- .select_from (projects )
47- .where (projects .c .uuid == f"{ project_uuid } " )
48- )
49- == 1
50- )
51-
5236 async def get_project_id_and_node_id_to_names_map (
5337 self ,
5438 * ,
Original file line number Diff line number Diff line change 4141from servicelib .logging_utils import log_context
4242from servicelib .progress_bar import ProgressBarData
4343from servicelib .utils import ensure_ends_with , limited_gather
44+ from simcore_postgres_database .utils_projects import ProjectsRepo
4445from simcore_postgres_database .utils_repos import transaction_context
4546from sqlalchemy .ext .asyncio import AsyncEngine
4647
@@ -792,9 +793,9 @@ async def deep_copy_project_simcore_s3(
792793 task_progress .description = "Checking study access rights..."
793794
794795 for prj_uuid in [src_project_uuid , dst_project_uuid ]:
795- if not await ProjectRepository . instance (
796- get_db_engine ( self . app )
797- ). project_exists ( project_uuid = prj_uuid ) :
796+ if not await ProjectsRepo ( get_db_engine ( self . app )). exists (
797+ project_uuid = prj_uuid
798+ ):
798799 raise ProjectNotFoundError (project_id = prj_uuid )
799800 source_access_rights = await AccessLayerRepository .instance (
800801 get_db_engine (self .app )
You can’t perform that action at this time.
0 commit comments