Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 pydantic v2 fixed broken unit tests #6649

2 changes: 1 addition & 1 deletion services/api-server/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ ujson==5.9.0
# -c requirements/../../../packages/simcore-sdk/requirements/../../../requirements/constraints.txt
# -c requirements/../../../requirements/constraints.txt
# fastapi
urllib3==2.2.2
urllib3==2.2.3
# via
# -c requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
Expand Down
2 changes: 1 addition & 1 deletion services/api-server/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ typing-extensions==4.10.0
# boto3-stubs
# mypy
# sqlalchemy2-stubs
urllib3==2.2.2
urllib3==2.2.3
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_base.txt
Expand Down
2 changes: 1 addition & 1 deletion services/autoscaling/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ typing-extensions==4.11.0
# types-aiobotocore-ec2
# types-aiobotocore-s3
# types-aiobotocore-ssm
urllib3==2.2.1
urllib3==2.2.3
# via
# -c requirements/../../../packages/aws-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/aws-library/requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
Expand Down
2 changes: 1 addition & 1 deletion services/autoscaling/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ typing-extensions==4.11.0
# types-aiobotocore-iam
# types-aiobotocore-s3
# types-aiobotocore-ssm
urllib3==2.2.1
urllib3==2.2.3
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_base.txt
Expand Down
2 changes: 1 addition & 1 deletion services/catalog/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ ujson==5.9.0
# -c requirements/../../../packages/settings-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../requirements/constraints.txt
# fastapi
urllib3==2.2.2
urllib3==2.2.3
# via
# -c requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
Expand Down
2 changes: 1 addition & 1 deletion services/catalog/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ typing-extensions==4.10.0
# alembic
# mypy
# sqlalchemy2-stubs
urllib3==2.2.2
urllib3==2.2.3
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_base.txt
Expand Down
2 changes: 1 addition & 1 deletion services/clusters-keeper/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@ typing-extensions==4.11.0
# types-aiobotocore-ec2
# types-aiobotocore-s3
# types-aiobotocore-ssm
urllib3==2.2.1
urllib3==2.2.3
# via
# -c requirements/../../../packages/aws-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/aws-library/requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
Expand Down
2 changes: 1 addition & 1 deletion services/clusters-keeper/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ typing-extensions==4.11.0
# cfn-lint
# pydantic
# pydantic-core
urllib3==2.2.1
urllib3==2.2.3
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_base.txt
Expand Down
2 changes: 1 addition & 1 deletion services/dask-sidecar/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ typing-extensions==4.11.0
# typer
tzdata==2024.1
# via pandas
urllib3==2.2.1
urllib3==2.2.3
# via
# -c requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/dask-task-models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
Expand Down
2 changes: 1 addition & 1 deletion services/dask-sidecar/requirements/_dask-distributed.txt
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ tornado==6.4
# via
# -c requirements/./_base.txt
# distributed
urllib3==2.2.1
urllib3==2.2.3
# via
# -c requirements/./_base.txt
# distributed
Expand Down
2 changes: 1 addition & 1 deletion services/dask-sidecar/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ typing-extensions==4.11.0
# cfn-lint
# pydantic
# pydantic-core
urllib3==2.2.1
urllib3==2.2.3
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_base.txt
Expand Down
2 changes: 1 addition & 1 deletion services/datcore-adapter/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ typing-extensions==4.10.0
# pydantic
# pydantic-core
# typer
urllib3==2.2.1
urllib3==2.2.3
# via
# -c requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
Expand Down
2 changes: 1 addition & 1 deletion services/datcore-adapter/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ typing-extensions==4.10.0
# via
# -c requirements/_base.txt
# boto3-stubs
urllib3==2.2.1
urllib3==2.2.3
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_base.txt
Expand Down
2 changes: 1 addition & 1 deletion services/director-v2/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ ujson==5.10.0
# -c requirements/../../../packages/simcore-sdk/requirements/../../../requirements/constraints.txt
# -c requirements/../../../requirements/constraints.txt
# fastapi
urllib3==2.2.1
urllib3==2.2.3
# via
# -c requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/dask-task-models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
Expand Down
2 changes: 1 addition & 1 deletion services/director-v2/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ typing-extensions==4.11.0
# sqlalchemy2-stubs
tzdata==2024.2
# via pandas
urllib3==2.2.1
urllib3==2.2.3
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_base.txt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime

