Skip to content

Commit fef2946

Browse files
author
Andrei Neagu
committed
Merge remote-tracking branch 'upstream/master' into pr-osparc-s3-zip-stream-worker-code
2 parents 4c444aa + bcc60b5 commit fef2946

File tree

35 files changed

+702
-297
lines changed

35 files changed

+702
-297
lines changed

api/specs/web-server/_storage.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
PresignedLink,
2323
)
2424
from models_library.api_schemas_webserver.storage import (
25+
BatchDeletePathsBodyParams,
2526
DataExportPost,
2627
ListPathsQueryParams,
2728
StorageLocationPathParams,
@@ -80,6 +81,19 @@ async def compute_path_size(_path: Annotated[StoragePathComputeSizeParams, Depen
8081
"""Compute the size of a path"""
8182

8283

84+
@router.post(
85+
"/storage/locations/{location_id}/-/paths:batchDelete",
86+
response_model=Envelope[TaskGet],
87+
status_code=status.HTTP_202_ACCEPTED,
88+
description="Deletes Paths",
89+
)
90+
async def batch_delete_paths(
91+
_path: Annotated[StorageLocationPathParams, Depends()],
92+
_body: Annotated[BatchDeletePathsBodyParams, Depends()],
93+
):
94+
"""deletes files/folders if user has the rights to"""
95+
96+
8397
@router.get(
8498
"/storage/locations/{location_id}/datasets",
8599
response_model=Envelope[list[DatasetMetaData]],

packages/models-library/src/models_library/api_schemas_webserver/storage.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,9 @@ class ListPathsQueryParams(InputSchema, CursorQueryParameters):
3535
] = DEFAULT_NUMBER_OF_PATHS_PER_PAGE
3636

3737

38+
class BatchDeletePathsBodyParams(InputSchema):
39+
paths: set[Path]
40+
41+
3842
class DataExportPost(InputSchema):
3943
paths: list[StorageFileID]

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ def from_key(cls, key: str) -> "DockerLabelKey":
6363
_UNDEFINED_LABEL_VALUE_INT: Final[str] = "0"
6464

6565

66-
DOCKER_TASK_EC2_INSTANCE_TYPE_PLACEMENT_CONSTRAINT_KEY: Final[
67-
DockerLabelKey
68-
] = TypeAdapter(DockerLabelKey).validate_python("ec2-instance-type")
66+
DOCKER_TASK_EC2_INSTANCE_TYPE_PLACEMENT_CONSTRAINT_KEY: Final[DockerLabelKey] = (
67+
TypeAdapter(DockerLabelKey).validate_python("ec2-instance-type")
68+
)
6969

7070

7171
def to_simcore_runtime_docker_label_key(key: str) -> DockerLabelKey:
@@ -122,18 +122,24 @@ def _backwards_compatibility(cls, values: dict[str, Any]) -> dict[str, Any]:
122122

123123
mapped_values.setdefault(
124124
f"{_SIMCORE_RUNTIME_DOCKER_LABEL_PREFIX}memory-limit",
125-
_UNDEFINED_LABEL_VALUE_INT,
125+
values.get("memory_limit", _UNDEFINED_LABEL_VALUE_INT),
126126
)
127127

128128
def _convert_nano_cpus_to_cpus(nano_cpu: str) -> str:
129129
with contextlib.suppress(ValidationError):
130-
return f"{TypeAdapter(float).validate_python(nano_cpu) / (1.0*10**9):.2f}"
130+
return f"{TypeAdapter(float).validate_python(nano_cpu) / (1.0 * 10**9):.2f}"
131131
return _UNDEFINED_LABEL_VALUE_INT
132132

133133
mapped_values.setdefault(
134134
f"{_SIMCORE_RUNTIME_DOCKER_LABEL_PREFIX}cpu-limit",
135-
_convert_nano_cpus_to_cpus(
136-
values.get("nano_cpus_limit", _UNDEFINED_LABEL_VALUE_INT)
135+
values.get(
136+
"cpu_limit",
137+
_convert_nano_cpus_to_cpus(
138+
values.get(
139+
"nano_cpus_limit",
140+
_UNDEFINED_LABEL_VALUE_INT,
141+
)
142+
),
137143
),
138144
)
139145
return mapped_values

packages/models-library/tests/test_docker.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55

66
from typing import Any
7+
from uuid import UUID
78

89
import pytest
910
from faker import Faker
@@ -13,7 +14,7 @@
1314
DockerLabelKey,
1415
StandardSimcoreDockerLabels,
1516
)
16-
from pydantic import TypeAdapter, ValidationError
17+
from pydantic import ByteSize, TypeAdapter, ValidationError
1718

1819
_faker = Faker()
1920

@@ -83,11 +84,11 @@ def test_docker_label_key(label_key: str, valid: bool):
8384
True,
8485
),
8586
(
86-
f"registry:5000/si.m--c_ore/services/1234/jupyter-smash:{'A'*128}",
87+
f"registry:5000/si.m--c_ore/services/1234/jupyter-smash:{'A' * 128}",
8788
True,
8889
),
8990
(
90-
f"registry:5000/si.m--c_ore/services/1234/jupyter-smash:{'A'*129}",
91+
f"registry:5000/si.m--c_ore/services/1234/jupyter-smash:{'A' * 129}",
9192
False,
9293
),
9394
),
@@ -122,3 +123,17 @@ def test_simcore_service_docker_label_keys(obj_data: dict[str, Any]):
122123
).validate_python(exported_dict)
123124
assert re_imported_docker_label_keys
124125
assert simcore_service_docker_label_keys == re_imported_docker_label_keys
126+
127+
128+
def test_simcore_service_docker_label_keys_construction():
129+
simcore_service_docker_label_keys = StandardSimcoreDockerLabels(
130+
user_id=8268,
131+
project_id=UUID("5ea24ce0-0e4d-4ee6-a3f1-e4799752a684"),
132+
node_id=UUID("c17c6279-23c6-412f-8826-867323a7711a"),
133+
product_name="osparc",
134+
simcore_user_agent="oePqmjQbZndJghceKRJR",
135+
swarm_stack_name="UNDEFINED_DOCKER_LABEL", # NOTE: there is currently no need for this label in the comp backend
136+
memory_limit=ByteSize(23424324),
137+
cpu_limit=1.0,
138+
)
139+
assert simcore_service_docker_label_keys.cpu_limit == 1.0

0 commit comments

Comments
 (0)