Skip to content

Commit a194300

Browse files
authored
♻️Dask sidecar: Glob error tests + autoscaling monitoring fix (#7650)
1 parent 2d0ae68 commit a194300

File tree

10 files changed

+168
-61
lines changed

10 files changed

+168
-61
lines changed

packages/pytest-simcore/src/pytest_simcore/aws_s3_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ async def s3_client(s3_settings: S3Settings) -> typing.AsyncIterator[S3Client]:
2525
exit_stack = contextlib.AsyncExitStack()
2626
session_client = session.client(
2727
"s3",
28-
endpoint_url=f"{s3_settings.S3_ENDPOINT}",
28+
endpoint_url=f"{s3_settings.S3_ENDPOINT}" if s3_settings.S3_ENDPOINT else None,
2929
aws_access_key_id=s3_settings.S3_ACCESS_KEY,
3030
aws_secret_access_key=s3_settings.S3_SECRET_KEY,
3131
region_name=s3_settings.S3_REGION,

packages/service-library/tests/aiohttp/test_tracing.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# pylint: disable=unused-variable
44

55
import importlib
6-
from collections.abc import Callable
7-
from typing import Any, Iterator
6+
from collections.abc import Callable, Iterator
7+
from typing import Any
88

99
import pip
1010
import pytest
@@ -92,6 +92,9 @@ def manage_package(request):
9292
uninstall_package(package)
9393

9494

95+
@pytest.mark.skip(
96+
reason="this test installs always the latest version of the package which creates conflicts."
97+
)
9598
@pytest.mark.parametrize(
9699
"tracing_settings_in, manage_package",
97100
[

packages/service-library/tests/fastapi/test_tracing.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import importlib
55
import random
66
import string
7-
from collections.abc import Callable
8-
from typing import Any, Iterator
7+
from collections.abc import Callable, Iterator
8+
from typing import Any
99

1010
import pip
1111
import pytest
@@ -115,6 +115,9 @@ def manage_package(request):
115115
uninstall_package(package)
116116

117117

118+
@pytest.mark.skip(
119+
reason="this test installs always the latest version of the package which creates conflicts."
120+
)
118121
@pytest.mark.parametrize(
119122
"tracing_settings_in, manage_package",
120123
[

scripts/maintenance/computational-clusters/autoscaled_monitor/dask.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def _list_tasks(
116116
list_of_tasks = await client.run_on_scheduler(_list_tasks) # type: ignore
117117
except TypeError:
118118
rich.print(
119-
f"ERROR while recoverring unrunnable tasks using {dask_client=}. Defaulting to empty list of tasks!!"
119+
"ERROR while recoverring unrunnable tasks . Defaulting to empty list of tasks!!"
120120
)
121121
return list_of_tasks
122122

@@ -126,12 +126,16 @@ async def get_scheduler_details(state: AppState, instance: Instance):
126126
datasets_on_cluster = ()
127127
processing_jobs = {}
128128
all_tasks = {}
129-
with contextlib.suppress(TimeoutError, OSError):
129+
try:
130130
async with dask_client(state, instance) as client:
131131
scheduler_info = client.scheduler_info()
132132
datasets_on_cluster = await _wrap_dask_async_call(client.list_datasets())
133133
processing_jobs = await _wrap_dask_async_call(client.processing())
134134
all_tasks = await _list_all_tasks(client)
135+
except (TimeoutError, OSError, TypeError):
136+
rich.print(
137+
"ERROR while recoverring scheduler details !! no scheduler info found!!"
138+
)
135139

136140
return scheduler_info, datasets_on_cluster, processing_jobs, all_tasks
137141

services/dask-sidecar/requirements/_test.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#
88
--constraint _base.txt
99

10-
10+
aioboto3
1111
coverage
1212
docker
1313
faker
@@ -22,4 +22,6 @@ pytest-mock
2222
pytest-sugar
2323
python-dotenv
2424
# mypy
25+
types-aioboto3
26+
types-aiobotocore[s3]
2527
types-aiofiles

services/dask-sidecar/requirements/_test.txt

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
aioboto3==14.1.0
2+
# via -r requirements/_test.in
3+
aiobotocore==2.21.1
4+
# via
5+
# -c requirements/_base.txt
6+
# aioboto3
7+
aiofiles==24.1.0
8+
# via
9+
# -c requirements/_base.txt
10+
# aioboto3
11+
aiohappyeyeballs==2.4.4
12+
# via
13+
# -c requirements/_base.txt
14+
# aiohttp
15+
aiohttp==3.11.18
16+
# via
17+
# -c requirements/../../../requirements/constraints.txt
18+
# -c requirements/_base.txt
19+
# aiobotocore
20+
aioitertools==0.12.0
21+
# via
22+
# -c requirements/_base.txt
23+
# aiobotocore
24+
aiosignal==1.3.1
25+
# via
26+
# -c requirements/_base.txt
27+
# aiohttp
128
annotated-types==0.7.0
229
# via
330
# -c requirements/_base.txt
@@ -7,6 +34,7 @@ antlr4-python3-runtime==4.13.2
734
attrs==24.2.0
835
# via
936
# -c requirements/_base.txt
37+
# aiohttp
1038
# jsonschema
1139
# referencing
1240
aws-sam-translator==1.95.0
@@ -17,15 +45,21 @@ blinker==1.9.0
1745
# via flask
1846
boto3==1.37.1
1947
# via
48+
# aiobotocore
2049
# aws-sam-translator
2150
# moto
2251
botocore==1.37.1
2352
# via
2453
# -c requirements/_base.txt
54+
# aiobotocore
2555
# aws-xray-sdk
2656
# boto3
2757
# moto
2858
# s3transfer
59+
botocore-stubs==1.38.11
60+
# via
61+
# types-aioboto3
62+
# types-aiobotocore
2963
certifi==2024.8.30
3064
# via
3165
# -c requirements/../../../requirements/constraints.txt
@@ -65,6 +99,11 @@ flask==3.1.0
6599
# moto
66100
flask-cors==5.0.1
67101
# via moto
102+
frozenlist==1.5.0
103+
# via
104+
# -c requirements/_base.txt
105+
# aiohttp
106+
# aiosignal
68107
graphql-core==3.2.6
69108
# via moto
70109
icdiff==2.0.7
@@ -73,6 +112,7 @@ idna==3.10
73112
# via
74113
# -c requirements/_base.txt
75114
# requests
115+
# yarl
76116
iniconfig==2.0.0
77117
# via pytest
78118
itsdangerous==2.2.0
@@ -86,6 +126,7 @@ jinja2==3.1.4
86126
jmespath==1.0.1
87127
# via
88128
# -c requirements/_base.txt
129+
# aiobotocore
89130
# boto3
90131
# botocore
91132
joserfc==1.0.4
@@ -120,6 +161,12 @@ moto==5.1.4
120161
# via -r requirements/_test.in
121162
mpmath==1.3.0
122163
# via sympy
164+
multidict==6.1.0
165+
# via
166+
# -c requirements/_base.txt
167+
# aiobotocore
168+
# aiohttp
169+
# yarl
123170
networkx==3.4.2
124171
# via cfn-lint
125172
openapi-schema-validator==0.6.3
@@ -139,6 +186,11 @@ ply==3.11
139186
# via jsonpath-ng
140187
pprintpp==0.4.0
141188
# via pytest-icdiff
189+
propcache==0.2.1
190+
# via
191+
# -c requirements/_base.txt
192+
# aiohttp
193+
# yarl
142194
py-partiql-parser==0.6.1
143195
# via moto
144196
pycparser==2.22
@@ -187,6 +239,7 @@ pytest-sugar==1.0.0
187239
python-dateutil==2.9.0.post0
188240
# via
189241
# -c requirements/_base.txt
242+
# aiobotocore
190243
# botocore
191244
# moto
192245
python-dotenv==1.0.1
@@ -239,8 +292,20 @@ sympy==1.13.3
239292
# via cfn-lint
240293
termcolor==2.5.0
241294
# via pytest-sugar
295+
types-aioboto3==14.3.0
296+
# via -r requirements/_test.in
297+
types-aiobotocore==2.22.0
298+
# via
299+
# -r requirements/_test.in
300+
# types-aioboto3
301+
types-aiobotocore-s3==2.22.0
302+
# via types-aiobotocore
242303
types-aiofiles==24.1.0.20241221
243304
# via -r requirements/_test.in
305+
types-awscrt==0.26.1
306+
# via botocore-stubs
307+
types-s3transfer==0.12.0
308+
# via types-aioboto3
244309
typing-extensions==4.12.2
245310
# via
246311
# -c requirements/_base.txt
@@ -249,6 +314,9 @@ typing-extensions==4.12.2
249314
# pydantic
250315
# pydantic-core
251316
# pyopenssl
317+
# types-aioboto3
318+
# types-aiobotocore
319+
# types-aiobotocore-s3
252320
tzdata==2024.2
253321
# via
254322
# -c requirements/_base.txt
@@ -269,6 +337,11 @@ werkzeug==3.1.3
269337
wrapt==1.17.0
270338
# via
271339
# -c requirements/_base.txt
340+
# aiobotocore
272341
# aws-xray-sdk
273342
xmltodict==0.14.2
274343
# via moto
344+
yarl==1.18.3
345+
# via
346+
# -c requirements/_base.txt
347+
# aiohttp

services/dask-sidecar/src/simcore_service_dask_sidecar/computational_sidecar/docker_utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,13 @@
33
import logging
44
import re
55
import socket
6-
from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable
6+
from collections.abc import (
7+
AsyncGenerator,
8+
AsyncIterator,
9+
Awaitable,
10+
Callable,
11+
Coroutine,
12+
)
713
from pathlib import Path
814
from pprint import pformat
915
from typing import Any, Final, cast
@@ -51,7 +57,7 @@
5157
from .task_shared_volume import TaskSharedVolumes
5258

5359
logger = logging.getLogger(__name__)
54-
LogPublishingCB = Callable[[LogMessageStr, LogLevelInt], Awaitable[None]]
60+
LogPublishingCB = Callable[[LogMessageStr, LogLevelInt], Coroutine[Any, Any, None]]
5561

5662

5763
async def create_container_config(

services/dask-sidecar/src/simcore_service_dask_sidecar/utils/files.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import mimetypes
55
import time
66
import zipfile
7-
from collections.abc import Awaitable, Callable
7+
from collections.abc import Callable, Coroutine
88
from io import IOBase
99
from pathlib import Path
1010
from typing import Any, Final, TypedDict, cast
@@ -25,7 +25,7 @@
2525
S3_FILE_SYSTEM_SCHEMES: Final = ["s3", "s3a"]
2626

2727

28-
LogPublishingCB = Callable[[LogMessageStr, LogLevelInt], Awaitable[None]]
28+
LogPublishingCB = Callable[[LogMessageStr, LogLevelInt], Coroutine[Any, Any, None]]
2929

3030

3131
def _file_progress_cb(

services/dask-sidecar/tests/unit/conftest.py

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import fsspec
1515
import pytest
1616
import simcore_service_dask_sidecar
17-
from aiobotocore.session import AioBaseClient, get_session
1817
from common_library.json_serialization import json_dumps
1918
from common_library.serialization import model_dump_with_secrets
2019
from dask_task_models_library.container_tasks.protocol import TaskOwner
@@ -36,6 +35,7 @@
3635

3736
pytest_plugins = [
3837
"pytest_simcore.aws_server",
38+
"pytest_simcore.aws_s3_service",
3939
"pytest_simcore.cli_runner",
4040
"pytest_simcore.docker_compose",
4141
"pytest_simcore.docker_registry",
@@ -179,45 +179,6 @@ def s3_settings(mocked_s3_server_envs: None) -> S3Settings:
179179
return S3Settings.create_from_envs()
180180

181181

182-
@pytest.fixture
183-
def s3_endpoint_url(s3_settings: S3Settings) -> AnyUrl:
184-
assert s3_settings.S3_ENDPOINT
185-
return TypeAdapter(AnyUrl).validate_python(
186-
f"{s3_settings.S3_ENDPOINT}",
187-
)
188-
189-
190-
@pytest.fixture
191-
async def aiobotocore_s3_client(
192-
s3_settings: S3Settings, s3_endpoint_url: AnyUrl
193-
) -> AsyncIterator[AioBaseClient]:
194-
session = get_session()
195-
async with session.create_client(
196-
"s3",
197-
endpoint_url=f"{s3_endpoint_url}",
198-
aws_secret_access_key="xxx", # noqa: S106
199-
aws_access_key_id="xxx",
200-
) as client:
201-
yield client
202-
203-
204-
@pytest.fixture
205-
async def bucket(
206-
aiobotocore_s3_client: AioBaseClient, s3_settings: S3Settings
207-
) -> AsyncIterator[str]:
208-
response = await aiobotocore_s3_client.create_bucket(
209-
Bucket=s3_settings.S3_BUCKET_NAME
210-
)
211-
assert "ResponseMetadata" in response
212-
assert "HTTPStatusCode" in response["ResponseMetadata"]
213-
assert response["ResponseMetadata"]["HTTPStatusCode"] == 200
214-
215-
response = await aiobotocore_s3_client.list_buckets()
216-
assert response["Buckets"]
217-
assert len(response["Buckets"]) == 1
218-
return response["Buckets"][0]["Name"]
219-
220-
221182
@pytest.fixture
222183
def s3_remote_file_url(s3_settings: S3Settings, faker: Faker) -> Callable[..., AnyUrl]:
223184
def creator(file_path: Path | None = None) -> AnyUrl:

0 commit comments

Comments
 (0)