diff --git a/packages/common-library/requirements/_base.in b/packages/common-library/requirements/_base.in index 73cc02bceb7..2277d690e64 100644 --- a/packages/common-library/requirements/_base.in +++ b/packages/common-library/requirements/_base.in @@ -3,4 +3,6 @@ # --constraint ../../../requirements/constraints.txt +orjson pydantic +pydantic-extra-types diff --git a/packages/common-library/requirements/_base.txt b/packages/common-library/requirements/_base.txt index 32a8575abea..a0162daa052 100644 --- a/packages/common-library/requirements/_base.txt +++ b/packages/common-library/requirements/_base.txt @@ -1,11 +1,18 @@ annotated-types==0.7.0 # via pydantic +orjson==3.10.10 + # via + # -c requirements/../../../requirements/constraints.txt + # -r requirements/_base.in pydantic==2.9.2 # via # -c requirements/../../../requirements/constraints.txt # -r requirements/_base.in + # pydantic-extra-types pydantic-core==2.23.4 # via pydantic +pydantic-extra-types==2.9.0 + # via -r requirements/_base.in typing-extensions==4.12.2 # via # pydantic diff --git a/packages/models-library/src/models_library/utils/json_serialization.py b/packages/common-library/src/common_library/json_serialization.py similarity index 100% rename from packages/models-library/src/models_library/utils/json_serialization.py rename to packages/common-library/src/common_library/json_serialization.py diff --git a/packages/common-library/tests/test_json_serialization.py b/packages/common-library/tests/test_json_serialization.py new file mode 100644 index 00000000000..7684497e493 --- /dev/null +++ b/packages/common-library/tests/test_json_serialization.py @@ -0,0 +1,97 @@ +# pylint: disable=redefined-outer-name +# pylint: disable=unused-argument +# pylint: disable=unused-variable + +import json +from copy import deepcopy +from typing import Annotated, Any, TypeAlias +from uuid import uuid4 + +import pytest +from common_library.json_serialization import ( + JsonNamespace, + SeparatorTuple, + json_dumps, + json_loads, +) +from faker import Faker +from pydantic import Field, TypeAdapter +from pydantic.json import pydantic_encoder + + +@pytest.fixture +def fake_data_dict(faker: Faker) -> dict[str, Any]: + data = { + "uuid_as_UUID": faker.uuid4(cast_to=None), + "uuid_as_str": faker.uuid4(), + "int": faker.pyint(), + "float": faker.pyfloat(), + "str": faker.pystr(), + "dict": faker.pydict(), + "list": faker.pylist(), + } + data["object"] = deepcopy(data) + return data + + +def test_json_dump_variants(): + + uuid_obj = uuid4() + + with pytest.raises(TypeError) as exc_info: + json.dumps(uuid_obj) + + assert str(exc_info.value) == "Object of type UUID is not JSON serializable" + + assert json_dumps(uuid_obj) == json.dumps(str(uuid_obj)) + + +def test_serialized_non_str_dict_keys(): + # tests orjson.OPT_NON_STR_KEYS option + + # if a dict has a key of a type other than str it will NOT raise + json_dumps({1: "foo"}) + + +ConstrainedFloat: TypeAlias = Annotated[float, Field(ge=0.0, le=1.0)] + + +def test_serialized_constraint_floats(): + # test extension of ENCODERS_BY_TYPE used in pydantic_encoder + + json_dumps({"value": 1.0}) + + # TypeError: Type is not JSON serializable: ProgressPercent + json_dumps({"value": TypeAdapter(ConstrainedFloat).validate_python(1.0)}) + + +def _expected_json_dumps(obj: Any, default=pydantic_encoder, **json_dumps_kwargs): + if "indent" not in json_dumps_kwargs: + json_dumps_kwargs.setdefault( + "separators", + SeparatorTuple(item_separator=",", key_separator=":"), # compact separators + ) + return json.dumps(obj, default=default, **json_dumps_kwargs) + + +@pytest.mark.parametrize( + "kwargs", + [ + pytest.param({}, id="no-kw"), + pytest.param({"sort_keys": True}, id="sort_keys-kw"), + pytest.param( + {"separators": (",", ":")}, id="default_separators-kw" + ), # NOTE: e.g. engineio.packet has `self.json.dumps(self.data, separators=(',', ':'))` + pytest.param( + {"indent": 2}, id="indent-kw" + ), # NOTE: only one-to-one with indent=2 + ], +) +def test_compatiblity_with_json_interface( + fake_data_dict: dict[str, Any], kwargs: dict[str, Any] +): + orjson_dump = JsonNamespace.dumps(fake_data_dict, **kwargs) + json_dump = _expected_json_dumps(fake_data_dict, **kwargs) + + # NOTE: cannot compare dumps directly because orjson compacts it more + assert json_loads(orjson_dump) == json_loads(json_dump) diff --git a/packages/models-library/src/models_library/service_settings_labels.py b/packages/models-library/src/models_library/service_settings_labels.py index 851b1880cc3..0a632a7b70d 100644 --- a/packages/models-library/src/models_library/service_settings_labels.py +++ b/packages/models-library/src/models_library/service_settings_labels.py @@ -5,6 +5,7 @@ from pathlib import Path from typing import Any, Literal, TypeAlias +from common_library.json_serialization import json_dumps from pydantic import ( BaseModel, ByteSize, @@ -23,7 +24,6 @@ from .generics import ListModel from .service_settings_nat_rule import NATRule from .services_resources import DEFAULT_SINGLE_SERVICE_NAME -from .utils.json_serialization import json_dumps _BaseConfig = ConfigDict( extra="forbid", arbitrary_types_allowed=True, ignored_types=(cached_property,) diff --git a/packages/models-library/src/models_library/utils/_original_fastapi_encoders.py b/packages/models-library/src/models_library/utils/_original_fastapi_encoders.py index 4f09ae6a379..0b48328d91b 100644 --- a/packages/models-library/src/models_library/utils/_original_fastapi_encoders.py +++ b/packages/models-library/src/models_library/utils/_original_fastapi_encoders.py @@ -10,7 +10,7 @@ from types import GeneratorType from typing import Any, Callable, Union -from models_library.utils.json_serialization import ENCODERS_BY_TYPE +from common_library.json_serialization import ENCODERS_BY_TYPE from pydantic import BaseModel from pydantic_core import PydanticUndefined, PydanticUndefinedType from typing_extensions import Annotated, Doc diff --git a/packages/models-library/src/models_library/utils/labels_annotations.py b/packages/models-library/src/models_library/utils/labels_annotations.py index ec8d1e7fd6c..26c7d7d73f5 100644 --- a/packages/models-library/src/models_library/utils/labels_annotations.py +++ b/packages/models-library/src/models_library/utils/labels_annotations.py @@ -8,7 +8,7 @@ from json.decoder import JSONDecodeError from typing import Any, TypeAlias -from .json_serialization import json_dumps +from common_library.json_serialization import json_dumps LabelsAnnotationsDict: TypeAlias = dict[str, str] diff --git a/packages/models-library/src/models_library/utils/specs_substitution.py b/packages/models-library/src/models_library/utils/specs_substitution.py index d8a7e9cf161..d1278d69912 100644 --- a/packages/models-library/src/models_library/utils/specs_substitution.py +++ b/packages/models-library/src/models_library/utils/specs_substitution.py @@ -1,10 +1,9 @@ from typing import Any, NamedTuple, TypeAlias, cast from common_library.errors_classes import OsparcErrorMixin - +from common_library.json_serialization import json_dumps, json_loads from pydantic import StrictBool, StrictFloat, StrictInt -from .json_serialization import json_dumps, json_loads from .string_substitution import ( SubstitutionsDict, TextTemplate, diff --git a/packages/models-library/tests/test_utils_json_serialization.py b/packages/models-library/tests/test_utils_json_serialization.py index 4e3839fc6e9..a229c16b75d 100644 --- a/packages/models-library/tests/test_utils_json_serialization.py +++ b/packages/models-library/tests/test_utils_json_serialization.py @@ -3,43 +3,14 @@ # pylint: disable=unused-variable -import json from copy import deepcopy from typing import Any from uuid import uuid4 import pytest +from common_library.json_serialization import json_dumps, json_loads from faker import Faker -from models_library.api_schemas_long_running_tasks.base import ProgressPercent from models_library.utils.fastapi_encoders import jsonable_encoder -from models_library.utils.json_serialization import ( - JsonNamespace, - SeparatorTuple, - json_dumps, - json_loads, -) -from pydantic.json import pydantic_encoder - - -def _expected_json_dumps(obj: Any, default=pydantic_encoder, **json_dumps_kwargs): - if "indent" not in json_dumps_kwargs: - json_dumps_kwargs.setdefault( - "separators", - SeparatorTuple(item_separator=",", key_separator=":"), # compact separators - ) - return json.dumps(obj, default=default, **json_dumps_kwargs) - - -def test_json_dump_variants(): - - uuid_obj = uuid4() - - with pytest.raises(TypeError) as exc_info: - json.dumps(uuid_obj) - - assert str(exc_info.value) == "Object of type UUID is not JSON serializable" - - assert json_dumps(uuid_obj) == json.dumps(str(uuid_obj)) @pytest.fixture @@ -75,42 +46,3 @@ def test_serialization_of_nested_dicts(fake_data_dict: dict[str, Any]): dump = json_dumps(obj) assert json_loads(dump) == jsonable_encoder(obj) - - -@pytest.mark.parametrize( - "kwargs", - [ - pytest.param({}, id="no-kw"), - pytest.param({"sort_keys": True}, id="sort_keys-kw"), - pytest.param( - {"separators": (",", ":")}, id="default_separators-kw" - ), # NOTE: e.g. engineio.packet has `self.json.dumps(self.data, separators=(',', ':'))` - pytest.param( - {"indent": 2}, id="indent-kw" - ), # NOTE: only one-to-one with indent=2 - ], -) -def test_compatiblity_with_json_interface( - fake_data_dict: dict[str, Any], kwargs: dict[str, Any] -): - orjson_dump = JsonNamespace.dumps(fake_data_dict, **kwargs) - json_dump = _expected_json_dumps(fake_data_dict, **kwargs) - - # NOTE: cannot compare dumps directly because orjson compacts it more - assert json_loads(orjson_dump) == json_loads(json_dump) - - -def test_serialized_non_str_dict_keys(): - # tests orjson.OPT_NON_STR_KEYS option - - # if a dict has a key of a type other than str it will NOT raise - json_dumps({1: "foo"}) - - -def test_serialized_constraint_floats(): - # test extension of ENCODERS_BY_TYPE used in pydantic_encoder - - json_dumps({"value": 1.0}) - - # TypeError: Type is not JSON serializable: ProgressPercent - json_dumps({"value": ProgressPercent(1.0)}) diff --git a/packages/pytest-simcore/src/pytest_simcore/helpers/aws_ec2.py b/packages/pytest-simcore/src/pytest_simcore/helpers/aws_ec2.py index cf54561f843..1e992f4ee45 100644 --- a/packages/pytest-simcore/src/pytest_simcore/helpers/aws_ec2.py +++ b/packages/pytest-simcore/src/pytest_simcore/helpers/aws_ec2.py @@ -1,8 +1,8 @@ import base64 from collections.abc import Sequence +from common_library.json_serialization import json_dumps from models_library.docker import DockerGenericTag -from models_library.utils.json_serialization import json_dumps from types_aiobotocore_ec2 import EC2Client from types_aiobotocore_ec2.literals import InstanceStateNameType, InstanceTypeType from types_aiobotocore_ec2.type_defs import FilterTypeDef, InstanceTypeDef, TagTypeDef diff --git a/packages/service-integration/tests/test__usecase_jupytermath.py b/packages/service-integration/tests/test__usecase_jupytermath.py index e49f9b0512a..4b816a18198 100644 --- a/packages/service-integration/tests/test__usecase_jupytermath.py +++ b/packages/service-integration/tests/test__usecase_jupytermath.py @@ -13,7 +13,7 @@ import pytest import yaml -from models_library.utils.json_serialization import json_loads +from common_library.json_serialization import json_loads from service_integration import cli from typer.testing import CliRunner, Result diff --git a/packages/service-library/src/servicelib/aiohttp/client_session.py b/packages/service-library/src/servicelib/aiohttp/client_session.py index 26e4e7d579c..40e49c76a4b 100644 --- a/packages/service-library/src/servicelib/aiohttp/client_session.py +++ b/packages/service-library/src/servicelib/aiohttp/client_session.py @@ -2,7 +2,7 @@ from typing import cast from aiohttp import ClientSession, ClientTimeout, web -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from ..utils import ( get_http_client_request_aiohttp_connect_timeout, diff --git a/packages/service-library/src/servicelib/aiohttp/long_running_tasks/_error_handlers.py b/packages/service-library/src/servicelib/aiohttp/long_running_tasks/_error_handlers.py index ef1e91a0197..9e67b2b7f4d 100644 --- a/packages/service-library/src/servicelib/aiohttp/long_running_tasks/_error_handlers.py +++ b/packages/service-library/src/servicelib/aiohttp/long_running_tasks/_error_handlers.py @@ -1,7 +1,7 @@ import logging from aiohttp import web -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from ...long_running_tasks._errors import ( TaskCancelledError, diff --git a/packages/service-library/src/servicelib/aiohttp/long_running_tasks/_routes.py b/packages/service-library/src/servicelib/aiohttp/long_running_tasks/_routes.py index d2e2dda98bf..1906c0bc93f 100644 --- a/packages/service-library/src/servicelib/aiohttp/long_running_tasks/_routes.py +++ b/packages/service-library/src/servicelib/aiohttp/long_running_tasks/_routes.py @@ -2,7 +2,7 @@ from typing import Any from aiohttp import web -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from pydantic import BaseModel from servicelib.aiohttp import status diff --git a/packages/service-library/src/servicelib/aiohttp/long_running_tasks/_server.py b/packages/service-library/src/servicelib/aiohttp/long_running_tasks/_server.py index 47640c491f2..1d97f9320c8 100644 --- a/packages/service-library/src/servicelib/aiohttp/long_running_tasks/_server.py +++ b/packages/service-library/src/servicelib/aiohttp/long_running_tasks/_server.py @@ -5,8 +5,8 @@ from typing import Any from aiohttp import web +from common_library.json_serialization import json_dumps from common_library.pydantic_networks_extension import AnyHttpUrlLegacy -from models_library.utils.json_serialization import json_dumps from pydantic import PositiveFloat, TypeAdapter from ...aiohttp import status diff --git a/packages/service-library/src/servicelib/aiohttp/requests_validation.py b/packages/service-library/src/servicelib/aiohttp/requests_validation.py index ce4a97d54a1..5a588041682 100644 --- a/packages/service-library/src/servicelib/aiohttp/requests_validation.py +++ b/packages/service-library/src/servicelib/aiohttp/requests_validation.py @@ -13,7 +13,7 @@ from typing import TypeAlias, TypeVar, Union from aiohttp import web -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from pydantic import BaseModel, ConfigDict, TypeAdapter, ValidationError from ..mimetype_constants import MIMETYPE_APPLICATION_JSON diff --git a/packages/service-library/src/servicelib/aiohttp/rest_middlewares.py b/packages/service-library/src/servicelib/aiohttp/rest_middlewares.py index d12ea2147d8..d5f5a04283b 100644 --- a/packages/service-library/src/servicelib/aiohttp/rest_middlewares.py +++ b/packages/service-library/src/servicelib/aiohttp/rest_middlewares.py @@ -13,7 +13,7 @@ from aiohttp.web_request import Request from aiohttp.web_response import StreamResponse from common_library.error_codes import create_error_code -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from ..logging_errors import create_troubleshotting_log_kwargs from ..mimetype_constants import MIMETYPE_APPLICATION_JSON diff --git a/packages/service-library/src/servicelib/aiohttp/rest_responses.py b/packages/service-library/src/servicelib/aiohttp/rest_responses.py index 52aa87497d8..1cce04ae015 100644 --- a/packages/service-library/src/servicelib/aiohttp/rest_responses.py +++ b/packages/service-library/src/servicelib/aiohttp/rest_responses.py @@ -1,6 +1,7 @@ """ Utils to check, convert and compose server responses for the RESTApi """ + import inspect import json from collections.abc import Mapping @@ -9,7 +10,7 @@ from aiohttp import web, web_exceptions from aiohttp.web_exceptions import HTTPError, HTTPException -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from servicelib.aiohttp.status import HTTP_200_OK from ..mimetype_constants import MIMETYPE_APPLICATION_JSON diff --git a/packages/service-library/src/servicelib/aiohttp/rest_utils.py b/packages/service-library/src/servicelib/aiohttp/rest_utils.py index b25a72301d6..e026e211977 100644 --- a/packages/service-library/src/servicelib/aiohttp/rest_utils.py +++ b/packages/service-library/src/servicelib/aiohttp/rest_utils.py @@ -2,7 +2,7 @@ from aiohttp import web from aiohttp.web import RouteDef, RouteTableDef -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps class EnvelopeFactory: diff --git a/packages/service-library/src/servicelib/utils_profiling_middleware.py b/packages/service-library/src/servicelib/utils_profiling_middleware.py index 22bc7c7d29e..5b5038e335e 100644 --- a/packages/service-library/src/servicelib/utils_profiling_middleware.py +++ b/packages/service-library/src/servicelib/utils_profiling_middleware.py @@ -4,7 +4,7 @@ from contextlib import contextmanager from typing import Final -from models_library.utils.json_serialization import json_dumps, json_loads +from common_library.json_serialization import json_dumps, json_loads from pyinstrument import Profiler from .mimetype_constants import MIMETYPE_APPLICATION_JSON, MIMETYPE_APPLICATION_ND_JSON diff --git a/packages/service-library/tests/aiohttp/test_client_session.py b/packages/service-library/tests/aiohttp/test_client_session.py index ccc9356f07e..74b91655c31 100644 --- a/packages/service-library/tests/aiohttp/test_client_session.py +++ b/packages/service-library/tests/aiohttp/test_client_session.py @@ -10,7 +10,7 @@ from aiohttp import web from aiohttp.client import ClientSession from aiohttp.test_utils import TestServer -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from servicelib.aiohttp.application_keys import APP_CLIENT_SESSION_KEY from servicelib.aiohttp.client_session import ( get_client_session, diff --git a/packages/service-library/tests/aiohttp/test_requests_validation.py b/packages/service-library/tests/aiohttp/test_requests_validation.py index 4e1b4f4e2e7..2094349932f 100644 --- a/packages/service-library/tests/aiohttp/test_requests_validation.py +++ b/packages/service-library/tests/aiohttp/test_requests_validation.py @@ -9,8 +9,8 @@ import pytest from aiohttp import web from aiohttp.test_utils import TestClient +from common_library.json_serialization import json_dumps from faker import Faker -from models_library.utils.json_serialization import json_dumps from pydantic import BaseModel, ConfigDict, Field from servicelib.aiohttp import status from servicelib.aiohttp.requests_validation import ( diff --git a/packages/service-library/tests/aiohttp/test_rest_middlewares.py b/packages/service-library/tests/aiohttp/test_rest_middlewares.py index 554982e53cd..00f371544b7 100644 --- a/packages/service-library/tests/aiohttp/test_rest_middlewares.py +++ b/packages/service-library/tests/aiohttp/test_rest_middlewares.py @@ -14,7 +14,7 @@ from aiohttp import web from aiohttp.test_utils import TestClient from common_library.error_codes import parse_error_code -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from servicelib.aiohttp import status from servicelib.aiohttp.rest_middlewares import ( _FMSG_INTERNAL_ERROR_USER_FRIENDLY_WITH_OEC, diff --git a/packages/service-library/tests/deferred_tasks/test_deferred_tasks.py b/packages/service-library/tests/deferred_tasks/test_deferred_tasks.py index a03b87c4151..6dbc5d3d764 100644 --- a/packages/service-library/tests/deferred_tasks/test_deferred_tasks.py +++ b/packages/service-library/tests/deferred_tasks/test_deferred_tasks.py @@ -16,8 +16,8 @@ import psutil import pytest from aiohttp.test_utils import unused_port +from common_library.json_serialization import json_dumps from common_library.serialization import model_dump_with_secrets -from models_library.utils.json_serialization import json_dumps from pydantic import NonNegativeFloat, NonNegativeInt from pytest_mock import MockerFixture from servicelib import redis as servicelib_redis diff --git a/packages/settings-library/requirements/_base.txt b/packages/settings-library/requirements/_base.txt index 64117c65d55..3d57d1af6c2 100644 --- a/packages/settings-library/requirements/_base.txt +++ b/packages/settings-library/requirements/_base.txt @@ -6,15 +6,23 @@ markdown-it-py==3.0.0 # via rich mdurl==0.1.2 # via markdown-it-py +orjson==3.10.10 + # via + # -c requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt + # -c requirements/../../../requirements/constraints.txt + # -r requirements/../../../packages/common-library/requirements/_base.in pydantic==2.9.2 # via # -c requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt # -c requirements/../../../requirements/constraints.txt # -r requirements/../../../packages/common-library/requirements/_base.in # -r requirements/_base.in + # pydantic-extra-types # pydantic-settings pydantic-core==2.23.4 # via pydantic +pydantic-extra-types==2.9.0 + # via -r requirements/../../../packages/common-library/requirements/_base.in pydantic-settings==2.5.2 # via -r requirements/_base.in pygments==2.18.0 diff --git a/packages/settings-library/src/settings_library/utils_cli.py b/packages/settings-library/src/settings_library/utils_cli.py index e3addbc6130..8c28dfe9cb5 100644 --- a/packages/settings-library/src/settings_library/utils_cli.py +++ b/packages/settings-library/src/settings_library/utils_cli.py @@ -8,8 +8,8 @@ import rich import typer +from common_library.json_serialization import json_dumps from common_library.serialization import model_dump_with_secrets -from models_library.utils.json_serialization import json_dumps from pydantic import ValidationError from pydantic_core import to_jsonable_python from pydantic_settings import BaseSettings diff --git a/packages/settings-library/tests/test__pydantic_settings.py b/packages/settings-library/tests/test__pydantic_settings.py index 2d52c1096e7..976395b1b10 100644 --- a/packages/settings-library/tests/test__pydantic_settings.py +++ b/packages/settings-library/tests/test__pydantic_settings.py @@ -132,8 +132,9 @@ def test_construct(monkeypatch): # from __init__ settings_from_init = Settings( VALUE=1, - VALUE_ALSO_REQUIRED=10, VALUE_NULLABLE_REQUIRED=None, + VALUE_NULLABLE_REQUIRED_AS_WELL=None, + VALUE_REQUIRED_AS_WELL=32, ) print(settings_from_init.model_dump_json(exclude_unset=True, indent=1)) @@ -145,6 +146,8 @@ def test_construct(monkeypatch): "VALUE": "1", "VALUE_ALSO_REQUIRED": "10", "VALUE_NULLABLE_REQUIRED": "null", + "VALUE_NULLABLE_REQUIRED_AS_WELL": "null", + "VALUE_REQUIRED_AS_WELL": "32", }, ) # WARNING: set this env to None would not work w/o ``parse_none`` validator! bug??? diff --git a/packages/simcore-sdk/src/simcore_sdk/node_ports_v2/serialization_v2.py b/packages/simcore-sdk/src/simcore_sdk/node_ports_v2/serialization_v2.py index f4d74711e18..510f7b14fbb 100644 --- a/packages/simcore-sdk/src/simcore_sdk/node_ports_v2/serialization_v2.py +++ b/packages/simcore-sdk/src/simcore_sdk/node_ports_v2/serialization_v2.py @@ -5,8 +5,8 @@ from typing import Any import pydantic +from common_library.json_serialization import json_dumps from models_library.projects_nodes_io import NodeID -from models_library.utils.json_serialization import json_dumps from models_library.utils.nodes import compute_node_hash from packaging import version from settings_library.aws_s3_cli import AwsS3CliSettings diff --git a/services/api-server/src/simcore_service_api_server/api/dependencies/webserver.py b/services/api-server/src/simcore_service_api_server/api/dependencies/webserver.py index e79b7e83057..94cfed68b55 100644 --- a/services/api-server/src/simcore_service_api_server/api/dependencies/webserver.py +++ b/services/api-server/src/simcore_service_api_server/api/dependencies/webserver.py @@ -1,10 +1,10 @@ import time from typing import Annotated +from common_library.json_serialization import json_dumps from cryptography.fernet import Fernet from fastapi import Depends, FastAPI, HTTPException, status from fastapi.requests import Request -from models_library.utils.json_serialization import json_dumps from servicelib.rest_constants import X_PRODUCT_NAME_HEADER from ..._constants import MSG_BACKEND_SERVICE_UNAVAILABLE diff --git a/services/api-server/src/simcore_service_api_server/models/_utils_pydantic.py b/services/api-server/src/simcore_service_api_server/models/_utils_pydantic.py index ad519ca7d24..150cac87b97 100644 --- a/services/api-server/src/simcore_service_api_server/models/_utils_pydantic.py +++ b/services/api-server/src/simcore_service_api_server/models/_utils_pydantic.py @@ -1,4 +1,4 @@ -from models_library.utils.json_serialization import json_dumps, json_loads +from common_library.json_serialization import json_dumps, json_loads class BaseConfig: diff --git a/services/autoscaling/src/simcore_service_autoscaling/utils/buffer_machines_pool_core.py b/services/autoscaling/src/simcore_service_autoscaling/utils/buffer_machines_pool_core.py index dcbba97015d..66ff7972306 100644 --- a/services/autoscaling/src/simcore_service_autoscaling/utils/buffer_machines_pool_core.py +++ b/services/autoscaling/src/simcore_service_autoscaling/utils/buffer_machines_pool_core.py @@ -3,9 +3,9 @@ from typing import Final from aws_library.ec2 import AWS_TAG_VALUE_MAX_LENGTH, AWSTagKey, AWSTagValue, EC2Tags +from common_library.json_serialization import json_dumps from fastapi import FastAPI from models_library.docker import DockerGenericTag -from models_library.utils.json_serialization import json_dumps from pydantic import TypeAdapter from ..constants import ( diff --git a/services/autoscaling/tests/unit/test_modules_buffer_machine_core.py b/services/autoscaling/tests/unit/test_modules_buffer_machine_core.py index 8135ac9d2c4..c81369a89bb 100644 --- a/services/autoscaling/tests/unit/test_modules_buffer_machine_core.py +++ b/services/autoscaling/tests/unit/test_modules_buffer_machine_core.py @@ -17,11 +17,11 @@ import pytest import tenacity from aws_library.ec2 import AWSTagKey, EC2InstanceBootSpecific +from common_library.json_serialization import json_dumps from faker import Faker from fastapi import FastAPI from fastapi.encoders import jsonable_encoder from models_library.docker import DockerGenericTag -from models_library.utils.json_serialization import json_dumps from pydantic import TypeAdapter from pytest_mock.plugin import MockerFixture from pytest_simcore.helpers.aws_ec2 import ( diff --git a/services/catalog/src/simcore_service_catalog/services/director.py b/services/catalog/src/simcore_service_catalog/services/director.py index 7c6925902f4..ee1327b475c 100644 --- a/services/catalog/src/simcore_service_catalog/services/director.py +++ b/services/catalog/src/simcore_service_catalog/services/director.py @@ -7,10 +7,10 @@ from typing import Any import httpx +from common_library.json_serialization import json_dumps from fastapi import FastAPI, HTTPException from models_library.services_metadata_published import ServiceMetaDataPublished from models_library.services_types import ServiceKey, ServiceVersion -from models_library.utils.json_serialization import json_dumps from servicelib.logging_utils import log_context from starlette import status from tenacity.asyncio import AsyncRetrying diff --git a/services/clusters-keeper/tests/unit/test_utils_clusters.py b/services/clusters-keeper/tests/unit/test_utils_clusters.py index 20cde00c047..55190cb46a1 100644 --- a/services/clusters-keeper/tests/unit/test_utils_clusters.py +++ b/services/clusters-keeper/tests/unit/test_utils_clusters.py @@ -15,6 +15,7 @@ EC2InstanceBootSpecific, EC2InstanceData, ) +from common_library.json_serialization import json_dumps from faker import Faker from models_library.api_schemas_clusters_keeper.clusters import ClusterState from models_library.clusters import ( @@ -22,7 +23,6 @@ NoAuthentication, TLSAuthentication, ) -from models_library.utils.json_serialization import json_dumps from pydantic import ByteSize, TypeAdapter from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict, setenvs_from_dict from simcore_service_clusters_keeper.core.settings import ApplicationSettings diff --git a/services/director-v2/src/simcore_service_director_v2/api/routes/dynamic_services.py b/services/director-v2/src/simcore_service_director_v2/api/routes/dynamic_services.py index 750f634bb3b..743d7ae2a66 100644 --- a/services/director-v2/src/simcore_service_director_v2/api/routes/dynamic_services.py +++ b/services/director-v2/src/simcore_service_director_v2/api/routes/dynamic_services.py @@ -3,6 +3,7 @@ from typing import Annotated, Final import httpx +from common_library.json_serialization import json_dumps from fastapi import APIRouter, Depends, Header, HTTPException, Request from fastapi.responses import RedirectResponse from models_library.api_schemas_directorv2.dynamic_services import ( @@ -18,7 +19,6 @@ from models_library.service_settings_labels import SimcoreServiceLabels from models_library.services import ServiceKeyVersion from models_library.users import UserID -from models_library.utils.json_serialization import json_dumps from pydantic import NonNegativeFloat, NonNegativeInt from servicelib.fastapi.requests_decorators import cancel_on_disconnect from servicelib.logging_utils import log_decorator diff --git a/services/director-v2/src/simcore_service_director_v2/modules/db/events.py b/services/director-v2/src/simcore_service_director_v2/modules/db/events.py index 63a74aec2df..5570664bd22 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/db/events.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/db/events.py @@ -2,8 +2,8 @@ from aiopg.sa import Engine, create_engine from aiopg.sa.engine import get_dialect +from common_library.json_serialization import json_dumps from fastapi import FastAPI -from models_library.utils.json_serialization import json_dumps from servicelib.retry_policies import PostgresRetryPolicyUponInitialization from settings_library.postgres import PostgresSettings from simcore_postgres_database.utils_aiopg import ( diff --git a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_api/_core.py b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_api/_core.py index b36f17af9e5..dd80c484279 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_api/_core.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_api/_core.py @@ -5,6 +5,7 @@ import aiodocker from aiodocker.utils import clean_filters, clean_map +from common_library.json_serialization import json_dumps from fastapi.encoders import jsonable_encoder from models_library.aiodocker_api import AioDockerServiceSpec from models_library.docker import to_simcore_runtime_docker_label_key @@ -12,7 +13,6 @@ from models_library.projects_networks import DockerNetworkName from models_library.projects_nodes_io import NodeID from models_library.services_enums import ServiceState -from models_library.utils.json_serialization import json_dumps from servicelib.utils import logged_gather from starlette import status from tenacity import TryAgain, retry diff --git a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_compose_specs.py b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_compose_specs.py index c3e0a06fe64..b9d38ca6502 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_compose_specs.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_compose_specs.py @@ -2,6 +2,7 @@ from copy import deepcopy from typing import Any, Final, TypeAlias, TypedDict +from common_library.json_serialization import json_dumps from fastapi.applications import FastAPI from models_library.docker import DockerGenericTag, StandardSimcoreDockerLabels from models_library.products import ProductName @@ -21,7 +22,6 @@ ) from models_library.users import UserID from models_library.utils.docker_compose import replace_env_vars_in_compose_spec -from models_library.utils.json_serialization import json_dumps from pydantic import ByteSize from servicelib.resources import CPU_RESOURCE_LIMIT_KEY, MEM_RESOURCE_LIMIT_KEY from settings_library.docker_registry import RegistrySettings diff --git a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_service_specs/sidecar.py b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_service_specs/sidecar.py index b788e455cf3..001e549bf57 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_service_specs/sidecar.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/docker_service_specs/sidecar.py @@ -2,6 +2,7 @@ from copy import deepcopy from typing import Any, NamedTuple +from common_library.json_serialization import json_dumps from models_library.aiodocker_api import AioDockerServiceSpec from models_library.basic_types import BootModeEnum, PortInt from models_library.callbacks_mapping import CallbacksMapping @@ -14,7 +15,6 @@ ) from models_library.resource_tracker import HardwareInfo from models_library.service_settings_labels import SimcoreServiceSettingsLabel -from models_library.utils.json_serialization import json_dumps from pydantic import ByteSize, parse_obj_as from servicelib.rabbitmq import RabbitMQRPCClient from servicelib.rabbitmq.rpc_interfaces.efs_guardian import efs_manager diff --git a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_event_create_sidecars.py b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_event_create_sidecars.py index 0d7f2f8288f..6475e324950 100644 --- a/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_event_create_sidecars.py +++ b/services/director-v2/src/simcore_service_director_v2/modules/dynamic_sidecar/scheduler/_core/_event_create_sidecars.py @@ -3,6 +3,7 @@ import logging from typing import Any, Final +from common_library.json_serialization import json_dumps from fastapi import FastAPI from fastapi.encoders import jsonable_encoder from models_library.aiodocker_api import AioDockerServiceSpec @@ -17,7 +18,6 @@ ) from models_library.service_settings_labels import SimcoreServiceSettingsLabel from models_library.services import RunID -from models_library.utils.json_serialization import json_dumps from servicelib.rabbitmq import RabbitMQClient, RabbitMQRPCClient from simcore_postgres_database.models.comp_tasks import NodeClass diff --git a/services/director-v2/src/simcore_service_director_v2/utils/dask.py b/services/director-v2/src/simcore_service_director_v2/utils/dask.py index c6229bacdc8..452f1ba50a9 100644 --- a/services/director-v2/src/simcore_service_director_v2/utils/dask.py +++ b/services/director-v2/src/simcore_service_director_v2/utils/dask.py @@ -8,6 +8,7 @@ import dask_gateway # type: ignore[import-untyped] import distributed from aiopg.sa.engine import Engine +from common_library.json_serialization import json_dumps from dask_task_models_library.container_tasks.io import ( FileUrl, PortValue, @@ -29,7 +30,6 @@ from models_library.projects_nodes_io import NodeID, NodeIDStr from models_library.services import ServiceKey, ServiceVersion from models_library.users import UserID -from models_library.utils.json_serialization import json_dumps from pydantic import AnyUrl, ByteSize, ValidationError, parse_obj_as from servicelib.logging_utils import log_catch, log_context from simcore_sdk import node_ports_v2 diff --git a/services/director-v2/tests/unit/test_modules_dynamic_sidecar_client_api_public.py b/services/director-v2/tests/unit/test_modules_dynamic_sidecar_client_api_public.py index 69c1b9bc11b..a38a5a06197 100644 --- a/services/director-v2/tests/unit/test_modules_dynamic_sidecar_client_api_public.py +++ b/services/director-v2/tests/unit/test_modules_dynamic_sidecar_client_api_public.py @@ -6,11 +6,11 @@ from unittest.mock import AsyncMock import pytest +from common_library.json_serialization import json_dumps from faker import Faker from fastapi import FastAPI, status from httpx import HTTPError, Response from models_library.sidecar_volumes import VolumeCategory, VolumeStatus -from models_library.utils.json_serialization import json_dumps from pydantic import AnyHttpUrl, parse_obj_as from pytest_mock import MockerFixture from pytest_simcore.helpers.typing_env import EnvVarsDict diff --git a/services/director-v2/tests/unit/with_dbs/test_modules_dynamic_sidecar_docker_service_specs.py b/services/director-v2/tests/unit/with_dbs/test_modules_dynamic_sidecar_docker_service_specs.py index a05e4cd84da..edca0dfe03c 100644 --- a/services/director-v2/tests/unit/with_dbs/test_modules_dynamic_sidecar_docker_service_specs.py +++ b/services/director-v2/tests/unit/with_dbs/test_modules_dynamic_sidecar_docker_service_specs.py @@ -10,6 +10,7 @@ import pytest import respx +from common_library.json_serialization import json_dumps from faker import Faker from fastapi import FastAPI from fastapi.encoders import jsonable_encoder @@ -25,7 +26,6 @@ SimcoreServiceSettingsLabel, ) from models_library.services import RunID, ServiceKeyVersion -from models_library.utils.json_serialization import json_dumps from models_library.wallets import WalletInfo from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict from pytest_simcore.helpers.typing_env import EnvVarsDict diff --git a/services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/services/director_v2/_thin_client.py b/services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/services/director_v2/_thin_client.py index e823216576b..9b7fd4be9d4 100644 --- a/services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/services/director_v2/_thin_client.py +++ b/services/dynamic-scheduler/src/simcore_service_dynamic_scheduler/services/director_v2/_thin_client.py @@ -1,6 +1,7 @@ import datetime from typing import cast +from common_library.json_serialization import json_dumps from fastapi import FastAPI, status from httpx import Response, Timeout from models_library.api_schemas_dynamic_scheduler.dynamic_services import ( @@ -8,7 +9,6 @@ ) from models_library.projects_nodes_io import NodeID from models_library.services_resources import ServiceResourcesDictHelpers -from models_library.utils.json_serialization import json_dumps from servicelib.common_headers import ( X_DYNAMIC_SIDECAR_REQUEST_DNS, X_DYNAMIC_SIDECAR_REQUEST_SCHEME, diff --git a/services/dynamic-sidecar/tests/conftest.py b/services/dynamic-sidecar/tests/conftest.py index 0dc55477b47..04e76ecd7e2 100644 --- a/services/dynamic-sidecar/tests/conftest.py +++ b/services/dynamic-sidecar/tests/conftest.py @@ -14,13 +14,13 @@ import pytest import simcore_service_dynamic_sidecar +from common_library.json_serialization import json_dumps from faker import Faker from models_library.projects import ProjectID from models_library.projects_nodes import NodeID from models_library.services import RunID from models_library.services_creation import CreateServiceMetricsAdditionalParams from models_library.users import UserID -from models_library.utils.json_serialization import json_dumps from pydantic import TypeAdapter from pytest_mock.plugin import MockerFixture from pytest_simcore.helpers.monkeypatch_envs import ( diff --git a/services/dynamic-sidecar/tests/unit/test_modules_system_monitor__disk_usage.py b/services/dynamic-sidecar/tests/unit/test_modules_system_monitor__disk_usage.py index 97a65d4553b..06270e171ca 100644 --- a/services/dynamic-sidecar/tests/unit/test_modules_system_monitor__disk_usage.py +++ b/services/dynamic-sidecar/tests/unit/test_modules_system_monitor__disk_usage.py @@ -8,6 +8,7 @@ from unittest.mock import AsyncMock, Mock import pytest +from common_library.json_serialization import json_dumps from faker import Faker from fastapi import FastAPI from models_library.api_schemas_dynamic_sidecar.telemetry import ( @@ -17,7 +18,6 @@ from models_library.projects_nodes_io import NodeID from models_library.services_types import RunID from models_library.users import UserID -from models_library.utils.json_serialization import json_dumps from psutil._common import sdiskusage from pydantic import ByteSize, TypeAdapter from pytest_mock import MockerFixture diff --git a/services/payments/src/simcore_service_payments/cli.py b/services/payments/src/simcore_service_payments/cli.py index db884e5f99f..d493ba884bd 100644 --- a/services/payments/src/simcore_service_payments/cli.py +++ b/services/payments/src/simcore_service_payments/cli.py @@ -3,7 +3,7 @@ import os import typer -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from servicelib.utils_secrets import generate_password, generate_token_secret_key from settings_library.postgres import PostgresSettings from settings_library.rabbit import RabbitSettings diff --git a/services/storage/src/simcore_service_storage/handlers_datasets.py b/services/storage/src/simcore_service_storage/handlers_datasets.py index 69b345247e2..2cd510bcf79 100644 --- a/services/storage/src/simcore_service_storage/handlers_datasets.py +++ b/services/storage/src/simcore_service_storage/handlers_datasets.py @@ -2,9 +2,9 @@ from aiohttp import web from aiohttp.web import RouteTableDef +from common_library.json_serialization import json_dumps from models_library.api_schemas_storage import FileMetaDataGet from models_library.utils.fastapi_encoders import jsonable_encoder -from models_library.utils.json_serialization import json_dumps from servicelib.aiohttp.requests_validation import ( parse_request_path_parameters_as, parse_request_query_parameters_as, diff --git a/services/storage/src/simcore_service_storage/handlers_files.py b/services/storage/src/simcore_service_storage/handlers_files.py index b7ad6ebb007..0f78fdaeea5 100644 --- a/services/storage/src/simcore_service_storage/handlers_files.py +++ b/services/storage/src/simcore_service_storage/handlers_files.py @@ -5,6 +5,7 @@ from aiohttp import web from aiohttp.web import RouteTableDef +from common_library.json_serialization import json_dumps from models_library.api_schemas_storage import ( FileMetaDataGet, FileUploadCompleteFutureResponse, @@ -17,7 +18,6 @@ SoftCopyBody, ) from models_library.utils.fastapi_encoders import jsonable_encoder -from models_library.utils.json_serialization import json_dumps from pydantic import AnyUrl, ByteSize, TypeAdapter from servicelib.aiohttp import status from servicelib.aiohttp.requests_validation import ( diff --git a/services/storage/src/simcore_service_storage/handlers_health.py b/services/storage/src/simcore_service_storage/handlers_health.py index 5be7fda4e23..eb97bafe1ba 100644 --- a/services/storage/src/simcore_service_storage/handlers_health.py +++ b/services/storage/src/simcore_service_storage/handlers_health.py @@ -8,9 +8,9 @@ from aiohttp import web from aws_library.s3 import S3AccessError +from common_library.json_serialization import json_dumps from models_library.api_schemas_storage import HealthCheck, S3BucketName from models_library.app_diagnostics import AppStatusCheck -from models_library.utils.json_serialization import json_dumps from pydantic import TypeAdapter from servicelib.rest_constants import RESPONSE_MODEL_POLICY diff --git a/services/storage/src/simcore_service_storage/handlers_locations.py b/services/storage/src/simcore_service_storage/handlers_locations.py index 0144d1c0910..494c1821f15 100644 --- a/services/storage/src/simcore_service_storage/handlers_locations.py +++ b/services/storage/src/simcore_service_storage/handlers_locations.py @@ -4,9 +4,9 @@ from aiohttp import web from aiohttp.web import RouteTableDef +from common_library.json_serialization import json_dumps from models_library.api_schemas_storage import FileLocation from models_library.projects_nodes_io import StorageFileID -from models_library.utils.json_serialization import json_dumps from servicelib.aiohttp.application_keys import ( APP_CONFIG_KEY, APP_FIRE_AND_FORGET_TASKS_KEY, diff --git a/services/storage/src/simcore_service_storage/handlers_simcore_s3.py b/services/storage/src/simcore_service_storage/handlers_simcore_s3.py index 47dd35bc6bc..248c415b23f 100644 --- a/services/storage/src/simcore_service_storage/handlers_simcore_s3.py +++ b/services/storage/src/simcore_service_storage/handlers_simcore_s3.py @@ -3,10 +3,10 @@ from aiohttp import web from aiohttp.web import RouteTableDef +from common_library.json_serialization import json_dumps from models_library.api_schemas_storage import FileMetaDataGet, FoldersBody from models_library.projects import ProjectID from models_library.utils.fastapi_encoders import jsonable_encoder -from models_library.utils.json_serialization import json_dumps from servicelib.aiohttp import status from servicelib.aiohttp.long_running_tasks.server import ( TaskProgress, diff --git a/services/storage/src/simcore_service_storage/s3.py b/services/storage/src/simcore_service_storage/s3.py index 8814db3757a..a3fa2c3e10b 100644 --- a/services/storage/src/simcore_service_storage/s3.py +++ b/services/storage/src/simcore_service_storage/s3.py @@ -8,7 +8,7 @@ from aiohttp import web from aws_library.s3 import SimcoreS3API -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from servicelib.logging_utils import log_context from tenacity.asyncio import AsyncRetrying from tenacity.before_sleep import before_sleep_log diff --git a/services/web/server/src/simcore_service_webserver/db/_aiopg.py b/services/web/server/src/simcore_service_webserver/db/_aiopg.py index f6944e5ef67..4a45a0a00fb 100644 --- a/services/web/server/src/simcore_service_webserver/db/_aiopg.py +++ b/services/web/server/src/simcore_service_webserver/db/_aiopg.py @@ -10,7 +10,7 @@ from aiohttp import web from aiopg.sa import Engine, create_engine -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from servicelib.aiohttp.aiopg_utils import is_pg_responsive from servicelib.aiohttp.application_keys import APP_AIOPG_ENGINE_KEY from servicelib.logging_utils import log_context diff --git a/services/web/server/src/simcore_service_webserver/director_v2/_handlers.py b/services/web/server/src/simcore_service_webserver/director_v2/_handlers.py index f794fa6f148..daffd3be369 100644 --- a/services/web/server/src/simcore_service_webserver/director_v2/_handlers.py +++ b/services/web/server/src/simcore_service_webserver/director_v2/_handlers.py @@ -3,11 +3,11 @@ from typing import Any from aiohttp import web +from common_library.json_serialization import json_dumps from models_library.api_schemas_webserver.computations import ComputationStart from models_library.clusters import ClusterID from models_library.projects import ProjectID from models_library.users import UserID -from models_library.utils.json_serialization import json_dumps from pydantic import BaseModel, Field, ValidationError, parse_obj_as from pydantic.types import NonNegativeInt from servicelib.aiohttp import status diff --git a/services/web/server/src/simcore_service_webserver/exporter/_formatter/template_json.py b/services/web/server/src/simcore_service_webserver/exporter/_formatter/template_json.py index a8ddfd32f2a..e543510155c 100644 --- a/services/web/server/src/simcore_service_webserver/exporter/_formatter/template_json.py +++ b/services/web/server/src/simcore_service_webserver/exporter/_formatter/template_json.py @@ -1,7 +1,7 @@ from pathlib import Path import aiofiles -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from ...projects.models import ProjectDict diff --git a/services/web/server/src/simcore_service_webserver/groups/_handlers.py b/services/web/server/src/simcore_service_webserver/groups/_handlers.py index b6284bed8bf..ba366aaef46 100644 --- a/services/web/server/src/simcore_service_webserver/groups/_handlers.py +++ b/services/web/server/src/simcore_service_webserver/groups/_handlers.py @@ -4,6 +4,7 @@ from typing import Literal from aiohttp import web +from common_library.json_serialization import json_dumps from models_library.api_schemas_webserver.groups import ( AllUsersGroups, GroupUserGet, @@ -11,7 +12,6 @@ ) from models_library.emails import LowerCaseEmailStr from models_library.users import GroupID, UserID -from models_library.utils.json_serialization import json_dumps from pydantic import BaseModel, Extra, Field, parse_obj_as from servicelib.aiohttp import status from servicelib.aiohttp.requests_validation import ( diff --git a/services/web/server/src/simcore_service_webserver/login/_registration_api.py b/services/web/server/src/simcore_service_webserver/login/_registration_api.py index 1dfd1a5a500..b11dca73662 100644 --- a/services/web/server/src/simcore_service_webserver/login/_registration_api.py +++ b/services/web/server/src/simcore_service_webserver/login/_registration_api.py @@ -5,9 +5,9 @@ from aiohttp import web from captcha.image import ImageCaptcha +from common_library.json_serialization import json_dumps from models_library.emails import LowerCaseEmailStr from models_library.utils.fastapi_encoders import jsonable_encoder -from models_library.utils.json_serialization import json_dumps from PIL.Image import Image from pydantic import EmailStr, PositiveInt, ValidationError, parse_obj_as from servicelib.utils_secrets import generate_passcode diff --git a/services/web/server/src/simcore_service_webserver/login/utils.py b/services/web/server/src/simcore_service_webserver/login/utils.py index 0e5c4ef47f2..07cc9a4154c 100644 --- a/services/web/server/src/simcore_service_webserver/login/utils.py +++ b/services/web/server/src/simcore_service_webserver/login/utils.py @@ -2,9 +2,9 @@ from typing import Any from aiohttp import web +from common_library.json_serialization import json_dumps from models_library.products import ProductName from models_library.users import UserID -from models_library.utils.json_serialization import json_dumps from pydantic import PositiveInt from servicelib.aiohttp import observer from servicelib.aiohttp.rest_models import LogMessageType diff --git a/services/web/server/src/simcore_service_webserver/meta_modeling/_iterations.py b/services/web/server/src/simcore_service_webserver/meta_modeling/_iterations.py index c4b16f12caf..4cfd2bfca24 100644 --- a/services/web/server/src/simcore_service_webserver/meta_modeling/_iterations.py +++ b/services/web/server/src/simcore_service_webserver/meta_modeling/_iterations.py @@ -10,13 +10,13 @@ from typing import Any, Literal, Optional from aiohttp import web +from common_library.json_serialization import json_dumps from models_library.basic_types import KeyIDStr, SHA1Str from models_library.function_services_catalog import is_iterator_service from models_library.projects import ProjectID from models_library.projects_nodes import Node, OutputID, OutputTypes from models_library.projects_nodes_io import NodeID from models_library.services import ServiceMetaDataPublished -from models_library.utils.json_serialization import json_dumps from pydantic import BaseModel, ValidationError from pydantic.fields import Field from pydantic.types import PositiveInt diff --git a/services/web/server/src/simcore_service_webserver/projects/_crud_api_create.py b/services/web/server/src/simcore_service_webserver/projects/_crud_api_create.py index 37416912e15..4886b3b6242 100644 --- a/services/web/server/src/simcore_service_webserver/projects/_crud_api_create.py +++ b/services/web/server/src/simcore_service_webserver/projects/_crud_api_create.py @@ -5,6 +5,7 @@ from typing import Any, TypeAlias from aiohttp import web +from common_library.json_serialization import json_dumps from jsonschema import ValidationError as JsonSchemaValidationError from models_library.api_schemas_long_running_tasks.base import ProgressPercent from models_library.api_schemas_webserver.projects import ProjectGet @@ -13,7 +14,6 @@ from models_library.projects_state import ProjectStatus from models_library.users import UserID from models_library.utils.fastapi_encoders import jsonable_encoder -from models_library.utils.json_serialization import json_dumps from models_library.workspaces import UserWorkspaceAccessRightsDB from pydantic import parse_obj_as from servicelib.aiohttp.long_running_tasks.server import TaskProgress diff --git a/services/web/server/src/simcore_service_webserver/projects/_crud_handlers.py b/services/web/server/src/simcore_service_webserver/projects/_crud_handlers.py index 11d1f701b32..8041e83a07d 100644 --- a/services/web/server/src/simcore_service_webserver/projects/_crud_handlers.py +++ b/services/web/server/src/simcore_service_webserver/projects/_crud_handlers.py @@ -9,6 +9,7 @@ import logging from aiohttp import web +from common_library.json_serialization import json_dumps from jsonschema import ValidationError as JsonSchemaValidationError from models_library.api_schemas_webserver.projects import ( EmptyModel, @@ -24,7 +25,6 @@ from models_library.rest_pagination import Page from models_library.rest_pagination_utils import paginate_data from models_library.utils.fastapi_encoders import jsonable_encoder -from models_library.utils.json_serialization import json_dumps from pydantic import parse_obj_as from servicelib.aiohttp import status from servicelib.aiohttp.long_running_tasks.server import start_long_running_task diff --git a/services/web/server/src/simcore_service_webserver/projects/_nodes_handlers.py b/services/web/server/src/simcore_service_webserver/projects/_nodes_handlers.py index fd7a21eaad6..daeb1e454e0 100644 --- a/services/web/server/src/simcore_service_webserver/projects/_nodes_handlers.py +++ b/services/web/server/src/simcore_service_webserver/projects/_nodes_handlers.py @@ -7,6 +7,7 @@ import logging from aiohttp import web +from common_library.json_serialization import json_dumps from models_library.api_schemas_catalog.service_access_rights import ( ServiceAccessRightsGet, ) @@ -31,7 +32,6 @@ from models_library.services_resources import ServiceResourcesDict from models_library.users import GroupID from models_library.utils.fastapi_encoders import jsonable_encoder -from models_library.utils.json_serialization import json_dumps from pydantic import BaseModel, Field, parse_obj_as from servicelib.aiohttp import status from servicelib.aiohttp.long_running_tasks.server import ( diff --git a/services/web/server/src/simcore_service_webserver/projects/_ports_handlers.py b/services/web/server/src/simcore_service_webserver/projects/_ports_handlers.py index 0d2fb6f3eca..40e33893428 100644 --- a/services/web/server/src/simcore_service_webserver/projects/_ports_handlers.py +++ b/services/web/server/src/simcore_service_webserver/projects/_ports_handlers.py @@ -9,6 +9,7 @@ from typing import Any, Literal from aiohttp import web +from common_library.json_serialization import json_dumps from models_library.api_schemas_webserver.projects_ports import ( ProjectInputGet, ProjectInputUpdate, @@ -20,7 +21,6 @@ from models_library.projects_nodes_io import NodeID from models_library.users import UserID from models_library.utils.fastapi_encoders import jsonable_encoder -from models_library.utils.json_serialization import json_dumps from models_library.utils.services_io import JsonSchemaDict from pydantic import BaseModel, Field, parse_obj_as from servicelib.aiohttp.requests_validation import ( diff --git a/services/web/server/src/simcore_service_webserver/projects/projects_api.py b/services/web/server/src/simcore_service_webserver/projects/projects_api.py index 8a5e69c39ce..38cd5368044 100644 --- a/services/web/server/src/simcore_service_webserver/projects/projects_api.py +++ b/services/web/server/src/simcore_service_webserver/projects/projects_api.py @@ -22,6 +22,7 @@ from uuid import UUID, uuid4 from aiohttp import web +from common_library.json_serialization import json_dumps from models_library.api_schemas_clusters_keeper.ec2_instances import EC2InstanceTypeGet from models_library.api_schemas_directorv2.dynamic_services import ( GetProjectInactivityResponse, @@ -60,7 +61,6 @@ from models_library.socketio import SocketMessageDict from models_library.users import GroupID, UserID from models_library.utils.fastapi_encoders import jsonable_encoder -from models_library.utils.json_serialization import json_dumps from models_library.wallets import ZERO_CREDITS, WalletID, WalletInfo from models_library.workspaces import UserWorkspaceAccessRightsDB from pydantic import ByteSize, parse_obj_as diff --git a/services/web/server/src/simcore_service_webserver/publications/_handlers.py b/services/web/server/src/simcore_service_webserver/publications/_handlers.py index 2d7feef016f..2653bba1390 100644 --- a/services/web/server/src/simcore_service_webserver/publications/_handlers.py +++ b/services/web/server/src/simcore_service_webserver/publications/_handlers.py @@ -1,8 +1,8 @@ import logging from aiohttp import MultipartReader, hdrs, web +from common_library.json_serialization import json_dumps from json2html import json2html # type: ignore[import-untyped] -from models_library.utils.json_serialization import json_dumps from servicelib.aiohttp import status from servicelib.mimetype_constants import ( MIMETYPE_APPLICATION_JSON, diff --git a/services/web/server/src/simcore_service_webserver/socketio/server.py b/services/web/server/src/simcore_service_webserver/socketio/server.py index fed57e4d57e..617af26072f 100644 --- a/services/web/server/src/simcore_service_webserver/socketio/server.py +++ b/services/web/server/src/simcore_service_webserver/socketio/server.py @@ -3,7 +3,7 @@ from collections.abc import AsyncIterator from aiohttp import web -from models_library.utils.json_serialization import JsonNamespace +from common_library.json_serialization import JsonNamespace from servicelib.socketio_utils import cleanup_socketio_async_pubsub_manager from socketio import AsyncAioPikaManager, AsyncServer # type: ignore[import-untyped] diff --git a/services/web/server/src/simcore_service_webserver/statics/_events.py b/services/web/server/src/simcore_service_webserver/statics/_events.py index 49cef6deb64..4348fa5ef3d 100644 --- a/services/web/server/src/simcore_service_webserver/statics/_events.py +++ b/services/web/server/src/simcore_service_webserver/statics/_events.py @@ -6,7 +6,7 @@ from aiohttp import web from aiohttp.client import ClientSession from aiohttp.client_exceptions import ClientConnectionError, ClientError -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from servicelib.aiohttp.client_session import get_client_session from tenacity.asyncio import AsyncRetrying from tenacity.before import before_log diff --git a/services/web/server/src/simcore_service_webserver/users/schemas.py b/services/web/server/src/simcore_service_webserver/users/schemas.py index 53c9ee9b756..cae3f5b7df5 100644 --- a/services/web/server/src/simcore_service_webserver/users/schemas.py +++ b/services/web/server/src/simcore_service_webserver/users/schemas.py @@ -2,12 +2,12 @@ from typing import Any, ClassVar, Literal from uuid import UUID +from common_library.json_serialization import json_dumps from models_library.api_schemas_webserver._base import OutputSchema from models_library.api_schemas_webserver.groups import AllUsersGroups from models_library.api_schemas_webserver.users_preferences import AggregatedPreferences from models_library.emails import LowerCaseEmailStr from models_library.users import FirstNameStr, LastNameStr, UserID -from models_library.utils.json_serialization import json_dumps from pydantic import BaseModel, Field, root_validator, validator from simcore_postgres_database.models.users import UserRole diff --git a/services/web/server/src/simcore_service_webserver/utils_aiohttp.py b/services/web/server/src/simcore_service_webserver/utils_aiohttp.py index ae35a58ee6f..4adaa5ef468 100644 --- a/services/web/server/src/simcore_service_webserver/utils_aiohttp.py +++ b/services/web/server/src/simcore_service_webserver/utils_aiohttp.py @@ -6,8 +6,8 @@ from aiohttp import web from aiohttp.web_exceptions import HTTPError, HTTPException from aiohttp.web_routedef import RouteDef, RouteTableDef +from common_library.json_serialization import json_dumps from models_library.generics import Envelope -from models_library.utils.json_serialization import json_dumps from pydantic import BaseModel, Field from pydantic.generics import GenericModel from servicelib.common_headers import X_FORWARDED_PROTO diff --git a/services/web/server/src/simcore_service_webserver/utils_rate_limiting.py b/services/web/server/src/simcore_service_webserver/utils_rate_limiting.py index 3c16f2b3340..8c1117300ca 100644 --- a/services/web/server/src/simcore_service_webserver/utils_rate_limiting.py +++ b/services/web/server/src/simcore_service_webserver/utils_rate_limiting.py @@ -5,7 +5,7 @@ from typing import Callable, NamedTuple from aiohttp.web_exceptions import HTTPTooManyRequests -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps class RateLimitSetup(NamedTuple): diff --git a/services/web/server/src/simcore_service_webserver/version_control/_handlers_base.py b/services/web/server/src/simcore_service_webserver/version_control/_handlers_base.py index 171cf937704..c40b27946f2 100644 --- a/services/web/server/src/simcore_service_webserver/version_control/_handlers_base.py +++ b/services/web/server/src/simcore_service_webserver/version_control/_handlers_base.py @@ -3,7 +3,7 @@ from typing import Any from aiohttp import web -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from pydantic.error_wrappers import ValidationError from servicelib.aiohttp.typing_extension import Handler diff --git a/services/web/server/src/simcore_service_webserver/version_control/db.py b/services/web/server/src/simcore_service_webserver/version_control/db.py index 9ae6162c09e..ee884df6e9c 100644 --- a/services/web/server/src/simcore_service_webserver/version_control/db.py +++ b/services/web/server/src/simcore_service_webserver/version_control/db.py @@ -7,9 +7,9 @@ import sqlalchemy as sa from aiopg.sa import SAConnection from aiopg.sa.result import RowProxy +from common_library.json_serialization import json_dumps from models_library.basic_types import SHA1Str from models_library.projects import ProjectIDStr -from models_library.utils.json_serialization import json_dumps from pydantic.types import NonNegativeInt, PositiveInt from simcore_postgres_database.models.projects import projects from simcore_postgres_database.models.projects_version_control import ( diff --git a/services/web/server/tests/conftest.py b/services/web/server/tests/conftest.py index a57dfd3c852..76fc55eba28 100644 --- a/services/web/server/tests/conftest.py +++ b/services/web/server/tests/conftest.py @@ -16,11 +16,11 @@ import pytest import simcore_service_webserver from aiohttp.test_utils import TestClient +from common_library.json_serialization import json_dumps from faker import Faker from models_library.projects import ProjectID from models_library.projects_nodes_io import NodeID from models_library.projects_state import ProjectState -from models_library.utils.json_serialization import json_dumps from pytest_simcore.helpers.assert_checks import assert_status from pytest_simcore.helpers.dict_tools import ConfigDict from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict, setenvs_from_dict diff --git a/services/web/server/tests/integration/02/test_computation.py b/services/web/server/tests/integration/02/test_computation.py index 0a73402e68d..4dcb55e19d9 100644 --- a/services/web/server/tests/integration/02/test_computation.py +++ b/services/web/server/tests/integration/02/test_computation.py @@ -15,8 +15,8 @@ import pytest import sqlalchemy as sa from aiohttp.test_utils import TestClient +from common_library.json_serialization import json_dumps from models_library.projects_state import RunningState -from models_library.utils.json_serialization import json_dumps from pytest_simcore.helpers.assert_checks import assert_status from servicelib.aiohttp import status from servicelib.aiohttp.application import create_safe_application diff --git a/services/web/server/tests/unit/isolated/test_application_settings.py b/services/web/server/tests/unit/isolated/test_application_settings.py index 65fe54ff483..17e3502bfa5 100644 --- a/services/web/server/tests/unit/isolated/test_application_settings.py +++ b/services/web/server/tests/unit/isolated/test_application_settings.py @@ -6,7 +6,7 @@ import pytest from aiohttp import web -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from pydantic import HttpUrl, parse_obj_as from pytest_simcore.helpers.typing_env import EnvVarsDict from simcore_service_webserver.application_settings import ( diff --git a/services/web/server/tests/unit/isolated/test_products_model.py b/services/web/server/tests/unit/isolated/test_products_model.py index 45ecbd0f4c3..31c4ac60699 100644 --- a/services/web/server/tests/unit/isolated/test_products_model.py +++ b/services/web/server/tests/unit/isolated/test_products_model.py @@ -6,7 +6,7 @@ from typing import Any import pytest -from models_library.utils.json_serialization import json_dumps +from common_library.json_serialization import json_dumps from pydantic import BaseModel from simcore_service_webserver.products._db import Product diff --git a/services/web/server/tests/unit/with_dbs/01/studies_dispatcher/test_studies_dispatcher_handlers.py b/services/web/server/tests/unit/with_dbs/01/studies_dispatcher/test_studies_dispatcher_handlers.py index 7933270984a..420adf921ac 100644 --- a/services/web/server/tests/unit/with_dbs/01/studies_dispatcher/test_studies_dispatcher_handlers.py +++ b/services/web/server/tests/unit/with_dbs/01/studies_dispatcher/test_studies_dispatcher_handlers.py @@ -16,8 +16,8 @@ from aiohttp import ClientResponse, ClientSession from aiohttp.test_utils import TestClient, TestServer from aioresponses import aioresponses +from common_library.json_serialization import json_dumps from models_library.projects_state import ProjectLocked, ProjectStatus -from models_library.utils.json_serialization import json_dumps from pydantic import BaseModel, ByteSize, parse_obj_as from pytest_mock import MockerFixture from pytest_simcore.helpers.assert_checks import assert_status diff --git a/services/web/server/tests/unit/with_dbs/03/meta_modeling/test_meta_modeling_iterations.py b/services/web/server/tests/unit/with_dbs/03/meta_modeling/test_meta_modeling_iterations.py index 20cb885bdfa..ec22f84f441 100644 --- a/services/web/server/tests/unit/with_dbs/03/meta_modeling/test_meta_modeling_iterations.py +++ b/services/web/server/tests/unit/with_dbs/03/meta_modeling/test_meta_modeling_iterations.py @@ -7,11 +7,11 @@ import pytest from aiohttp import ClientResponse from aiohttp.test_utils import TestClient +from common_library.json_serialization import json_dumps from faker import Faker from models_library.projects import Project from models_library.projects_nodes import Node from models_library.services_resources import ServiceResourcesDict -from models_library.utils.json_serialization import json_dumps from pytest_mock import MockerFixture from pytest_simcore.helpers.assert_checks import assert_status from pytest_simcore.helpers.monkeypatch_envs import EnvVarsDict, setenvs_from_dict