Skip to content

Commit 9e808e8

Browse files
authored
Merge branch 'master' into pr-osparc-make-docker-api-proxy-arm-compatible
2 parents 5eeb086 + 08ce0fe commit 9e808e8

File tree

26 files changed

+447
-169
lines changed

26 files changed

+447
-169
lines changed

packages/aws-library/src/aws_library/ec2/_error_handler.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,8 @@ def ec2_exception_handler(
5959
[Callable[Concatenate[Self, P], Coroutine[Any, Any, R]]],
6060
Callable[Concatenate[Self, P], Coroutine[Any, Any, R]],
6161
]:
62-
"""
63-
Raises:
64-
SSMAccessError:
65-
"""
66-
6762
def decorator(
68-
func: Callable[Concatenate[Self, P], Coroutine[Any, Any, R]]
63+
func: Callable[Concatenate[Self, P], Coroutine[Any, Any, R]],
6964
) -> Callable[Concatenate[Self, P], Coroutine[Any, Any, R]]:
7065
@functools.wraps(func)
7166
async def wrapper(self: Self, *args: P.args, **kwargs: P.kwargs) -> R:

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
import json
77
import logging
88
import warnings
9+
from collections.abc import Iterator
910
from dataclasses import dataclass
1011
from io import StringIO
11-
from typing import Iterator
1212

1313
import aiohttp
1414
import pytest
@@ -38,6 +38,7 @@
3838
"traefik",
3939
"whoami",
4040
"sto-worker",
41+
"sto-worker-cpu-bound",
4142
}
4243
# TODO: unify healthcheck policies see https://github.com/ITISFoundation/osparc-simcore/pull/2281
4344
SERVICE_PUBLISHED_PORT = {}

packages/service-library/src/servicelib/background_task.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from tenacity.wait import wait_fixed
1111

1212
from .async_utils import cancel_wait_task, delayed_start
13-
from .logging_utils import log_context
13+
from .logging_utils import log_catch, log_context
1414

1515
_logger = logging.getLogger(__name__)
1616

@@ -84,7 +84,8 @@ class _InternalTryAgain(TryAgain):
8484
)
8585
@functools.wraps(func)
8686
async def _wrapper(*args: P.args, **kwargs: P.kwargs) -> None:
87-
await func(*args, **kwargs)
87+
with log_catch(_logger, reraise=True):
88+
await func(*args, **kwargs)
8889
raise _InternalTryAgain
8990

9091
return _wrapper

packages/service-library/tests/test_background_task.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import asyncio
88
import datetime
9+
import logging
910
from collections.abc import AsyncIterator, Awaitable, Callable
1011
from typing import Final
1112
from unittest import mock
@@ -204,3 +205,19 @@ async def _func() -> None:
204205
await task
205206

206207
assert mock_func.call_count > 1
208+
209+
210+
async def test_periodic_task_logs_error(
211+
mock_background_task: mock.AsyncMock,
212+
task_interval: datetime.timedelta,
213+
caplog: pytest.LogCaptureFixture,
214+
):
215+
mock_background_task.side_effect = RuntimeError("Test error")
216+
217+
with caplog.at_level(logging.ERROR):
218+
async with periodic_task(
219+
mock_background_task, interval=task_interval, task_name="test_task"
220+
):
221+
await asyncio.sleep(2 * task_interval.total_seconds())
222+
223+
assert "Test error" in caplog.text

