Skip to content

Commit f317b34

Browse files
Merge branch 'master' into extract-celery-code
2 parents bf18f60 + a5e90f2 commit f317b34

File tree

152 files changed

+1558
-1258
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+1558
-1258
lines changed

.github/workflows/ci-testing-deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2707,7 +2707,7 @@ jobs:
27072707
if: ${{ always() }}
27082708
needs:
27092709
[
2710-
system-test-e2e,
2710+
# system-test-e2e, NOTE: not required, until Odei will have a look
27112711
system-test-e2e-playwright,
27122712
system-test-environment-setup,
27132713
system-test-public-api,

.vscode/settings.template.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// This is a template. Clone and replace extension ".template.json" by ".json"
22
{
33
"autoDocstring.docstringFormat": "pep257",
4-
54
"editor.tabSize": 2,
65
"editor.insertSpaces": true,
76
"editor.detectIndentation": false,

api/specs/web-server/_long_running_tasks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def cancel_async_job(
6565

6666
@router.get(
6767
"/tasks/{task_id}/result",
68+
response_model=Any,
6869
name="get_task_result",
6970
description="Retrieves the result of a task",
7071
responses=_export_data_responses,

api/specs/web-server/_long_running_tasks_legacy.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# pylint: disable=too-many-arguments
55

66

7-
from typing import Annotated
7+
from typing import Annotated, Any
88

99
from fastapi import APIRouter, Depends, status
1010
from models_library.generics import Envelope
@@ -54,6 +54,7 @@ def cancel_and_delete_task(
5454
@router.get(
5555
"/{task_id}/result",
5656
name="get_task_result",
57+
response_model=Any,
5758
description="Retrieves the result of a task",
5859
)
5960
def get_task_result(

packages/models-library/src/models_library/api_schemas_long_running_tasks/tasks.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ class TaskResult(BaseModel):
1818
error: Any | None
1919

2020

21-
class TaskGet(BaseModel):
21+
class TaskBase(BaseModel):
2222
task_id: TaskId
2323
task_name: str
24+
25+
26+
class TaskGet(TaskBase):
2427
status_href: str
2528
result_href: str
2629
abort_href: str

packages/models-library/src/models_library/rest_error.py

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from common_library.basic_types import DEFAULT_FACTORY
55
from models_library.generics import Envelope
66
from pydantic import BaseModel, ConfigDict, Field
7+
from pydantic.config import JsonDict
78

89
from .basic_types import IDStr, LogLevel
910

@@ -72,39 +73,55 @@ class ErrorGet(BaseModel):
7273
description="Message displayed to the user",
7374
),
7475
]
76+
7577
support_id: Annotated[
7678
IDStr | None,
7779
Field(description="ID to track the incident during support", alias="supportId"),
7880
] = None
79-
status: int
8081

81-
# NOTE: The fields blow are DEPRECATED. Still here to keep compatibilty with front-end until updated
82+
status: Annotated[
83+
int,
84+
Field(
85+
description="Redundant HTTP status code of the error."
86+
"Must be the same as in the HTTP response"
87+
),
88+
]
89+
90+
# NOTE: The fields below are DEPRECATED.
91+
# Still here to keep compatibilty with front-end until updated
8292
errors: Annotated[
8393
list[ErrorItemType],
8494
Field(deprecated=True, default_factory=list, json_schema_extra={"default": []}),
8595
] = DEFAULT_FACTORY
96+
8697
logs: Annotated[
8798
list[LogMessageType],
8899
Field(deprecated=True, default_factory=list, json_schema_extra={"default": []}),
89100
] = DEFAULT_FACTORY
90101

102+
@staticmethod
103+
def _update_json_schema_extra(schema: JsonDict) -> None:
104+
schema.update(
105+
{
106+
"examples": [
107+
{
108+
"message": "Sorry you do not have sufficient access rights for product",
109+
"status": 401,
110+
},
111+
{
112+
"message": "Opps this error was unexpected. We are working on that!",
113+
"supportId": "OEC:12346789",
114+
"status": 500,
115+
},
116+
]
117+
}
118+
)
119+
91120
model_config = ConfigDict(
92121
populate_by_name=True,
93122
extra="ignore", # Used to prune extra fields from internal data
94123
frozen=True,
95-
json_schema_extra={
96-
"examples": [
97-
{
98-
"message": "Sorry you do not have sufficient access rights for product",
99-
"status": 401,
100-
},
101-
{
102-
"message": "Opps this error was unexpected. We are working on that!",
103-
"supportId": "OEC:12346789",
104-
"status": 500,
105-
},
106-
]
107-
},
124+
json_schema_extra=_update_json_schema_extra,
108125
)
109126

110127

packages/pytest-simcore/src/pytest_simcore/helpers/webserver_login.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
get_plugin_storage,
1818
)
1919
from simcore_service_webserver.products.products_service import list_products
20-
from simcore_service_webserver.security.api import clean_auth_policy_cache
20+
from simcore_service_webserver.security import security_service
2121
from yarl import URL
2222

2323
from .assert_checks import assert_status
@@ -187,7 +187,7 @@ async def __aexit__(self, *args):
187187
assert self.client.app
188188
# NOTE: cache key is based on an email. If the email is
189189
# reused during the test, then it creates quite some noise
190-
await clean_auth_policy_cache(self.client.app)
190+
await security_service.clean_auth_policy_cache(self.client.app)
191191
return await super().__aexit__(*args)
192192

193193

packages/service-library/src/servicelib/aiohttp/long_running_tasks/_constants.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
from pydantic import PositiveFloat
44

55
MINUTE: Final[PositiveFloat] = 60
6-
APP_LONG_RUNNING_TASKS_MANAGER_KEY: Final[
7-
str
8-
] = f"{__name__ }.long_running_tasks.tasks_manager"
9-
RQT_LONG_RUNNING_TASKS_CONTEXT_KEY: Final[
10-
str
11-
] = f"{__name__}.long_running_tasks.context"
6+
APP_LONG_RUNNING_MANAGER_KEY: Final[str] = (
7+
f"{__name__ }.long_running_tasks.tasks_manager"
8+
)
9+
RQT_LONG_RUNNING_TASKS_CONTEXT_KEY: Final[str] = (
10+
f"{__name__}.long_running_tasks.context"
11+
)

packages/service-library/src/servicelib/aiohttp/long_running_tasks/_dependencies.py

Lines changed: 0 additions & 23 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import datetime
2+
3+
from aiohttp import web
4+
5+
from ...long_running_tasks.base_long_running_manager import BaseLongRunningManager
6+
from ...long_running_tasks.task import TaskContext, TasksManager
7+
from ._constants import APP_LONG_RUNNING_MANAGER_KEY
8+
from ._request import get_task_context
9+
10+
11+
class AiohttpLongRunningManager(BaseLongRunningManager):
12+
def __init__(
13+
self,
14+
app: web.Application,
15+
stale_task_check_interval: datetime.timedelta,
16+
stale_task_detect_timeout: datetime.timedelta,
17+
):
18+
self._app = app
19+
self._tasks_manager = TasksManager(
20+
stale_task_check_interval=stale_task_check_interval,
21+
stale_task_detect_timeout=stale_task_detect_timeout,
22+
)
23+
24+
@property
25+
def tasks_manager(self) -> TasksManager:
26+
return self._tasks_manager
27+
28+
async def setup(self) -> None:
29+
await self._tasks_manager.setup()
30+
31+
async def teardown(self) -> None:
32+
await self._tasks_manager.teardown()
33+
34+
@staticmethod
35+
def get_task_context(request: web.Request) -> TaskContext:
36+
return get_task_context(request)
37+
38+
39+
def get_long_running_manager(app: web.Application) -> AiohttpLongRunningManager:
40+
output: AiohttpLongRunningManager = app[APP_LONG_RUNNING_MANAGER_KEY]
41+
return output

0 commit comments

Comments
 (0)