Skip to content

Commit dde9914

Browse files
committed
rename and doc
1 parent 7f78cb5 commit dde9914

File tree

22 files changed

+48
-39
lines changed

22 files changed

+48
-39
lines changed

packages/postgres-database/src/simcore_postgres_database/errors.py renamed to packages/postgres-database/src/simcore_postgres_database/aiopg_errors.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
"""aiopg errors
22
3+
WARNING: these errors are not raised by asyncpg. Therefore all code using new sqlalchemy.ext.asyncio
4+
MUST use instead import sqlalchemy.exc exceptions!!!!
5+
36
StandardError
47
|__ Warning
58
|__ Error

packages/postgres-database/src/simcore_postgres_database/utils_payments.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from aiopg.sa.connection import SAConnection
99
from aiopg.sa.result import ResultProxy, RowProxy
1010

11-
from . import errors
11+
from . import aiopg_errors
1212
from .models.payments_transactions import PaymentTransactionState, payments_transactions
1313

1414
_logger = logging.getLogger(__name__)
@@ -29,16 +29,13 @@ def __bool__(self):
2929
return False
3030

3131

32-
class PaymentAlreadyExists(PaymentFailure):
33-
...
32+
class PaymentAlreadyExists(PaymentFailure): ...
3433

3534

36-
class PaymentNotFound(PaymentFailure):
37-
...
35+
class PaymentNotFound(PaymentFailure): ...
3836

3937

40-
class PaymentAlreadyAcked(PaymentFailure):
41-
...
38+
class PaymentAlreadyAcked(PaymentFailure): ...
4239

4340

4441
async def insert_init_payment_transaction(
@@ -69,7 +66,7 @@ async def insert_init_payment_transaction(
6966
initiated_at=initiated_at,
7067
)
7168
)
72-
except errors.UniqueViolation:
69+
except aiopg_errors.UniqueViolation:
7370
return PaymentAlreadyExists(payment_id)
7471

7572
return payment_id

packages/postgres-database/src/simcore_postgres_database/utils_projects_metadata.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pydantic import BaseModel, ConfigDict
1010
from sqlalchemy.dialects.postgresql import insert as pg_insert
1111

12-
from .errors import ForeignKeyViolation
12+
from .aiopg_errors import ForeignKeyViolation
1313
from .models.projects import projects
1414
from .models.projects_metadata import projects_metadata
1515

@@ -33,11 +33,15 @@ class DBProjectInvalidAncestorsError(BaseProjectsMetadataError):
3333

3434

3535
class DBProjectInvalidParentProjectError(BaseProjectsMetadataError):
36-
msg_template: str = "Project project_uuid={project_uuid!r} has invalid parent project uuid={parent_project_uuid!r}"
36+
msg_template: str = (
37+
"Project project_uuid={project_uuid!r} has invalid parent project uuid={parent_project_uuid!r}"
38+
)
3739

3840

3941
class DBProjectInvalidParentNodeError(BaseProjectsMetadataError):
40-
msg_template: str = "Project project_uuid={project_uuid!r} has invalid parent project uuid={parent_node_id!r}"
42+
msg_template: str = (
43+
"Project project_uuid={project_uuid!r} has invalid parent project uuid={parent_node_id!r}"
44+
)
4145

4246

4347
#

packages/postgres-database/src/simcore_postgres_database/utils_projects_nodes.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from pydantic import BaseModel, ConfigDict, Field
1010
from sqlalchemy.dialects.postgresql import insert as pg_insert
1111

12-
from .errors import ForeignKeyViolation, UniqueViolation
12+
from .aiopg_errors import ForeignKeyViolation, UniqueViolation
1313
from .models.projects_node_to_pricing_unit import projects_node_to_pricing_unit
1414
from .models.projects_nodes import projects_nodes
1515

@@ -30,11 +30,15 @@ class ProjectNodesNodeNotFoundError(BaseProjectNodesError):
3030

3131

3232
class ProjectNodesNonUniqueNodeFoundError(BaseProjectNodesError):
33-
msg_template: str = "Multiple project found containing node {node_id}. TIP: misuse, the same node ID was found in several projects."
33+
msg_template: str = (
34+
"Multiple project found containing node {node_id}. TIP: misuse, the same node ID was found in several projects."
35+
)
3436

3537

3638
class ProjectNodesDuplicateNodeError(BaseProjectNodesError):
37-
msg_template: str = "Project node already exists, you cannot have 2x the same node in the same project."
39+
msg_template: str = (
40+
"Project node already exists, you cannot have 2x the same node in the same project."
41+
)
3842

3943

4044
class ProjectNodeCreate(BaseModel):

packages/postgres-database/src/simcore_postgres_database/utils_users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from aiopg.sa.result import RowProxy
1313
from sqlalchemy import Column
1414

15-
from .errors import UniqueViolation
15+
from .aiopg_errors import UniqueViolation
1616
from .models.users import UserRole, UserStatus, users
1717
from .models.users_details import users_pre_registration_details
1818

packages/postgres-database/tests/test_clusters.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from aiopg.sa.engine import Engine
1010
from aiopg.sa.result import ResultProxy
1111
from pytest_simcore.helpers.faker_factories import random_user
12-
from simcore_postgres_database.errors import ForeignKeyViolation, NotNullViolation
12+
from simcore_postgres_database.aiopg_errors import ForeignKeyViolation, NotNullViolation
1313
from simcore_postgres_database.models.cluster_to_groups import cluster_to_groups
1414
from simcore_postgres_database.models.clusters import ClusterType, clusters
1515
from simcore_postgres_database.models.users import users
@@ -41,7 +41,7 @@ async def user_group_id(aiopg_engine: Engine, user_id: int) -> int:
4141

4242

4343
async def test_cluster_without_owner_forbidden(
44-
create_fake_cluster: Callable[..., Awaitable[int]]
44+
create_fake_cluster: Callable[..., Awaitable[int]],
4545
):
4646
with pytest.raises(NotNullViolation):
4747
await create_fake_cluster()

packages/postgres-database/tests/test_models_payments_methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from aiopg.sa.result import RowProxy
1111
from faker import Faker
1212
from pytest_simcore.helpers.faker_factories import random_payment_method
13-
from simcore_postgres_database.errors import UniqueViolation
13+
from simcore_postgres_database.aiopg_errors import UniqueViolation
1414
from simcore_postgres_database.models.payments_methods import (
1515
InitPromptAckFlowState,
1616
payments_methods,

packages/postgres-database/tests/test_services_consume_filetypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
FAKE_FILE_CONSUMER_SERVICES,
1616
list_supported_filetypes,
1717
)
18-
from simcore_postgres_database.errors import CheckViolation
18+
from simcore_postgres_database.aiopg_errors import CheckViolation
1919
from simcore_postgres_database.models.services import services_meta_data
2020
from simcore_postgres_database.models.services_consume_filetypes import (
2121
services_consume_filetypes,

packages/postgres-database/tests/test_users.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
from aiopg.sa.result import ResultProxy, RowProxy
1212
from faker import Faker
1313
from pytest_simcore.helpers.faker_factories import random_user
14-
from simcore_postgres_database.errors import InvalidTextRepresentation, UniqueViolation
14+
from simcore_postgres_database.aiopg_errors import (
15+
InvalidTextRepresentation,
16+
UniqueViolation,
17+
)
1518
from simcore_postgres_database.models.users import UserRole, UserStatus, users
1619
from simcore_postgres_database.utils_users import (
1720
UsersRepo,

services/api-server/src/simcore_service_api_server/db/repositories/api_keys.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import sqlalchemy as sa
55
from models_library.products import ProductName
66
from pydantic.types import PositiveInt
7-
from simcore_postgres_database.errors import DatabaseError
7+
from simcore_postgres_database.aiopg_errors import DatabaseError
88

99
from .. import tables as tbl
1010
from ._base import BaseRepository

0 commit comments

Comments
 (0)