Skip to content

Commit d84efbf

Browse files
author
Andrei Neagu
committed
refactor to use settings instead of property name
1 parent b3bd6e6 commit d84efbf

File tree

3 files changed

+8
-17
lines changed
  • packages/service-library/src/servicelib/fastapi
  • services

3 files changed

+8
-17
lines changed

packages/service-library/src/servicelib/fastapi/docker.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,9 @@
2020

2121

2222
def get_lifespan_remote_docker_client(
23-
docker_api_proxy_settings_property_name: str,
23+
settings: DockerApiProxysettings,
2424
) -> LifespanGenerator:
25-
"""Ensures `setup` and `teardown` for the remote docker client.
26-
27-
Arguments:
28-
docker_api_proxy_settings_property_name -- if the name is `PROP_NAME`
29-
then it should be accessible as `app.state.settings.PROP_NAME`
30-
31-
Returns:
32-
docker client lifespan manager
33-
"""
34-
3525
async def _(app: FastAPI) -> AsyncIterator[State]:
36-
settings: DockerApiProxysettings = getattr(
37-
app.state.settings, docker_api_proxy_settings_property_name
38-
)
3926

4027
session: ClientSession | None = None
4128
if settings.DOCKER_API_PROXY_USER and settings.DOCKER_API_PROXY_PASSWORD:

services/docker-api-proxy/tests/integration/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ class ApplicationSetting(BaseApplicationSettings):
3939
Field(json_schema_extra={"auto_default_from_env": True}),
4040
]
4141

42+
settings = ApplicationSetting.create_from_envs()
43+
4244
app = FastAPI(
4345
lifespan=combine_lifespans(
44-
get_lifespan_remote_docker_client("DOCKER_API_PROXY")
46+
get_lifespan_remote_docker_client(settings.DOCKER_API_PROXY)
4547
)
4648
)
47-
app.state.settings = ApplicationSetting.create_from_envs()
49+
app.state.settings = settings
4850

4951
return app
5052

services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/core/application.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ def create_app(settings: ApplicationSettings | None = None) -> FastAPI:
5555
lifespan_service_tracker,
5656
lifespan_deferred_manager,
5757
lifespan_status_monitor,
58-
get_lifespan_remote_docker_client("DYNAMIC_SCHEDULER_DOCKER_API_PROXY"),
58+
get_lifespan_remote_docker_client(
59+
app_settings.DYNAMIC_SCHEDULER_DOCKER_API_PROXY
60+
),
5961
]
6062

6163
if app_settings.DYNAMIC_SCHEDULER_PROMETHEUS_INSTRUMENTATION_ENABLED:

0 commit comments

Comments
 (0)