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

⬆️ WIP: Upgrade services (pydantic v2) #6467

Draft
wants to merge 300 commits into
base: pydantic_v2_migration
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
300 commits
Select commit Hold shift + click to select a range
4fb2bf2
update error base class
giancarloromeo Sep 20, 2024
c11f109
fix folders error
giancarloromeo Sep 20, 2024
68fa4ae
use common osparcerrormixin
giancarloromeo Sep 20, 2024
40a4627
continue upgrading
giancarloromeo Sep 20, 2024
0563d81
upgrade dependencies
giancarloromeo Sep 20, 2024
2094d4f
continue upgrading
giancarloromeo Sep 20, 2024
57b0710
continue upgrading
giancarloromeo Sep 20, 2024
29306b1
continue upgrading
giancarloromeo Sep 22, 2024
a9c3ef3
remove deprecated parse_obj_as
giancarloromeo Sep 23, 2024
8250aff
fix url type
giancarloromeo Sep 23, 2024
6c63ccf
fix url type
giancarloromeo Sep 23, 2024
fd2f6cb
fix rabbit settings
giancarloromeo Sep 23, 2024
7a888f5
upgrade deprecated method
giancarloromeo Sep 23, 2024
b43955c
fix dns* creation
giancarloromeo Sep 23, 2024
a1a7e24
return redis dns as str
giancarloromeo Sep 23, 2024
d74f380
upgrade pydantic dependencies
giancarloromeo Sep 23, 2024
40e34e5
continue upgrading
giancarloromeo Sep 23, 2024
2843a12
continue upgrading
giancarloromeo Sep 23, 2024
c82afa5
fix anyhttpurl validation
giancarloromeo Sep 23, 2024
c96cd21
continue upgrading
giancarloromeo Sep 23, 2024
dfe63b5
continue upgrading
giancarloromeo Sep 23, 2024
0df8f60
add ignore
giancarloromeo Sep 23, 2024
56c1c89
fix errors messages
giancarloromeo Sep 23, 2024
3b15198
continue upgrading
giancarloromeo Sep 23, 2024
bb10a3d
continue upgrading
giancarloromeo Sep 23, 2024
ec0404a
continue upgrading
giancarloromeo Sep 23, 2024
96a0663
continue upgrading
giancarloromeo Sep 23, 2024
ad7ddb5
continue upgrading
giancarloromeo Sep 23, 2024
6369b33
fix test
giancarloromeo Sep 23, 2024
7d5537d
continue upgrading
giancarloromeo Sep 23, 2024
486437d
update error msg
giancarloromeo Sep 23, 2024
0167480
fix model_fields iteration
giancarloromeo Sep 23, 2024
1409f87
fix labels type
giancarloromeo Sep 23, 2024
94749e6
fix root field reference
giancarloromeo Sep 23, 2024
223e2ac
continue upgrading
giancarloromeo Sep 23, 2024
a9d30ab
fix test
giancarloromeo Sep 23, 2024
2a497f3
remove deprecated method
giancarloromeo Sep 23, 2024
32318b0
fix error output
giancarloromeo Sep 23, 2024
45baff8
fix base settings
giancarloromeo Sep 24, 2024
81f80de
fix error
giancarloromeo Sep 24, 2024
1c33bfb
fix error class
giancarloromeo Sep 24, 2024
898155d
fix nullable
giancarloromeo Sep 24, 2024
e3fc9c5
update base
giancarloromeo Sep 24, 2024
e645331
update test
giancarloromeo Sep 24, 2024
ff5533b
restore Error type
giancarloromeo Sep 24, 2024
0eaa8c8
update test
giancarloromeo Sep 24, 2024
9c22d2b
force mode_rebuild
giancarloromeo Sep 25, 2024
4e74ec7
fix port type
giancarloromeo Sep 25, 2024
0e3f7d3
continue upgrading
giancarloromeo Sep 25, 2024
6aaaea1
continue upgrading
giancarloromeo Sep 25, 2024
4ddddc9
fix AnyUrl build
giancarloromeo Sep 25, 2024
8120fff
fix field_info
giancarloromeo Sep 25, 2024
a28234d
fix utils service
giancarloromeo Sep 25, 2024
da97728
fix mypy
giancarloromeo Sep 25, 2024
06912be
set optional
giancarloromeo Sep 25, 2024
a0d6f84
set optional
giancarloromeo Sep 25, 2024
8e62f69
continue upgrading
giancarloromeo Sep 25, 2024
e3510cd
continue upgrading
giancarloromeo Sep 25, 2024
3e8ca5d
continue upgrading
giancarloromeo Sep 25, 2024
fffb812
fix cached property
giancarloromeo Sep 25, 2024
e5f9263
remove pytest.mark
giancarloromeo Sep 25, 2024
cea85f8
Merge branch 'is4481/upgrade-libs' into is4481/upgrade-api-server
giancarloromeo Sep 25, 2024
bc208a2
fix mypy
giancarloromeo Sep 26, 2024
85eb86f
fix parse none env
giancarloromeo Sep 26, 2024
476e538
fix env list parsing
giancarloromeo Sep 26, 2024
f28c414
use BeforeValidator for country codes
giancarloromeo Sep 26, 2024
5d4a6a2
fix mypy
giancarloromeo Sep 26, 2024
1283488
fix utils cli
giancarloromeo Sep 27, 2024
5cecc63
fix encoder issues
giancarloromeo Sep 27, 2024
cbc556f
add requirements
giancarloromeo Sep 27, 2024
4c27843
skip missing data
giancarloromeo Sep 27, 2024
9c4e07e
fix import
giancarloromeo Sep 27, 2024
6c58ae5
fix option name
giancarloromeo Sep 27, 2024
76b5cba
continue ugrading
giancarloromeo Sep 27, 2024
7021117
firx param name
giancarloromeo Sep 27, 2024
5d708b6
Merge branch 'is4481/upgrade-libs' into is4481/upgrade-api-server
giancarloromeo Sep 27, 2024
eae4783
upgrade requirements
giancarloromeo Sep 27, 2024
798912a
run bump-pydantic
giancarloromeo Sep 27, 2024
9eb4519
fix url
giancarloromeo Sep 27, 2024
6cbe7d9
ugprade requirements
giancarloromeo Sep 27, 2024
82c7812
run bump-pydantic
giancarloromeo Sep 27, 2024
b222869
continue upgrading
giancarloromeo Sep 27, 2024
5571be2
upgrade requirements
giancarloromeo Sep 27, 2024
610a8ef
continue upgrading
giancarloromeo Sep 27, 2024
65b00e9
fix issues
giancarloromeo Sep 27, 2024
7eea28e
upgrade requirements
giancarloromeo Sep 27, 2024
824e147
continue upgrading
giancarloromeo Sep 27, 2024
90f045b
upgrade requirements
giancarloromeo Sep 27, 2024
4dda24d
run bump-pydantic
giancarloromeo Sep 27, 2024
9c71e51
upgrade requirements
giancarloromeo Sep 27, 2024
7a20ef7
run bump-pydantic
giancarloromeo Sep 27, 2024
3e2cd3d
upgrade requirements
giancarloromeo Sep 27, 2024
ca1676e
run bump-pydantic
giancarloromeo Sep 27, 2024
c138339
upgrade requirements
giancarloromeo Sep 29, 2024
cd1fbc1
fix mypy
giancarloromeo Sep 30, 2024
4a29d2e
fix mypy
giancarloromeo Sep 30, 2024
532206e
fix rootmodel
giancarloromeo Sep 30, 2024
2cddbd8
continue upgrading
giancarloromeo Sep 30, 2024
32a5453
continue upgrading
giancarloromeo Sep 30, 2024
57f65d5
fix serializer
giancarloromeo Sep 30, 2024
02d950e
fix mypy
giancarloromeo Sep 30, 2024
16a9740
run bump-pydantic
giancarloromeo Sep 30, 2024
04509d3
fix int test
giancarloromeo Sep 30, 2024
10a80b3
fix rabbit method name
giancarloromeo Oct 1, 2024
3f91e30
remove deprecated
giancarloromeo Oct 1, 2024
9ebf506
replace deprecated dict
giancarloromeo Oct 1, 2024
a5d8ed7
Merge remote-tracking branch 'origin/is4481/upgrade-libs' into is4481…
giancarloromeo Oct 1, 2024
acc5c7f
fix validation info
giancarloromeo Oct 1, 2024
9d0bb3e
upgrade requirements
giancarloromeo Oct 1, 2024
0c12d9e
upgrade requirements
giancarloromeo Oct 1, 2024
3f990c5
continue upgrading
giancarloromeo Oct 1, 2024
94c33aa
fix field
giancarloromeo Oct 1, 2024
7b5962a
fix error base class
giancarloromeo Oct 1, 2024
8bbd32f
replace deprecated method
giancarloromeo Oct 1, 2024
9916dc1
upgrade requirements
giancarloromeo Oct 1, 2024
9cdb60b
run bump-pydantic
giancarloromeo Oct 1, 2024
cddd439
replace parse_obj
giancarloromeo Oct 1, 2024
8c0fd00
change config access
giancarloromeo Oct 1, 2024
8d0acc2
upgrade requirements
giancarloromeo Oct 1, 2024
e6c9576
upgrade requirements
giancarloromeo Oct 1, 2024
f004598
upgrade requirements
giancarloromeo Oct 1, 2024
5f03a35
run bump-pydantic
giancarloromeo Oct 1, 2024
713343b
upgrade requirements
giancarloromeo Oct 1, 2024
12ec0a3
upgrade requirements
giancarloromeo Oct 2, 2024
ca36539
fix pylint
giancarloromeo Oct 2, 2024
4e49d2d
fix endopoints type
giancarloromeo Oct 2, 2024
f0fc1d7
fix pagination urls type
giancarloromeo Oct 2, 2024
aa6a73f
fix sonar
giancarloromeo Oct 2, 2024
5debf98
fix code smells
giancarloromeo Oct 2, 2024
9d93d7e
continue upgrading
giancarloromeo Oct 2, 2024
0a1a1a4
continue upgrading
giancarloromeo Oct 2, 2024
32622e0
fix mypy
giancarloromeo Oct 2, 2024
9a6df80
move adapter out
giancarloromeo Oct 2, 2024
8e53f7a
move adapter out
giancarloromeo Oct 2, 2024
9f1c18c
simplify regex
giancarloromeo Oct 2, 2024
64f3aa4
Merge branch 'is4481/upgrade-libs' into is4481/upgrade-services
giancarloromeo Oct 2, 2024
40eb160
fix httpx client
giancarloromeo Oct 2, 2024
7ffe247
upgrade
giancarloromeo Oct 2, 2024
a697a3f
fix mypy
giancarloromeo Oct 2, 2024
301d457
fix mypy
giancarloromeo Oct 2, 2024
1df1179
fix field name
giancarloromeo Oct 3, 2024
9e99c51
fix validationerror match
giancarloromeo Oct 3, 2024
b07d12b
fix optional field
giancarloromeo Oct 3, 2024
444a600
fix comments
giancarloromeo Oct 3, 2024
2a8d6eb
remove redundant comment
giancarloromeo Oct 3, 2024
386c316
remove unnecessary schema patch
giancarloromeo Oct 3, 2024
3a2b56a
Merge branch 'is4481/upgrade-libs' into is4481/upgrade-services
giancarloromeo Oct 3, 2024
68b1599
upgrade CI requrements
giancarloromeo Oct 3, 2024
42a86be
run bump-pydantic
giancarloromeo Oct 3, 2024
12dc421
continue upgrading
giancarloromeo Oct 3, 2024
3aa9009
remove unnecessary cast
giancarloromeo Oct 3, 2024
3b7aa47
Merge branch 'is4481/upgrade-libs' into is4481/upgrade-services
giancarloromeo Oct 4, 2024
4c034d2
add final
giancarloromeo Oct 4, 2024
24679c1
add final
giancarloromeo Oct 4, 2024
b625366
Merge branch 'is4481/upgrade-libs' into is4481/upgrade-services
giancarloromeo Oct 4, 2024
c9f094f
fix ValidationError import
giancarloromeo Oct 4, 2024
fee36c0
fix mypy
giancarloromeo Oct 4, 2024
79a4641
fix missing callback
giancarloromeo Oct 4, 2024
06c8046
fix field name
giancarloromeo Oct 4, 2024
323dbc9
code not used by base class
giancarloromeo Oct 4, 2024
9a8e718
revert latest commit
giancarloromeo Oct 4, 2024
42f07ea
set final
giancarloromeo Oct 4, 2024
18ca9c9
Merge branch 'is4481/upgrade-libs' into is4481/upgrade-services
giancarloromeo Oct 4, 2024
8e756b7
continue fixing
giancarloromeo Oct 4, 2024
ccee1d5
continue upgrading
giancarloromeo Oct 4, 2024
a839523
fix leading / in url
giancarloromeo Oct 4, 2024
1732564
fixed tests in dynamic-scheduler
Oct 5, 2024
968b5ab
Add common library
giancarloromeo Oct 7, 2024
67304b6
add code field
giancarloromeo Oct 7, 2024
9fe7c1a
Merge branch 'is4481/upgrade-libs' into is4481/upgrade-services
giancarloromeo Oct 7, 2024
36cda93
continue upgrading
giancarloromeo Oct 7, 2024
1a73ba0
continue upgrading
giancarloromeo Oct 7, 2024
3f781e6
run bump-pydantic
giancarloromeo Oct 7, 2024
0ce5ef4
fix pylint
giancarloromeo Oct 7, 2024
3f5d881
add base common library
giancarloromeo Oct 7, 2024
df864b4
add error classes
giancarloromeo Oct 7, 2024
09c0073
point to common library
giancarloromeo Oct 7, 2024
d752d18
fix names
giancarloromeo Oct 7, 2024
3f0ec86
remove moved modules
giancarloromeo Oct 7, 2024
4a30d09
fix rename
giancarloromeo Oct 7, 2024
1e57220
add utils
giancarloromeo Oct 7, 2024
cb7ac13
add common modules
giancarloromeo Oct 7, 2024
30e2613
Merge branch 'add-common-library' into is4481/upgrade-libs
giancarloromeo Oct 7, 2024
2663ed1
update requirements
giancarloromeo Oct 7, 2024
e358cd2
upgrade package name
giancarloromeo Oct 7, 2024
0b8a6ab
remove moved modules
giancarloromeo Oct 7, 2024
2b4e79d
update requirements
giancarloromeo Oct 7, 2024
e6efb6d
update requirements
giancarloromeo Oct 7, 2024
51c6ca5
update requirements
giancarloromeo Oct 7, 2024
4265fec
update package name
giancarloromeo Oct 7, 2024
5a998a0
add requirement
giancarloromeo Oct 7, 2024
fc91024
add requirement
giancarloromeo Oct 7, 2024
0ead0b4
update requirements
giancarloromeo Oct 7, 2024
727c634
add py.typed
giancarloromeo Oct 7, 2024
f387ebb
add me as codeowner
giancarloromeo Oct 7, 2024
5ed512a
update requirements
giancarloromeo Oct 7, 2024
7bc8715
update requirements
giancarloromeo Oct 7, 2024
18ad6d1
update requirements
giancarloromeo Oct 7, 2024
f63a537
minor fixes
giancarloromeo Oct 7, 2024
97854a0
Merge branch 'add-common-library' into is4481/upgrade-libs
giancarloromeo Oct 7, 2024
4b93c00
use anyhttpurl legacy
giancarloromeo Oct 7, 2024
9114d67
Merge branch 'pydantic_v2_migration' into is4481/upgrade-libs
giancarloromeo Oct 7, 2024
989e76a
upgrade reqs
giancarloromeo Oct 7, 2024
fa7072d
update reqs
giancarloromeo Oct 7, 2024
a2fd96f
Merge remote-tracking branch 'upstream/is4481/upgrade-services' into …
Oct 8, 2024
23aef7c
Merge remote-tracking branch 'upstream/is4481/upgrade-libs' into upgr…
Oct 8, 2024
f7d71e4
remove out of date comment
Oct 8, 2024
e2252f8
moved to common library
Oct 8, 2024
a746b80
fixed broken imports after migration to common_library
Oct 8, 2024
b8a3f23
fixed errors
Oct 8, 2024
6e76143
Merge branch 'is4481/upgrade-libs' into is4481/upgrade-services
giancarloromeo Oct 8, 2024
a83e3ff
Merge remote-tracking branch 'upstream/is4481/upgrade-services' into …
Oct 8, 2024
bdfd51e
Merge pull request #1 from GitHK/upgrade-dynamic-sceduler
giancarloromeo Oct 8, 2024
cd00aec
ignore assignment
giancarloromeo Oct 8, 2024
b74c9f4
ensure that both the field name and alias work
giancarloromeo Oct 8, 2024
e0c83b0
fix tests
giancarloromeo Oct 8, 2024
bcb907d
fix test
giancarloromeo Oct 8, 2024
9ca9fbc
update reqs
giancarloromeo Oct 8, 2024
25d2735
update reqs
giancarloromeo Oct 8, 2024
0f204cd
fix httpurl field
giancarloromeo Oct 8, 2024
8981b41
upgrade reqs
giancarloromeo Oct 8, 2024
50c8af4
upgrade reqs
giancarloromeo Oct 8, 2024
6fe1544
fix mypy
giancarloromeo Oct 8, 2024
b29329a
fix reqs
giancarloromeo Oct 8, 2024
3cb4ea5
add typeadapter
giancarloromeo Oct 8, 2024
e36b18c
move changes
giancarloromeo Oct 8, 2024
fdd19c6
move base type adapters
giancarloromeo Oct 8, 2024
c913551
fix test
giancarloromeo Oct 8, 2024
890583b
fix type
giancarloromeo Oct 8, 2024
ffd0adc
fix type
giancarloromeo Oct 8, 2024
7663205
fix networks types
giancarloromeo Oct 9, 2024
74330ed
update reqs
giancarloromeo Oct 9, 2024
26348d0
fix type
giancarloromeo Oct 9, 2024
6eb3bf7
fix type
giancarloromeo Oct 9, 2024
b3d0076
fix url types
giancarloromeo Oct 9, 2024
4606e1f
add type hints
giancarloromeo Oct 9, 2024
a37efc1
fix minor
giancarloromeo Oct 9, 2024
638a0be
add validation
giancarloromeo Oct 9, 2024
4151198
Merge branch 'is4481/upgrade-libs' into is4481/upgrade-services
giancarloromeo Oct 9, 2024
8540a81
upgrade web server
giancarloromeo Oct 9, 2024
e64e49d
fix model_config
giancarloromeo Oct 9, 2024
ca1aad2
fix import
giancarloromeo Oct 9, 2024
580cc39
continue upgrading
giancarloromeo Oct 9, 2024
c0af73d
fix test
giancarloromeo Oct 9, 2024
2575237
fix field
giancarloromeo Oct 9, 2024
ac56fe4
fix mypy
giancarloromeo Oct 9, 2024
c34cee9
fix mypy
giancarloromeo Oct 9, 2024
93161aa
fix typo
giancarloromeo Oct 9, 2024
37ee729
fix errors
giancarloromeo Oct 9, 2024
03d6b87
Merge branch 'pydantic_v2_migration' into is4481/upgrade-services
giancarloromeo Oct 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import datetime

