Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pydantic.errors import PydanticErrorMixin
from common_library.errors_classes import OsparcErrorMixin


class BaseAgentRPCError(PydanticErrorMixin, Exception):
class BaseAgentRPCError(OsparcErrorMixin, Exception):
...


Expand Down
115 changes: 89 additions & 26 deletions services/agent/requirements/_base.txt

Large diffs are not rendered by default.

59 changes: 31 additions & 28 deletions services/agent/requirements/_test.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
aioboto3==13.1.1
aioboto3==13.2.0
# via -r requirements/_test.in
aiobotocore==2.13.1
aiobotocore==2.15.2
# via aioboto3
aiofiles==24.1.0
# via
# -c requirements/_base.txt
# aioboto3
aiohappyeyeballs==2.4.0
aiohappyeyeballs==2.4.3
# via
# -c requirements/_base.txt
# aiohttp
aiohttp==3.10.6
aiohttp==3.10.10
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_base.txt
Expand All @@ -27,7 +27,7 @@ annotated-types==0.7.0
# pydantic
antlr4-python3-runtime==4.13.2
# via moto
anyio==4.6.0
anyio==4.6.2.post1
# via
# -c requirements/_base.txt
# httpx
Expand All @@ -45,12 +45,12 @@ aws-xray-sdk==2.14.0
# via moto
blinker==1.8.2
# via flask
boto3==1.34.131
boto3==1.35.36
# via
# aiobotocore
# aws-sam-translator
# moto
botocore==1.34.131
botocore==1.35.36
# via
# aiobotocore
# aws-xray-sdk
Expand All @@ -66,17 +66,17 @@ certifi==2024.8.30
# requests
cffi==1.17.1
# via cryptography
cfn-lint==1.15.1
cfn-lint==1.16.1
# via moto
charset-normalizer==3.3.2
charset-normalizer==3.4.0
# via
# -c requirements/_base.txt
# requests
click==8.1.7
# via
# -c requirements/_base.txt
# flask
coverage==7.6.1
coverage==7.6.3
# via
# -r requirements/_test.in
# pytest-cov
Expand All @@ -87,12 +87,7 @@ cryptography==43.0.1
# moto
docker==7.1.0
# via moto
ecdsa==0.19.0
# via
# moto
# python-jose
# sshpubkeys
faker==30.0.0
faker==30.4.0
# via -r requirements/_test.in
flask==3.0.3
# via
Expand All @@ -105,13 +100,13 @@ frozenlist==1.4.1
# -c requirements/_base.txt
# aiohttp
# aiosignal
graphql-core==3.2.4
graphql-core==3.2.5
# via moto
h11==0.14.0
# via
# -c requirements/_base.txt
# httpcore
httpcore==1.0.5
httpcore==1.0.6
# via
# -c requirements/_base.txt
# httpx
Expand Down Expand Up @@ -146,7 +141,7 @@ jsondiff==2.2.1
# via moto
jsonpatch==1.33
# via cfn-lint
jsonpath-ng==1.6.1
jsonpath-ng==1.7.0
# via moto
jsonpointer==3.0.0
# via jsonpatch
Expand All @@ -165,11 +160,11 @@ jsonschema-specifications==2023.7.1
# openapi-schema-validator
lazy-object-proxy==1.10.0
# via openapi-spec-validator
markupsafe==2.1.5
markupsafe==3.0.1
# via
# jinja2
# werkzeug
moto==5.0.15
moto==5.0.17
# via -r requirements/_test.in
mpmath==1.3.0
# via sympy
Expand All @@ -178,7 +173,7 @@ multidict==6.1.0
# -c requirements/_base.txt
# aiohttp
# yarl
networkx==3.3
networkx==3.4.1
# via cfn-lint
openapi-schema-validator==0.6.2
# via openapi-spec-validator
Expand All @@ -194,6 +189,10 @@ pluggy==1.5.0
# via pytest
ply==3.11
# via jsonpath-ng
propcache==0.2.0
# via
# -c requirements/_base.txt
# yarl
py-partiql-parser==0.5.6
# via moto
pycparser==2.22
Expand All @@ -207,7 +206,7 @@ pydantic-core==2.23.4
# via
# -c requirements/_base.txt
# pydantic
pyparsing==3.1.4
pyparsing==3.2.0
# via moto
pytest==8.3.3
# via
Expand All @@ -232,7 +231,9 @@ python-dateutil==2.9.0.post0
# faker
# moto
python-dotenv==1.0.1
# via -r requirements/_test.in
# via
# -c requirements/_base.txt
# -r requirements/_test.in
pyyaml==6.0.2
# via
# -c requirements/../../../requirements/constraints.txt
Expand Down Expand Up @@ -266,9 +267,9 @@ rpds-py==0.20.0
# -c requirements/_base.txt
# jsonschema
# referencing
s3transfer==0.10.2
s3transfer==0.10.3
# via boto3
setuptools==75.1.0
setuptools==75.2.0
# via
# -c requirements/_base.txt
# moto
Expand All @@ -290,7 +291,9 @@ typing-extensions==4.12.2
# -c requirements/_base.txt
# aws-sam-translator
# cfn-lint
# faker
# pydantic
# pydantic-core
urllib3==2.2.3
# via
# -c requirements/../../../requirements/constraints.txt
Expand All @@ -308,9 +311,9 @@ wrapt==1.16.0
# -c requirements/_base.txt
# aiobotocore
# aws-xray-sdk
xmltodict==0.13.0
xmltodict==0.14.2
# via moto
yarl==1.12.1
yarl==1.15.3
# via
# -c requirements/_base.txt
# aiohttp
20 changes: 10 additions & 10 deletions services/agent/requirements/_tools.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
astroid==3.3.4
astroid==3.3.5
# via pylint
black==24.8.0
black==24.10.0
# via -r requirements/../../../requirements/devenv.txt
build==1.2.2
build==1.2.2.post1
# via pip-tools
bump2version==1.0.1
# via -r requirements/../../../requirements/devenv.txt
Expand All @@ -14,9 +14,9 @@ click==8.1.7
# -c requirements/_test.txt
# black
# pip-tools
dill==0.3.8
dill==0.3.9
# via pylint
distlib==0.3.8
distlib==0.3.9
# via virtualenv
filelock==3.16.1
# via virtualenv
Expand Down Expand Up @@ -53,11 +53,11 @@ platformdirs==4.3.6
# black
# pylint
# virtualenv
pre-commit==3.8.0
pre-commit==4.0.1
# via -r requirements/../../../requirements/devenv.txt
pylint==3.3.1
# via -r requirements/../../../requirements/devenv.txt
pyproject-hooks==1.1.0
pyproject-hooks==1.2.0
# via
# build
# pip-tools
Expand All @@ -67,9 +67,9 @@ pyyaml==6.0.2
# -c requirements/_base.txt
# -c requirements/_test.txt
# pre-commit
ruff==0.6.7
ruff==0.6.9
# via -r requirements/../../../requirements/devenv.txt
setuptools==75.1.0
setuptools==75.2.0
# via
# -c requirements/_base.txt
# -c requirements/_test.txt
Expand All @@ -81,7 +81,7 @@ typing-extensions==4.12.2
# -c requirements/_base.txt
# -c requirements/_test.txt
# mypy
virtualenv==20.26.5
virtualenv==20.26.6
# via pre-commit
wheel==0.44.0
# via pip-tools
8 changes: 5 additions & 3 deletions services/agent/src/simcore_service_agent/core/settings.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from datetime import timedelta