from pydantic import AliasChoices, Field, TypeAdapter, field_validator
from pydantic_settings import SettingsConfigDict
from servicelib.logging_utils_filtering import LoggerName, MessageSubstring
from settings_library.application import BaseApplicationSettings
from settings_library.basic_types import LogLevel, VersionTag
Expand Down Expand Up @@ -32,19 +33,27 @@ class _BaseApplicationSettings(BaseApplicationSettings, MixinLoggingSettings):
DYNAMIC_SCHEDULER_LOG_FORMAT_LOCAL_DEV_ENABLED: bool = Field(
default=False,
validation_alias=AliasChoices(
"DYNAMIC_SCHEDULER_LOG_FORMAT_LOCAL_DEV_ENABLED",
"LOG_FORMAT_LOCAL_DEV_ENABLED",
"DYNAMIC_SCHEDULER_LOG_FORMAT_LOCAL_DEV_ENABLED",
),
description=(
"Enables local development log format. WARNING: make sure it "
"is disabled if you want to have structured logs!"
),
description="Enables local development log format. WARNING: make sure it is disabled if you want to have structured logs!",
)
DYNAMIC_SCHEDULER_LOG_FILTER_MAPPING: dict[
LoggerName, list[MessageSubstring]
] = Field(
default_factory=dict,
validation_alias=AliasChoices(
"DYNAMIC_SCHEDULER_LOG_FILTER_MAPPING", "LOG_FILTER_MAPPING"
"LOG_FILTER_MAPPING",
"DYNAMIC_SCHEDULER_LOG_FILTER_MAPPING",
),
description=(
"is a dictionary that maps specific loggers "
"(such as 'uvicorn.access' or 'gunicorn.access') to a list "
"of log message patterns that should be filtered out."
),
description="is a dictionary that maps specific loggers (such as 'uvicorn.access' or 'gunicorn.access') to a list of log message patterns that should be filtered out.",
)

