Skip to content

Commit 6c1074a

Browse files
committed
same in storage service
1 parent c862398 commit 6c1074a

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

services/storage/src/simcore_service_storage/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
MAX_CONCURRENT_REST_CALLS: Final[int] = 10
4040

4141
# DATABASE ----------------------------
42-
APP_DB_ENGINE_KEY = f"{__name__}.db_engine"
42+
APP_AIOPG_ENGINE_KEY = f"{__name__}.aiopg_engine"
4343
MAX_CONCURRENT_DB_TASKS: Final[int] = 2
4444

4545
# DATA STORAGE MANAGER ----------------------------------

services/storage/src/simcore_service_storage/db.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
from aiohttp import web
55
from aiopg.sa import Engine
6+
from aiopg.sa.engine import Engine
67
from servicelib.aiohttp.aiopg_utils import is_pg_responsive
78
from servicelib.common_aiopg_utils import DataSourceName, create_pg_engine
89
from servicelib.retry_policies import PostgresRetryPolicyUponInitialization
@@ -13,7 +14,7 @@
1314
)
1415
from tenacity import retry
1516

16-
from .constants import APP_CONFIG_KEY, APP_DB_ENGINE_KEY
17+
from .constants import APP_AIOPG_ENGINE_KEY, APP_CONFIG_KEY
1718

1819
_logger = logging.getLogger(__name__)
1920

@@ -46,7 +47,8 @@ async def postgres_cleanup_ctx(app: web.Application):
4647
) as engine:
4748

4849
assert engine # nosec
49-
app[APP_DB_ENGINE_KEY] = engine
50+
app[APP_AIOPG_ENGINE_KEY] = engine
51+
5052
_logger.info("Created pg engine for %s", dsn)
5153
yield # ----------
5254
_logger.info("Deleting pg engine for %s", dsn)
@@ -55,19 +57,19 @@ async def postgres_cleanup_ctx(app: web.Application):
5557

5658
async def is_service_responsive(app: web.Application) -> bool:
5759
"""Returns true if the app can connect to db service"""
58-
return await is_pg_responsive(engine=app[APP_DB_ENGINE_KEY])
60+
return await is_pg_responsive(engine=app[APP_AIOPG_ENGINE_KEY])
5961

6062

6163
def get_engine_state(app: web.Application) -> dict[str, Any]:
62-
engine: Engine | None = app.get(APP_DB_ENGINE_KEY)
64+
engine: Engine | None = app.get(APP_AIOPG_ENGINE_KEY)
6365
if engine:
6466
engine_info: dict[str, Any] = get_pg_engine_stateinfo(engine)
6567
return engine_info
6668
return {}
6769

6870

6971
def setup_db(app: web.Application):
70-
app[APP_DB_ENGINE_KEY] = None
72+
app[APP_AIOPG_ENGINE_KEY] = None
7173

7274
# app is created at this point but not yet started
7375
_logger.debug("Setting up %s [service: %s] ...", __name__, "postgres")

services/storage/src/simcore_service_storage/db_tokens.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from models_library.users import UserID
88
from simcore_postgres_database.storage_models import tokens
99

10-
from .constants import APP_CONFIG_KEY, APP_DB_ENGINE_KEY
10+
from .constants import APP_AIOPG_ENGINE_KEY, APP_CONFIG_KEY
1111

1212
log = logging.getLogger(__name__)
1313

@@ -27,7 +27,7 @@ async def get_api_token_and_secret(
2727
app: web.Application, user_id: UserID
2828
) -> tuple[str, str]:
2929
# from the client side together with the userid?
30-
engine = app[APP_DB_ENGINE_KEY]
30+
engine = app[APP_AIOPG_ENGINE_KEY]
3131

3232
# defaults from config if any, othewise None
3333
api_token = app[APP_CONFIG_KEY].BF_API_KEY

services/storage/src/simcore_service_storage/simcore_s3_dsm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838

3939
from . import db_file_meta_data, db_projects, db_tokens
4040
from .constants import (
41+
APP_AIOPG_ENGINE_KEY,
4142
APP_CONFIG_KEY,
42-
APP_DB_ENGINE_KEY,
4343
DATCORE_ID,
4444
EXPAND_DIR_MAX_ITEM_COUNT,
4545
MAX_CONCURRENT_S3_TASKS,
@@ -1084,7 +1084,7 @@ def create_simcore_s3_data_manager(app: web.Application) -> SimcoreS3DataManager
10841084
cfg: Settings = app[APP_CONFIG_KEY]
10851085
assert cfg.STORAGE_S3 # nosec
10861086
return SimcoreS3DataManager(
1087-
engine=app[APP_DB_ENGINE_KEY],
1087+
engine=app[APP_AIOPG_ENGINE_KEY],
10881088
simcore_bucket_name=parse_obj_as(S3BucketName, cfg.STORAGE_S3.S3_BUCKET_NAME),
10891089
app=app,
10901090
settings=cfg,

0 commit comments

Comments
 (0)