from pydantic import field_validator


def _get_float_string_as_seconds(
v: datetime.timedelta | str | float,
) -> datetime.timedelta | float | str:
if isinstance(v, str):
try:
return float(v)
except ValueError:
# returns format like "1:00:00"
return v
return v


def validate_timedelta_in_legacy_mode(field: str):
"""Transforms a float/int number into a valid datetime as it used to work in the past"""
return field_validator(field, mode="before")(_get_float_string_as_seconds)
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from datetime import timedelta

import pytest
from common_library.pydantic_settings_validators import (
validate_timedelta_in_legacy_mode,
)
from faker import Faker
from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict
from pytest_simcore.helpers.monkeypatch_envs import setenvs_from_dict


def test_validate_timedelta_in_legacy_mode(
monkeypatch: pytest.MonkeyPatch, faker: Faker
):
class Settings(BaseSettings):
APP_NAME: str
REQUEST_TIMEOUT: timedelta = Field(default=timedelta(seconds=40))

_legacy_parsing_request_timeout = validate_timedelta_in_legacy_mode(
"REQUEST_TIMEOUT"
)

model_config = SettingsConfigDict()

app_name = faker.pystr()
env_vars: dict[str, str | bool] = {"APP_NAME": app_name}

# without timedelta
setenvs_from_dict(monkeypatch, env_vars)
settings = Settings()
print(settings.model_dump())
assert app_name == settings.APP_NAME
assert timedelta(seconds=40) == settings.REQUEST_TIMEOUT

