Skip to content

Commit fa7bba0

Browse files
committed
deprecation warnings
1 parent afb1b7a commit fa7bba0

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
SEE https://www.postgresql.org/docs/current/errcodes-appendix.html
2222
"""
2323

24+
import warnings
25+
2426
# NOTE: psycopg2.errors are created dynamically
2527
# pylint: disable=no-name-in-module
2628
from psycopg2 import (
@@ -46,6 +48,19 @@
4648

4749
assert issubclass(UniqueViolation, IntegrityError) # nosec
4850

51+
52+
warnings.warn(
53+
(
54+
"DEPRECATED: The aiopg DBAPI exceptions in this module are no longer used. "
55+
"Please use exceptions from the `sqlalchemy.exc` module instead. "
56+
"See https://docs.sqlalchemy.org/en/21/core/exceptions.html for details. "
57+
"This change is part of the migration to SQLAlchemy async support with asyncpg. "
58+
"See migration issue: https://github.com/ITISFoundation/osparc-simcore/issues/4529"
59+
),
60+
DeprecationWarning,
61+
stacklevel=2,
62+
)
63+
4964
__all__: tuple[str, ...] = (
5065
"CheckViolation",
5166
"DatabaseError",

services/web/server/src/simcore_service_webserver/db/_aiopg.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"""
66

77
import logging
8+
import warnings
89
from collections.abc import AsyncIterator
910
from typing import Any, cast
1011

@@ -29,6 +30,16 @@
2930

3031
_logger = logging.getLogger(__name__)
3132

33+
warnings.warn(
34+
(
35+
"simcore_service_webserver.db._aiopg is deprecated and will be removed in a future release. "
36+
"Please use simcore_service_webserver.db._asyncpg instead. "
37+
"See migration details: https://github.com/ITISFoundation/osparc-simcore/issues/4529"
38+
),
39+
DeprecationWarning,
40+
stacklevel=2,
41+
)
42+
3243

3344
@retry(**PostgresRetryPolicyUponInitialization(_logger).kwargs)
3445
async def _ensure_pg_ready(

services/web/server/src/simcore_service_webserver/db/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
)
3636
def setup_db(app: web.Application):
3737

38-
# ensures keys exist
38+
# ensures keys exist DEPRECATED
3939
app[APP_AIOPG_ENGINE_KEY] = None
4040
assert get_database_engine_legacy(app) is None # nosec
4141

0 commit comments

Comments
 (0)