-
Notifications
You must be signed in to change notification settings - Fork 32
♻️ Refactor groups/classifiers and scicrunch to use asyncpg with service/repository separation
#8433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pcrespov
merged 20 commits into
ITISFoundation:master
from
pcrespov:is4529/migrate-aiopg-to-asynpg-1
Sep 29, 2025
Merged
♻️ Refactor groups/classifiers and scicrunch to use asyncpg with service/repository separation
#8433
Changes from 12 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d61e95e
✨ [Service] Introduce GroupClassifierRepository and refactor related …
pcrespov 35c6278
rename
pcrespov 99c7bb6
✨ [Tests] Add random_group_classifier factory and related tests for G…
pcrespov 772bed7
wrong exceptions
pcrespov a117544
rename
pcrespov fb166e4
exposes interface
pcrespov ec78ff2
moving scicrungh unders the service layer
pcrespov 7281b1d
fixes error
pcrespov aec68f4
fix
pcrespov 251633d
mypy fix
pcrespov 555b07d
cleanup
pcrespov eca30ba
cleanup models
pcrespov bfd8972
rename
pcrespov b75387a
fake
pcrespov 64cf911
fixes
pcrespov 17ba3af
refactor: update scicrunch service integration and improve dependency…
pcrespov 9e90443
refactor: replace ScicrunchResourcesService with SCICRUNCH_SERVICE_AP…
pcrespov 4ef0000
@GitHK review: fix #5160
pcrespov 6982f42
fixes fomratting
pcrespov af4d430
fixes tests
pcrespov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
services/web/server/src/simcore_service_webserver/groups/_classifiers_repository.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import logging | ||
| from typing import Any | ||
|
|
||
| import sqlalchemy as sa | ||
| from simcore_postgres_database.models.classifiers import group_classifiers | ||
| from simcore_postgres_database.utils_repos import pass_or_acquire_connection | ||
| from sqlalchemy.engine import Row | ||
| from sqlalchemy.ext.asyncio import AsyncConnection | ||
|
|
||
| from ..db.base_repository import BaseRepository | ||
|
|
||
| _logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class GroupClassifierRepository(BaseRepository): | ||
|
|
||
| async def _get_bundle( | ||
| self, gid: int, connection: AsyncConnection | None = None | ||
| ) -> Row | None: | ||
| async with pass_or_acquire_connection(self.engine, connection) as conn: | ||
| result = await conn.execute( | ||
| sa.select(group_classifiers.c.bundle).where( | ||
| group_classifiers.c.gid == gid | ||
| ) | ||
| ) | ||
| return result.one_or_none() | ||
|
|
||
| async def get_classifiers_from_bundle(self, gid: int) -> dict[str, Any] | None: | ||
| bundle_row = await self._get_bundle(gid) | ||
| if bundle_row: | ||
| # pylint: disable=protected-access | ||
| return dict(bundle_row.bundle._mapping) # noqa: SLF001 | ||
| return None | ||
|
|
||
| async def group_uses_scicrunch( | ||
| self, gid: int, connection: AsyncConnection | None = None | ||
| ) -> bool: | ||
| async with pass_or_acquire_connection(self.engine, connection) as conn: | ||
| result = await conn.execute( | ||
| sa.select(group_classifiers.c.uses_scicrunch).where( | ||
| group_classifiers.c.gid == gid | ||
| ) | ||
| ) | ||
| row = result.one_or_none() | ||
| return bool(row.uses_scicrunch if row else False) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.