Skip to content

Commit c7ac51b

Browse files
Performance improvement, allow functions to run in parallel rather than in the async event loop
It is because the underlying calls are synchronous by nature, in FastAPI endpoints marked with async are always ran in the eventloop even when blocking, when non async it attempts to coalasce and run requests in threads
1 parent 875811e commit c7ac51b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/service_ml_forecast/api/model_config_route.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
)
5858
@realm_accessible
5959
@roles_allowed(resource=OPENREMOTE_KC_RESOURCE, roles=[ClientRoles.WRITE_ADMIN_ROLE])
60-
async def create_model_config(
60+
def create_model_config(
6161
user: Annotated[UserContext, Depends(KeycloakMiddleware.get_user_context)],
6262
realm: str,
6363
model_config: ModelConfig,
@@ -78,7 +78,7 @@ async def create_model_config(
7878
)
7979
@realm_accessible
8080
@roles_allowed(resource=OPENREMOTE_KC_RESOURCE, roles=[ClientRoles.READ_ADMIN_ROLE])
81-
async def get_model_config(
81+
def get_model_config(
8282
user: Annotated[UserContext, Depends(KeycloakMiddleware.get_user_context)],
8383
realm: str,
8484
id: UUID,
@@ -98,7 +98,7 @@ async def get_model_config(
9898
)
9999
@realm_accessible
100100
@roles_allowed(resource=OPENREMOTE_KC_RESOURCE, roles=[ClientRoles.READ_ADMIN_ROLE])
101-
async def get_model_configs(
101+
def get_model_configs(
102102
user: Annotated[UserContext, Depends(KeycloakMiddleware.get_user_context)],
103103
realm: str,
104104
config_service: ModelConfigService = Depends(get_config_service),
@@ -118,7 +118,7 @@ async def get_model_configs(
118118
)
119119
@realm_accessible
120120
@roles_allowed(resource=OPENREMOTE_KC_RESOURCE, roles=[ClientRoles.WRITE_ADMIN_ROLE])
121-
async def update_model_config(
121+
def update_model_config(
122122
user: Annotated[UserContext, Depends(KeycloakMiddleware.get_user_context)],
123123
realm: str,
124124
id: UUID,
@@ -143,7 +143,7 @@ async def update_model_config(
143143
)
144144
@realm_accessible
145145
@roles_allowed(resource=OPENREMOTE_KC_RESOURCE, roles=[ClientRoles.WRITE_ADMIN_ROLE])
146-
async def delete_model_config(
146+
def delete_model_config(
147147
user: Annotated[UserContext, Depends(KeycloakMiddleware.get_user_context)],
148148
realm: str,
149149
id: UUID,

src/service_ml_forecast/api/web_route.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
HTTPStatus.NOT_FOUND: {"description": "Index.html file not found"},
4949
},
5050
)
51-
async def serve_index() -> FileResponse:
51+
def serve_index() -> FileResponse:
5252
"""Serve the index.html file from the web dist directory."""
5353

5454
index_path = DIRS.ML_WEBSERVER_UI_DIST_DIR / "index.html"
@@ -65,7 +65,7 @@ async def serve_index() -> FileResponse:
6565
HTTPStatus.NOT_FOUND: {"description": "Static file not found"},
6666
},
6767
)
68-
async def serve_spa(path: str) -> FileResponse:
68+
def serve_spa(path: str) -> FileResponse:
6969
"""Serve static files or return index.html for SPA routing."""
7070

7171
requested_path = DIRS.ML_WEBSERVER_UI_DIST_DIR / path

0 commit comments

Comments
 (0)