Skip to content

Commit dd3afe1

Browse files
committed
refactor: replace dynamic key generation with constant for SciCrunch instance retrieval
1 parent 38fe086 commit dd3afe1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

services/web/server/src/simcore_service_webserver/scicrunch/service_client.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ def acquire_instance(
6060
cls, app: web.Application, settings: SciCrunchSettings
6161
) -> "SciCrunch":
6262
"""Returns single instance for the application and stores it"""
63-
obj: SciCrunch | None = app.get(f"{__name__}.{cls.__name__}")
63+
obj: SciCrunch | None = app.get(_SCICRUNCH_KEYAPP)
6464
if obj is None:
6565
session = get_client_session(app)
66-
app[f"{__name__}.{cls.__name__}"] = obj = cls(session, settings)
66+
app[_SCICRUNCH_KEYAPP] = obj = cls(session, settings)
6767
return obj
6868

6969
@classmethod
7070
def get_instance(cls, app: web.Application) -> "SciCrunch":
71-
obj: SciCrunch | None = app.get(f"{__name__}.{cls.__name__}")
71+
obj: SciCrunch | None = app.get(_SCICRUNCH_KEYAPP)
7272
if obj is None:
7373
raise ScicrunchConfigError(
7474
details="Services on scicrunch.org are currently disabled"
@@ -171,3 +171,6 @@ async def search_resource(self, name_as: str) -> list[ResourceHit]:
171171
# Might be good to know that scicrunch.org is not reachable and cannot perform search now?
172172
hits = await autocomplete_by_name(name_as, self.client, self.settings)
173173
return hits.root
174+
175+
176+
_SCICRUNCH_KEYAPP = web.AppKey(SciCrunch.__name__, SciCrunch)

0 commit comments

Comments
 (0)