# with timedelta in seconds
env_vars["REQUEST_TIMEOUT"] = "5555"
setenvs_from_dict(monkeypatch, env_vars)
settings = Settings()
print(settings.model_dump())
assert app_name == settings.APP_NAME
assert timedelta(seconds=5555) == settings.REQUEST_TIMEOUT
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pydantic.errors import PydanticErrorMixin
from common_library.errors_classes import OsparcErrorMixin


class _BaseRpcApiError(PydanticErrorMixin, ValueError):
class _BaseRpcApiError(OsparcErrorMixin, ValueError):
@classmethod
def get_full_class_name(cls) -> str:
# Can be used as unique code identifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,9 @@ def legacy_enforce_str_to_int(cls, v):
return int(v)
return v

model_config = ConfigDict(populate_by_name=True)

model_config = ConfigDict(
populate_by_name=True,
)

class SimCoreFileLink(BaseFileLink):
"""I/O port type to hold a link to a file in simcore S3 storage"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@
"""

import json
from typing import Literal, TypedDict
import sys
from typing import Literal

if sys.version_info >= (3, 12):
from typing import TypedDict
else:
from typing_extensions import TypedDict # See: https://docs.pydantic.dev/2.9/errors/usage_errors/#typed-dict-version

import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import JSONB
Expand Down
35 changes: 22 additions & 13 deletions services/agent/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ aiohttp==3.8.5
# aiodocker
aiosignal==1.2.0
# via aiohttp
annotated-types==0.7.0
# via pydantic
anyio==3.6.2
# via
# httpx
Expand Down Expand Up @@ -41,16 +43,10 @@ click==8.1.3
# uvicorn
dnspython==2.2.1
# via email-validator
email-validator==1.3.0
email-validator==2.2.0
# via pydantic
fastapi==0.96.0
fastapi==0.115.0
# via
# -c requirements/../../../packages/models-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/service-library/requirements/../../../packages/models-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/service-library/requirements/../../../packages/settings-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/service-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/settings-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../requirements/constraints.txt
# -r requirements/../../../packages/service-library/requirements/_fastapi.in
# -r requirements/_base.in
# prometheus-fastapi-instrumentator
Expand Down Expand Up @@ -106,27 +102,38 @@ prometheus-client==0.19.0
# prometheus-fastapi-instrumentator
prometheus-fastapi-instrumentator==6.1.0
# via -r requirements/../../../packages/service-library/requirements/_fastapi.in
pydantic==1.10.2
pydantic==2.9.2
# via
# -c requirements/../../../packages/models-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/service-library/requirements/../../../packages/models-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/service-library/requirements/../../../packages/settings-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/service-library/requirements/../../../packages/settings-library/requirements/_base.in
# -c requirements/../../../packages/service-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/settings-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../requirements/constraints.txt
# -r requirements/../../../packages/models-library/requirements/_base.in
# -r requirements/../../../packages/settings-library/requirements/_base.in
# -r requirements/_base.in
# fastapi
# pydantic-extra-types
# pydantic-settings
pydantic-core==2.23.4
# via pydantic
pydantic-extra-types==2.9.0
# via -r requirements/../../../packages/models-library/requirements/_base.in
pydantic-settings==2.5.2
# via
# -r requirements/../../../packages/models-library/requirements/_base.in
# -r requirements/../../../packages/settings-library/requirements/_base.in
pygments==2.15.1
# via rich
pyrsistent==0.19.2
# via jsonschema
python-dateutil==2.8.2
# via arrow
python-dotenv==1.0.0
# via -r requirements/_base.in
# via
# -r requirements/_base.in
# pydantic-settings
rich==13.4.2
# via
# -r requirements/../../../packages/settings-library/requirements/_base.in
Expand All @@ -143,7 +150,7 @@ sniffio==1.3.0
# via
# anyio
# httpx
starlette==0.27.0
starlette==0.38.6
# via
# -c requirements/../../../packages/models-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/service-library/requirements/../../../packages/models-library/requirements/../../../requirements/constraints.txt
Expand All @@ -154,10 +161,12 @@ starlette==0.27.0
# fastapi
typer==0.12.3
# via -r requirements/../../../packages/settings-library/requirements/_base.in
typing-extensions==4.4.0
typing-extensions==4.12.2
# via
# aiodocker
# fastapi
# pydantic
# pydantic-core
# typer
uvicorn==0.19.0
# via
Expand Down
19 changes: 11 additions & 8 deletions services/agent/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ aiosignal==1.2.0
# via
# -c requirements/_base.txt
# aiohttp
annotated-types==0.7.0
# via
# -c requirements/_base.txt
# pydantic
anyio==3.6.2
# via
# -c requirements/_base.txt
Expand Down Expand Up @@ -81,8 +85,6 @@ ecdsa==0.19.0
# moto
# python-jose
# sshpubkeys
exceptiongroup==1.2.2
# via pytest
faker==27.0.0
# via -r requirements/_test.in
flask==3.0.3
Expand Down Expand Up @@ -178,11 +180,15 @@ pyasn1==0.6.0
# rsa
pycparser==2.22
# via cffi
pydantic==1.10.2
pydantic==2.9.2
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_base.txt
# aws-sam-translator
pydantic-core==2.23.4
# via
# -c requirements/_base.txt
# pydantic
pyparsing==3.1.2
# via moto
pyrsistent==0.19.2
Expand Down Expand Up @@ -257,16 +263,13 @@ sshpubkeys==3.3.1
# via moto
sympy==1.13.2
# via cfn-lint
tomli==2.0.1
# via
# coverage
# pytest
typing-extensions==4.4.0
typing-extensions==4.12.2
# via
# -c requirements/_base.txt
# aws-sam-translator
# cfn-lint
# pydantic
# pydantic-core
urllib3==2.2.2
# via
# -c requirements/../../../requirements/constraints.txt
Expand Down
12 changes: 1 addition & 11 deletions services/agent/requirements/_tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,12 @@ setuptools==69.2.0
# -c requirements/_base.txt
# -c requirements/_test.txt
# pip-tools
tomli==2.0.1
# via
# -c requirements/_test.txt
# black
# build
# mypy
# pip-tools
# pylint
tomlkit==0.13.2
# via pylint
typing-extensions==4.4.0
typing-extensions==4.12.2
# via
# -c requirements/_base.txt
# -c requirements/_test.txt
# astroid
# black
# mypy
virtualenv==20.26.3
# via pre-commit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def create_app() -> FastAPI:
# SETTINGS
settings = ApplicationSettings.create_from_envs()
_setup_logger(settings)
logger.debug(settings.json(indent=2))
logger.debug(settings.model_dump_json(indent=2))