DYNAMIC_SCHEDULER_STOP_SERVICE_TIMEOUT: datetime.timedelta = Field(
Expand All @@ -60,6 +69,8 @@ class _BaseApplicationSettings(BaseApplicationSettings, MixinLoggingSettings):
def _validate_log_level(cls, value: str) -> str:
return cls.validate_log_level(value)

model_config = SettingsConfigDict(extra="allow")


class ApplicationSettings(_BaseApplicationSettings):
"""Web app's environment variables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ def set_last_status_notification_to_now(self) -> None:
#####################

def to_bytes(self) -> bytes:
result: bytes = umsgpack.packb(self.dict(), ext_handlers=_PACKB_EXTENSION_TYPES)
result: bytes = umsgpack.packb(
self.model_dump(), ext_handlers=_PACKB_EXTENSION_TYPES
)
return result

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,17 @@
pytest_simcore_core_services_selection = [
"redis",
]
pytest_simcore_ops_services_selection = [
# "redis-commander",
]


@pytest.fixture
def app_environment(
disable_rabbitmq_setup: None,
disable_deferred_manager_setup: None,
disable_notifier_setup: None,
disable_status_monitor_setup: None,
app_environment: EnvVarsDict,
redis_service: RedisSettings,
remove_redis_data: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
DynamicServiceStart,
)
from models_library.projects import ProjectID
from pydantic import TypeAdapter
from servicelib.deferred_tasks import TaskUID
from simcore_service_dynamic_scheduler.services.service_tracker._models import (
SchedulerServiceState,
Expand Down Expand Up @@ -51,8 +52,8 @@ def test_serialization(
"dynamic_service_start",
[
None,
DynamicServiceStart.parse_obj(
DynamicServiceStart.Config.schema_extra["example"]
TypeAdapter(DynamicServiceStart).validate_python(
DynamicServiceStart.model_config["json_schema_extra"]["example"]
),
],
)
Expand Down
2 changes: 1 addition & 1 deletion services/dynamic-sidecar/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ typing-extensions==4.11.0
# typer
u-msgpack-python==2.8.0
# via -r requirements/_base.in
urllib3==2.2.2
urllib3==2.2.3
# via
# -c requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
Expand Down
2 changes: 1 addition & 1 deletion services/dynamic-sidecar/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ typing-extensions==4.11.0
# mypy
# sqlalchemy2-stubs
# types-aiobotocore-s3
urllib3==2.2.2
urllib3==2.2.3
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_base.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async def health_endpoint(
) -> ApplicationHealth:
if not application_health.is_healthy:
raise HTTPException(
status.HTTP_503_SERVICE_UNAVAILABLE, detail=application_health.dict()
status.HTTP_503_SERVICE_UNAVAILABLE, detail=application_health.model_dump()
)

if not rabbitmq_client.healthy or not rabbitmq_rpc_server.healthy:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async def _start_containers(

response = await test_client.post(
f"/{API_VTAG}/containers",
json={"metrics_params": mock_metrics_params.dict()},
json={"metrics_params": mock_metrics_params.model_dump()},
)
assert response.status_code == status.HTTP_202_ACCEPTED, response.text
task_id: TaskId = response.json()
Expand Down Expand Up @@ -776,7 +776,7 @@ def mock_inactive_since_command_response(
activity_response: ActivityInfo,
) -> None:
mocker.patch(
"simcore_service_dynamic_sidecar.api.containers.run_command_in_container",
"simcore_service_dynamic_sidecar.api.rest.containers.run_command_in_container",
return_value=activity_response.model_dump_json(),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,16 @@ async def _get_task_id_create_service_containers(
*args,
**kwargs,
) -> TaskId:
ctontainers_compose_spec = ContainersComposeSpec(
containers_compose_spec = ContainersComposeSpec(
docker_compose_yaml=compose_spec,
)
await httpx_async_client.post(
f"/{API_VTAG}/containers/compose-spec", json=ctontainers_compose_spec.dict()
f"/{API_VTAG}/containers/compose-spec",
json=containers_compose_spec.model_dump(),
)
containers_create = ContainersCreate(metrics_params=mock_metrics_params)
response = await httpx_async_client.post(
f"/{API_VTAG}/containers", json=containers_create.dict()
f"/{API_VTAG}/containers", json=containers_create.model_dump()
)
task_id: TaskId = response.json()
assert isinstance(task_id, str)
Expand Down
6 changes: 4 additions & 2 deletions services/dynamic-sidecar/tests/unit/test_api_rest_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@ async def test_is_healthy(test_client: TestClient) -> None:
test_client.application.state.application_health.is_healthy = True
response = await test_client.get("/health")
assert response.status_code == status.HTTP_200_OK, response
assert response.json() == ApplicationHealth(is_healthy=True).dict()
assert response.json() == ApplicationHealth(is_healthy=True).model_dump()


async def test_is_unhealthy(test_client: TestClient) -> None:
test_client.application.state.application_health.is_healthy = False
response = await test_client.get("/health")
assert response.status_code == status.HTTP_503_SERVICE_UNAVAILABLE, response
assert response.json() == {"detail": ApplicationHealth(is_healthy=False).dict()}
assert response.json() == {
"detail": ApplicationHealth(is_healthy=False).model_dump()
}


async def test_is_unhealthy_via_rabbitmq(test_client: TestClient) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,12 @@ async def _get_task_id_create_service_containers(
docker_compose_yaml=compose_spec,
)
await httpx_async_client.post(
f"/{API_VTAG}/containers/compose-spec", json=ctontainers_compose_spec.dict()
f"/{API_VTAG}/containers/compose-spec",
json=ctontainers_compose_spec.model_dump(),
)
containers_create = ContainersCreate(metrics_params=mock_metrics_params)
response = await httpx_async_client.post(
f"/{API_VTAG}/containers", json=containers_create.dict()
f"/{API_VTAG}/containers", json=containers_create.model_dump()
)
task_id: TaskId = response.json()
assert isinstance(task_id, str)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,16 @@ async def _get_task_id_create_service_containers(
compose_spec: str,
mock_metrics_params: CreateServiceMetricsAdditionalParams,
) -> TaskId:
ctontainers_compose_spec = ContainersComposeSpec(
containers_compose_spec = ContainersComposeSpec(
docker_compose_yaml=compose_spec,
)
await httpx_async_client.post(
f"/{API_VTAG}/containers/compose-spec", json=ctontainers_compose_spec.dict()
f"/{API_VTAG}/containers/compose-spec",
json=containers_compose_spec.model_dump(),
)
containers_create = ContainersCreate(metrics_params=mock_metrics_params)
response = await httpx_async_client.post(
f"/{API_VTAG}/containers", json=containers_create.dict()
f"/{API_VTAG}/containers", json=containers_create.model_dump()
)
task_id: TaskId = response.json()
assert isinstance(task_id, str)
Expand Down
2 changes: 1 addition & 1 deletion services/invitations/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ typing-extensions==4.10.0
# pydantic
# pydantic-core
# typer
urllib3==2.2.2
urllib3==2.2.3
# via
# -c requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
Expand Down
2 changes: 1 addition & 1 deletion services/osparc-gateway-server/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ typing-extensions==4.12.2
# -c requirements/_base.txt
# mypy
# sqlalchemy2-stubs
urllib3==2.2.1
urllib3==2.2.3
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/../../dask-sidecar/requirements/_dask-distributed.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ tornado==6.4
# -c requirements/../../../../dask-sidecar/requirements/_dask-distributed.txt
# dask-gateway
# distributed
urllib3==2.2.1
urllib3==2.2.3
# via
# -c requirements/../../../../../requirements/constraints.txt
# -c requirements/../../../../dask-sidecar/requirements/_dask-distributed.txt
Expand Down
2 changes: 1 addition & 1 deletion services/payments/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ typing-extensions==4.12.2
# pydantic
# pydantic-core
# typer
urllib3==2.2.2
urllib3==2.2.3
# via
# -c requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
Expand Down
2 changes: 1 addition & 1 deletion services/payments/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ typing-extensions==4.12.2
# -c requirements/_base.txt
# mypy
# sqlalchemy2-stubs
urllib3==2.2.2
urllib3==2.2.3
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_base.txt
Expand Down
Loading
Loading