from common_library.pydantic_networks_extension import AnyHttpUrlLegacy
from common_library.pydantic_validators import validate_numeric_string_as_timedelta
from models_library.basic_types import BootModeEnum, LogLevel
from pydantic import AliasChoices, AnyHttpUrl, Field, field_validator
from pydantic import AliasChoices, Field, field_validator
from settings_library.base import BaseCustomSettings
from settings_library.r_clone import S3Provider
from settings_library.rabbit import RabbitSettings
Expand Down Expand Up @@ -33,7 +34,7 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
AGENT_VOLUMES_CLEANUP_TARGET_SWARM_STACK_NAME: str = Field(
..., description="Exactly the same as director-v2's `SWARM_STACK_NAME` env var"
)
AGENT_VOLUMES_CLEANUP_S3_ENDPOINT: AnyHttpUrl
AGENT_VOLUMES_CLEANUP_S3_ENDPOINT: AnyHttpUrlLegacy
AGENT_VOLUMES_CLEANUP_S3_ACCESS_KEY: str
AGENT_VOLUMES_CLEANUP_S3_SECRET_KEY: str
AGENT_VOLUMES_CLEANUP_S3_BUCKET: str
Expand Down Expand Up @@ -73,7 +74,8 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
AGENT_DOCKER_NODE_ID: str = Field(..., description="used by the rabbitmq module")

AGENT_RABBITMQ: RabbitSettings = Field(
auto_default_from_env=True, description="settings for service/rabbitmq"
json_schema_extra={"auto_default_from_env": True},
description="settings for service/rabbitmq",
)