assert settings.SC_BOOT_MODE # nosec
app = FastAPI(
Expand Down
10 changes: 5 additions & 5 deletions services/agent/src/simcore_service_agent/core/settings.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Final

from models_library.basic_types import BootModeEnum, LogLevel
from pydantic import AnyHttpUrl, Field, NonNegativeInt, validator
from pydantic import AliasChoices, field_validator, AnyHttpUrl, Field, NonNegativeInt
from settings_library.base import BaseCustomSettings
from settings_library.r_clone import S3Provider
from settings_library.utils_logging import MixinLoggingSettings
Expand All @@ -11,16 +11,16 @@

class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
LOGLEVEL: LogLevel = Field(
LogLevel.WARNING.value, env=["AGENT_LOGLEVEL", "LOG_LEVEL", "LOGLEVEL"]
LogLevel.WARNING.value, validation_alias=AliasChoices("AGENT_LOGLEVEL", "LOG_LEVEL", "LOGLEVEL")
)
SC_BOOT_MODE: BootModeEnum | None

AGENT_VOLUMES_LOG_FORMAT_LOCAL_DEV_ENABLED: bool = Field(
default=False,
env=[
validation_alias=AliasChoices(
"AGENT_VOLUMES_LOG_FORMAT_LOCAL_DEV_ENABLED",
"LOG_FORMAT_LOCAL_DEV_ENABLED",
],
),
description="Enables local development log format. WARNING: make sure it is disabled if you want to have structured logs!",
)
AGENT_VOLUMES_CLEANUP_TARGET_SWARM_STACK_NAME: str = Field(
Expand All @@ -47,7 +47,7 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
)
AGENT_PROMETHEUS_INSTRUMENTATION_ENABLED: bool = True

@validator("LOGLEVEL")
@field_validator("LOGLEVEL")
@classmethod
def valid_log_level(cls, value) -> LogLevel:
return LogLevel(cls.validate_log_level(value))
5 changes: 2 additions & 3 deletions services/agent/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from models_library.basic_types import BootModeEnum
from models_library.services import RunID
from moto.server import ThreadedMotoServer
from pydantic import HttpUrl, parse_obj_as
from pydantic import HttpUrl, TypeAdapter
from settings_library.r_clone import S3Provider
from simcore_service_agent.core.settings import ApplicationSettings

Expand Down Expand Up @@ -189,7 +189,6 @@ def caplog_info_debug(
@pytest.fixture(scope="module")
def mocked_s3_server_url(mocked_aws_server: ThreadedMotoServer) -> HttpUrl:
# pylint: disable=protected-access
return parse_obj_as(
HttpUrl,
return TypeAdapter(HttpUrl).validate_python(
f"http://{mocked_aws_server._ip_address}:{mocked_aws_server._port}", # noqa: SLF001
)
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ async def test_store_to_s3(
)

await _download_files_from_bucket(
endpoint=mocked_s3_server_url,
endpoint=str(mocked_s3_server_url),
access_key="xxx",
secret_key="xxx",
bucket_name=bucket,
Expand Down
Loading
Loading