Skip to content

Commit 4dfad54

Browse files
fix deprecated
1 parent 67da4f8 commit 4dfad54

File tree

12 files changed

+42
-37
lines changed

12 files changed

+42
-37
lines changed

api/specs/director/schemas/scripts/create_node-meta-schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
if __name__ == "__main__":
1717
with Path.open(CURRENT_DIR.parent / "node-meta-v0.0.1-pydantic.json", "w") as f:
18-
schema = ServiceMetaDataPublished.schema_json()
18+
schema = ServiceMetaDataPublished.model_json_schema()
1919
schema_without_ref = jsonref.loads(schema)
2020

2121
json.dump(schema_without_ref, f, indent=2)

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

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,27 @@ def _check_size(cls, v, info: ValidationInfo):
5656

5757
@cached_property
5858
def dsn(self) -> str:
59-
dsn: str = str(
60-
PostgresDsn.build( # pylint: disable=no-member
61-
scheme="postgresql",
62-
username=self.POSTGRES_USER,
63-
password=self.POSTGRES_PASSWORD.get_secret_value(),
64-
host=self.POSTGRES_HOST,
65-
port=self.POSTGRES_PORT,
66-
path=f"{self.POSTGRES_DB}",
67-
)
59+
dsn = PostgresDsn.build( # pylint: disable=no-member
60+
scheme="postgresql",
61+
username=self.POSTGRES_USER,
62+
password=self.POSTGRES_PASSWORD.get_secret_value(),
63+
host=self.POSTGRES_HOST,
64+
port=self.POSTGRES_PORT,
65+
path=f"{self.POSTGRES_DB}",
6866
)
69-
return dsn
67+
return f"{dsn}"
7068

7169
@cached_property
7270
def dsn_with_async_sqlalchemy(self) -> str:
73-
dsn: str = str(
74-
PostgresDsn.build( # pylint: disable=no-member
75-
scheme="postgresql+asyncpg",
76-
username=self.POSTGRES_USER,
77-
password=self.POSTGRES_PASSWORD.get_secret_value(),
78-
host=self.POSTGRES_HOST,
79-
port=self.POSTGRES_PORT,
80-
path=f"{self.POSTGRES_DB}",
81-
)
71+
dsn = PostgresDsn.build( # pylint: disable=no-member
72+
scheme="postgresql+asyncpg",
73+
username=self.POSTGRES_USER,
74+
password=self.POSTGRES_PASSWORD.get_secret_value(),
75+
host=self.POSTGRES_HOST,
76+
port=self.POSTGRES_PORT,
77+
path=f"{self.POSTGRES_DB}",
8278
)
83-
return dsn
79+
return f"{dsn}"
8480

8581
@cached_property
8682
def dsn_with_query(self) -> str:

services/director-v2/src/simcore_service_director_v2/modules/db/repositories/projects_networks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ async def upsert_projects_networks(
3333
)
3434

3535
async with self.db_engine.acquire() as conn:
36-
row_data = json.loads(projects_networks_to_insert.json())
36+
row_data = json.loads(projects_networks_to_insert.model_dump_json())
3737
insert_stmt = pg_insert(projects_networks).values(**row_data)
3838
upsert_snapshot = insert_stmt.on_conflict_do_update(
3939
constraint=projects_networks.primary_key, set_=row_data

services/director-v2/src/simcore_service_director_v2/utils/clients.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import logging
2-
from typing import Any, Union
2+
from typing import Any
33

44
import httpx
55
from fastapi import HTTPException
@@ -9,7 +9,7 @@
99
logger = logging.getLogger(__name__)
1010

1111

12-
def unenvelope_or_raise_error(resp: httpx.Response) -> Union[list[Any], dict[str, Any]]:
12+
def unenvelope_or_raise_error(resp: httpx.Response) -> list[Any] | dict[str, Any]:
1313
"""
1414
Director responses are enveloped
1515
If successful response, we un-envelop it and return data as a dict

services/director-v2/tests/helpers/shared_comp_utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async def assert_and_wait_for_pipeline_status(
6464
MAX_TIMEOUT_S = 5 * MINUTE
6565

6666
async def check_pipeline_state() -> ComputationGet:
67-
response = await client.get(url, params={"user_id": user_id})
67+
response = await client.get(f"{url}", params={"user_id": user_id})
6868
assert (
6969
response.status_code == status.HTTP_200_OK
7070
), f"response code is {response.status_code}, error: {response.text}"
@@ -100,4 +100,5 @@ async def check_pipeline_state() -> ComputationGet:
100100
return task_out
101101

102102
# this is only to satisfy pylance
103-
raise AssertionError("No computation task generated!")
103+
msg = "No computation task generated!"
104+
raise AssertionError(msg)

services/director-v2/tests/integration/02/test_dynamic_sidecar_nodeports_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def mock_env(
403403
"COMPUTATIONAL_BACKEND_ENABLED": "true",
404404
"COMPUTATIONAL_BACKEND_DASK_CLIENT_ENABLED": "true",
405405
"COMPUTATIONAL_BACKEND_DEFAULT_CLUSTER_URL": dask_scheduler_service,
406-
"COMPUTATIONAL_BACKEND_DEFAULT_CLUSTER_AUTH": dask_scheduler_auth.json(),
406+
"COMPUTATIONAL_BACKEND_DEFAULT_CLUSTER_AUTH": dask_scheduler_auth.model_dump_json(),
407407
"DIRECTOR_V2_PROMETHEUS_INSTRUMENTATION_ENABLED": "1",
408408
},
409409
)

services/director-v2/tests/integration/02/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,9 @@ async def patch_dynamic_service_url(app: FastAPI, node_uuid: str) -> str:
263263
proxy_service_name,
264264
target_port=dynamic_sidecar_proxy_settings.DYNAMIC_SIDECAR_CADDY_ADMIN_API_PORT,
265265
)
266-
assert proxy_published_port is not None, f"{sidecar_settings.json()=}"
266+
assert (
267+
proxy_published_port is not None
268+
), f"{sidecar_settings.model_dump_json()=}"
267269

268270
async with scheduler.scheduler._lock: # noqa: SLF001
269271
localhost_ip = get_localhost_ip()
@@ -458,7 +460,7 @@ async def assert_retrieve_service(
458460

459461
size_bytes = json_result["data"]["size_bytes"]
460462
assert size_bytes > 0
461-
assert type(size_bytes) == int
463+
assert isinstance(size_bytes, int)
462464

463465

464466
async def assert_stop_service(

services/director-v2/tests/unit/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def scheduler_data_from_http_request(
123123
def mock_service_inspect(
124124
scheduler_data_from_http_request: ServiceDetails,
125125
) -> Mapping[str, Any]:
126-
service_details = json.loads(scheduler_data_from_http_request.json())
126+
service_details = json.loads(scheduler_data_from_http_request.model_dump_json())
127127
service_details["compose_spec"] = json.dumps(service_details["compose_spec"])
128128
return {
129129
"Spec": {

services/director-v2/tests/unit/test_models_schemas_dynamic_services_scheduler.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from copy import deepcopy
55
from pathlib import Path
66

7-
from pydantic import TypeAdapter
87
import pytest
8+
from pydantic import TypeAdapter
99
from simcore_service_director_v2.models.dynamic_services_scheduler import SchedulerData
1010

1111

@@ -20,7 +20,7 @@ def test_regression_as_label_data(scheduler_data: SchedulerData) -> None:
2020
# old tested implementation
2121
scheduler_data_copy = deepcopy(scheduler_data)
2222
scheduler_data_copy.compose_spec = json.dumps(scheduler_data_copy.compose_spec)
23-
json_encoded = scheduler_data_copy.json()
23+
json_encoded = scheduler_data_copy.model_dump_json()
2424

2525
# using pydantic's internals
2626
label_data = scheduler_data.as_label_data()
@@ -35,4 +35,6 @@ def test_ensure_legacy_format_compatibility(legacy_scheduler_data_format: Path):
3535

3636
# PRs applying changes to the legacy format:
3737
# - https://github.com/ITISFoundation/osparc-simcore/pull/3610
38-
assert TypeAdapter(list[SchedulerData]).validate_json(legacy_scheduler_data_format.read_text())
38+
assert TypeAdapter(list[SchedulerData]).validate_json(
39+
legacy_scheduler_data_format.read_text()
40+
)

services/director-v2/tests/unit/test_modules_rabbitmq.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def message(faker: Faker) -> WalletCreditsLimitReachedMessage:
4444
async def test_handler_out_of_credits(
4545
mock_app: FastAPI, message: WalletCreditsLimitReachedMessage, ignore_limits
4646
):
47-
await handler_out_of_credits(mock_app, message.json().encode())
47+
await handler_out_of_credits(mock_app, message.model_dump_json().encode())
4848

4949
removal_mark_count = (
5050
mock_app.state.dynamic_sidecar_scheduler.mark_all_services_in_wallet_for_removal.call_count

0 commit comments

Comments
 (0)