_validate_agent_volumes_cleanup_interval = validate_numeric_string_as_timedelta(
Expand Down
10 changes: 9 additions & 1 deletion services/agent/src/simcore_service_agent/models/volumes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from pathlib import Path
from typing import Final

from models_library.api_schemas_directorv2.services import (
CHARS_IN_VOLUME_NAME_BEFORE_DIR_NAME,
Expand All @@ -7,7 +8,7 @@
from models_library.projects_nodes_io import NodeID
from models_library.services_types import RunID
from models_library.users import UserID
from pydantic import BaseModel, Field
from pydantic import BaseModel, ConfigDict, Field, TypeAdapter


class DynamicServiceVolumeLabels(BaseModel):
Expand All @@ -22,7 +23,14 @@ class DynamicServiceVolumeLabels(BaseModel):
def directory_name(self) -> str:
return self.source[CHARS_IN_VOLUME_NAME_BEFORE_DIR_NAME:][::-1].strip("_")

model_config = ConfigDict(
arbitrary_types_allowed=True,
)


class VolumeDetails(BaseModel):
mountpoint: Path = Field(alias="Mountpoint")
labels: DynamicServiceVolumeLabels = Field(alias="Labels")


VolumeDetailsAdapter: Final[TypeAdapter[VolumeDetails]] = TypeAdapter(VolumeDetails)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from simcore_service_agent.core.settings import ApplicationSettings
from starlette import status

from ..models.volumes import VolumeDetails
from ..models.volumes import VolumeDetails, VolumeDetailsAdapter
from .backup import backup_volume
from .instrumentation import get_instrumentation

Expand Down Expand Up @@ -60,7 +60,7 @@ async def get_unused_dynamc_sidecar_volumes(docker: Docker) -> set[str]:

async def get_volume_details(docker: Docker, *, volume_name: str) -> VolumeDetails:
volume_details = await DockerVolume(docker, volume_name).show()
return VolumeDetails.parse_obj(volume_details)
return VolumeDetailsAdapter.validate_python(volume_details)


@contextmanager
Expand Down
1 change: 1 addition & 0 deletions services/autoscaling/tests/unit/test_core_settings.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=no-member
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
# pylint: disable=unused-variable
Expand Down
1 change: 1 addition & 0 deletions services/autoscaling/tests/unit/test_utils_docker.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# pylint: disable=no-member
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
# pylint: disable=unused-variable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
from typing import Final

from aws_library.ec2._models import AWSTagKey, AWSTagValue
from pydantic import parse_obj_as
from pydantic import TypeAdapter

DOCKER_STACK_DEPLOY_COMMAND_NAME: Final[str] = "private cluster docker deploy"
DOCKER_STACK_DEPLOY_COMMAND_EC2_TAG_KEY: Final[AWSTagKey] = parse_obj_as(
AWSTagKey, "io.simcore.clusters-keeper.private_cluster_docker_deploy"
)
DOCKER_STACK_DEPLOY_COMMAND_EC2_TAG_KEY: Final[AWSTagKey] = TypeAdapter(
AWSTagKey
).validate_python("io.simcore.clusters-keeper.private_cluster_docker_deploy")

USER_ID_TAG_KEY: Final[AWSTagKey] = parse_obj_as(AWSTagKey, "user_id")
WALLET_ID_TAG_KEY: Final[AWSTagKey] = parse_obj_as(AWSTagKey, "wallet_id")
ROLE_TAG_KEY: Final[AWSTagKey] = parse_obj_as(AWSTagKey, "role")
WORKER_ROLE_TAG_VALUE: Final[AWSTagValue] = parse_obj_as(AWSTagValue, "worker")
MANAGER_ROLE_TAG_VALUE: Final[AWSTagValue] = parse_obj_as(AWSTagValue, "manager")
USER_ID_TAG_KEY: Final[AWSTagKey] = TypeAdapter(AWSTagKey).validate_python("user_id")
WALLET_ID_TAG_KEY: Final[AWSTagKey] = TypeAdapter(AWSTagKey).validate_python(
"wallet_id"
)
ROLE_TAG_KEY: Final[AWSTagKey] = TypeAdapter(AWSTagKey).validate_python("role")
WORKER_ROLE_TAG_VALUE: Final[AWSTagValue] = TypeAdapter(AWSTagValue).validate_python(
"worker"
)
MANAGER_ROLE_TAG_VALUE: Final[AWSTagValue] = TypeAdapter(AWSTagValue).validate_python(
"manager"
)
Loading
Loading