Skip to content

Commit e6f5baa

Browse files
committed
🎨 Refactor application initialization functions for improved clarity and organization
1 parent 45a1a99 commit e6f5baa

File tree

2 files changed

+20
-27
lines changed

2 files changed

+20
-27
lines changed

services/web/server/src/simcore_service_webserver/application.py

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,6 @@ async def _finished_banner(app: web.Application):
7272
print(info.get_finished_banner(), flush=True) # noqa: T201
7373

7474

75-
def create_application_auth() -> web.Application:
76-
app = create_safe_application()
77-
setup_settings(app)
78-
79-
setup_db(app)
80-
setup_session(app)
81-
setup_security(app)
82-
setup_rest(app)
83-
84-
# NOTE: *last* events
85-
app.on_startup.append(_welcome_banner)
86-
app.on_shutdown.append(_finished_banner)
87-
88-
_logger.debug("Routes in app: \n %s", pformat(app.router.named_resources()))
89-
90-
return app
91-
92-
9375
def create_application() -> web.Application:
9476
"""
9577
Initializes service
@@ -187,6 +169,24 @@ def create_application() -> web.Application:
187169
return app
188170

189171

172+
def create_application_authz() -> web.Application:
173+
app = create_safe_application()
174+
setup_settings(app)
175+
176+
setup_db(app)
177+
setup_session(app)
178+
setup_security(app)
179+
setup_rest(app)
180+
181+
# NOTE: *last* events
182+
app.on_startup.append(_welcome_banner)
183+
app.on_shutdown.append(_finished_banner)
184+
185+
_logger.debug("Routes in this app: \n %s", pformat(app.router.named_resources()))
186+
187+
return app
188+
189+
190190
def run_service(app: web.Application, config: dict[str, Any]):
191191
web.run_app(
192192
app,
@@ -195,9 +195,3 @@ def run_service(app: web.Application, config: dict[str, Any]):
195195
# this gets overriden by the gunicorn config in /docker/boot.sh
196196
access_log_format='%a %t "%r" %s %b --- [%Dus] "%{Referer}i" "%{User-Agent}i"',
197197
)
198-
199-
200-
__all__: tuple[str, ...] = (
201-
"create_application",
202-
"run_service",
203-
)

services/web/server/src/simcore_service_webserver/cli.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
""" Application's command line .
1+
"""Application's command line .
22
33
Why does this file exist, and why not put this in __main__?
44
@@ -15,13 +15,12 @@
1515

1616
import logging
1717
import os
18-
from typing import Final
18+
from typing import Annotated, Final
1919

2020
import typer
2121
from aiohttp import web
2222
from common_library.json_serialization import json_dumps
2323
from settings_library.utils_cli import create_settings_command
24-
from typing_extensions import Annotated
2524

2625
from .application_settings import ApplicationSettings
2726
from .login import cli as login_cli

0 commit comments

Comments
 (0)