packages/settings-library/src/settings_library/celery.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ class CelerySettings(BaseCustomSettings):
2222
description="Time after which task results will be deleted (default to seconds, or see https://pydantic-docs.helpmanual.io/usage/types/#datetime-types for string formating)."
2323
),
2424
] = timedelta(days=7)
25+
CELERY_EPHEMERAL_RESULT_EXPIRES: Annotated[
26+
timedelta,
27+
Field(
28+
description="Time after which ephemeral task results will be deleted (default to seconds, or see https://pydantic-docs.helpmanual.io/usage/types/#datetime-types for string formating)."
29+
),
30+
] = timedelta(hours=1)
2531
CELERY_RESULT_PERSISTENT: Annotated[
2632
bool,
2733
Field(

services/autoscaling/src/simcore_service_autoscaling/modules/auto_scaling_core.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,10 @@ async def _sorted_allowed_instance_types(app: FastAPI) -> list[EC2InstanceType]:
338338
allowed_instance_type_names
339339
), "EC2_INSTANCES_ALLOWED_TYPES cannot be empty!"
340340

341-
allowed_instance_types: list[
342-
EC2InstanceType
343-
] = await ec2_client.get_ec2_instance_capabilities(
344-
cast(set[InstanceTypeType], set(allowed_instance_type_names))
341+
allowed_instance_types: list[EC2InstanceType] = (
342+
await ec2_client.get_ec2_instance_capabilities(
343+
cast(set[InstanceTypeType], set(allowed_instance_type_names))
344+
)
345345
)
346346

347347
def _as_selection(instance_type: EC2InstanceType) -> int:
@@ -470,14 +470,14 @@ async def _start_warm_buffer_instances(
470470
with log_context(
471471
_logger, logging.INFO, f"start {len(instances_to_start)} buffer machines"
472472
):
473-
await get_ec2_client(app).set_instances_tags(
474-
instances_to_start,
475-
tags=get_activated_buffer_ec2_tags(app, auto_scaling_mode),
476-
)
477-
478473
started_instances = await get_ec2_client(app).start_instances(
479474
instances_to_start
480475
)
476+
# NOTE: first start the instance and then set the tags in case the instance cannot start (e.g. InsufficientInstanceCapacity)
477+
await get_ec2_client(app).set_instances_tags(
478+
started_instances,
479+
tags=get_activated_buffer_ec2_tags(app, auto_scaling_mode),
480+
)
481481
started_instance_ids = [i.id for i in started_instances]
482482

483483
return dataclasses.replace(
@@ -669,7 +669,7 @@ async def _find_needed_instances(
669669
"found following %s needed instances: %s",
670670
len(needed_new_instance_types_for_tasks),
671671
[
672-
f"{i.instance_type.name}:{i.instance_type.resources} takes {len(i.assigned_tasks)} task{'s' if len(i.assigned_tasks)>1 else ''}"
672+
f"{i.instance_type.name}:{i.instance_type.resources} takes {len(i.assigned_tasks)} task{'s' if len(i.assigned_tasks) > 1 else ''}"
673673
for i in needed_new_instance_types_for_tasks
674674
],
675675
)

services/docker-compose.devel.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,16 @@ services:
215215
STORAGE_PROFILING : ${STORAGE_PROFILING}
216216
STORAGE_LOGLEVEL: DEBUG
217217

218+
sto-worker-cpu-bound:
219+
volumes:
220+
- ./storage:/devel/services/storage
221+
- ../packages:/devel/packages
222+
- ${HOST_UV_CACHE_DIR}:/home/scu/.cache/uv
223+
environment:
224+
<<: *common-environment
225+
STORAGE_PROFILING : ${STORAGE_PROFILING}
226+
STORAGE_LOGLEVEL: DEBUG
227+
218228
agent:
219229
environment:
220230
<<: *common-environment

services/docker-compose.local.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ services:
133133
ports:
134134
- "8080"
135135
- "3021:3000"
136+
137+
sto-worker-cpu-bound:
138+
environment:
139+
<<: *common_environment
140+
STORAGE_REMOTE_DEBUGGING_PORT : 3000
141+
ports:
142+
- "8080"
143+
- "3022:3000"
136144
webserver:
137145
environment: &webserver_environment_local
138146
<<: *common_environment

services/docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,10 +1193,21 @@ services:
11931193
image: ${DOCKER_REGISTRY:-itisfoundation}/storage:${DOCKER_IMAGE_TAG:-master-github-latest}
11941194
init: true
11951195
hostname: "sto-worker-{{.Node.Hostname}}-{{.Task.Slot}}"
1196+
environment:
1197+
<<: *storage_environment
1198+
STORAGE_WORKER_MODE: "true"
1199+
CELERY_CONCURRENCY: 100
1200+
networks: *storage_networks
1201+
1202+
sto-worker-cpu-bound:
1203+
image: ${DOCKER_REGISTRY:-itisfoundation}/storage:${DOCKER_IMAGE_TAG:-master-github-latest}
1204+
init: true
1205+
hostname: "sto-worker-cpu-bound-{{.Node.Hostname}}-{{.Task.Slot}}"
11961206
environment:
11971207
<<: *storage_environment
11981208
STORAGE_WORKER_MODE: "true"
11991209
CELERY_CONCURRENCY: 1
1210+
CELERY_QUEUES: "cpu-bound"
12001211
networks: *storage_networks
12011212

12021213
rabbit:

services/static-webserver/client/source/class/osparc/data/Resources.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,10 @@ qx.Class.define("osparc.data.Resources", {
12091209
method: "GET",
12101210
url: statics.API + "/storage/locations/{locationId}/paths?file_filter={path}&cursor={cursor}&size=1000"
12111211
},
1212+
multiDownload: {
1213+
method: "POST",
1214+
url: statics.API + "/storage/locations/{locationId}/export-data"
1215+
},
12121216
batchDelete: {
12131217
method: "POST",
12141218
url: statics.API + "/storage/locations/{locationId}/-/paths:batchDelete"

0 commit comments

Comments
 (0)