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

⬆️♻️ Updates pydantic repo-wide to the same version and fixes new issues in all services #6882

Merged
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
64807a1
constraint
pcrespov Dec 2, 2024
26d634c
upgrades to 2.10.2
pcrespov Dec 2, 2024
5da357a
fixes web-server mypy
pcrespov Dec 2, 2024
3b1b0b3
fixes log-level default everywhere
pcrespov Dec 2, 2024
d85161d
rm old models
pcrespov Dec 2, 2024
6258409
annotated
pcrespov Dec 2, 2024
d7bd68c
mypy
pcrespov Dec 2, 2024
db06488
@GitHK please review directorv2 changes
pcrespov Dec 2, 2024
ecb5eb2
upgrades faststream everywhere
pcrespov Dec 2, 2024
136db2e
defaults?
pcrespov Dec 2, 2024
bb66bb8
api-server
pcrespov Dec 2, 2024
60a743a
annotations
pcrespov Dec 3, 2024
7ead8ec
fixes rut
pcrespov Dec 3, 2024
e29f65a
fixes sil
pcrespov Dec 3, 2024
0b5e311
cleanup
pcrespov Dec 3, 2024
a2ae61b
settings-library
pcrespov Dec 3, 2024
fade298
basic types
pcrespov Dec 3, 2024
3a4491c
api-server
pcrespov Dec 3, 2024
0058325
rm json_serializer option
pcrespov Dec 3, 2024
f143ca5
fixes tests
pcrespov Dec 3, 2024
bd36009
corrects required
pcrespov Dec 3, 2024
4b61054
api-servier
pcrespov Dec 3, 2024
41b6512
cleanup
pcrespov Dec 3, 2024
4982ae5
Merge branch 'master' into mai/pydantic-upgrade-repo-wide
pcrespov Dec 3, 2024
0bc3eb0
uses AnyHttpUrl
pcrespov Dec 3, 2024
e6a8f18
@GitHK review: split tests and adds xfail
pcrespov Dec 3, 2024
7ca6bce
reverts httpurl after tests
pcrespov Dec 3, 2024
081b74b
update oas
pcrespov Dec 3, 2024
02190a7
update
pcrespov Dec 3, 2024
be7262a
@sanderegg review: auto-generator and urls
pcrespov Dec 3, 2024
e39a580
@GitHK review: checks
pcrespov Dec 3, 2024
7e218eb
@GitHK review: example assert
pcrespov Dec 3, 2024
fc5cabc
Merge branch 'master' into mai/pydantic-upgrade-repo-wide
pcrespov Dec 3, 2024
68fac91
spaces
pcrespov Dec 3, 2024
72a7da1
missing after merge
pcrespov Dec 3, 2024
0b83488
fixes director
pcrespov Dec 3, 2024
927b67e
@sanderegg, @GitHK review: import unset constant
pcrespov Dec 3, 2024
0791acd
update
pcrespov Dec 3, 2024
0d55f35
update
pcrespov Dec 3, 2024
36827b1
Merge branch 'master' into mai/pydantic-upgrade-repo-wide
pcrespov Dec 3, 2024
7c0291b
update
pcrespov Dec 3, 2024
f1642f1
@GitHK review: wrong fixture
pcrespov Dec 4, 2024
23f54cd
upgrade
pcrespov Dec 4, 2024
ba91703
pyaments
pcrespov Dec 4, 2024
b16d094
Merge branch 'master' into mai/pydantic-upgrade-repo-wide
pcrespov Dec 4, 2024
2667696
Merge branch 'master' into mai/pydantic-upgrade-repo-wide
pcrespov Dec 4, 2024
9bf15c0
undo
pcrespov Dec 4, 2024
cc89dcb
fixes dv2
pcrespov Dec 4, 2024
01b33a5
cleanup
pcrespov Dec 4, 2024
57dcc32
fixes payments
pcrespov Dec 4, 2024
b5b684e
fixs webserver
pcrespov Dec 4, 2024
7f76279
fixes warnings
pcrespov Dec 4, 2024
1be53d5
bad imports and oas
pcrespov Dec 4, 2024
f6c7e5d
Merge branch 'master' into mai/pydantic-upgrade-repo-wide
pcrespov Dec 4, 2024
c2d3389
cleanup
pcrespov Dec 4, 2024
a0e817f
Merge branch 'master' into mai/pydantic-upgrade-repo-wide
pcrespov Dec 4, 2024
4555dfb
Merge branch 'master' into mai/pydantic-upgrade-repo-wide
pcrespov Dec 5, 2024
77f2adf
Merge branch 'master' into mai/pydantic-upgrade-repo-wide
pcrespov Dec 5, 2024
e449f63
@GitHK review: rename unset
pcrespov Dec 5, 2024
8fcd5b1
@GitHK review: annotations
pcrespov Dec 5, 2024
7148313
Merge branch 'master' into mai/pydantic-upgrade-repo-wide
pcrespov Dec 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/aws-library/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ email-validator==2.2.0
# via pydantic
fast-depends==2.4.12
# via faststream
faststream==0.5.28
faststream==0.5.31
# via -r requirements/../../../packages/service-library/requirements/_base.in
frozenlist==1.4.1
# via
Expand Down Expand Up @@ -218,7 +218,7 @@ protobuf==4.25.5
# opentelemetry-proto
psutil==6.0.0
# via -r requirements/../../../packages/service-library/requirements/_base.in
pydantic==2.9.2
pydantic==2.10.2
# via
# -c requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
Expand Down Expand Up @@ -247,7 +247,7 @@ pydantic==2.9.2
# fast-depends
# pydantic-extra-types
# pydantic-settings
pydantic-core==2.23.4
pydantic-core==2.27.1
# via pydantic
pydantic-extra-types==2.9.0
# via
Expand Down Expand Up @@ -307,7 +307,6 @@ redis==5.0.4
# -r requirements/../../../packages/service-library/requirements/_base.in
referencing==0.29.3
# via
# -c requirements/../../../packages/service-library/requirements/./constraints.txt
# jsonschema
# jsonschema-specifications
repro-zipfile==0.3.1
Expand Down Expand Up @@ -393,6 +392,7 @@ wrapt==1.16.0
# opentelemetry-instrumentation-redis
yarl==1.12.1
# via
# -r requirements/../../../packages/service-library/requirements/_base.in
# aio-pika
# aiohttp
# aiormq
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-library/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,12 @@ py-partiql-parser==0.5.6
# via moto
pycparser==2.22
# via cffi
pydantic==2.9.2
pydantic==2.10.2
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_base.txt
# aws-sam-translator
pydantic-core==2.23.4
pydantic-core==2.27.1
# via
# -c requirements/_base.txt
# pydantic
Expand Down
4 changes: 2 additions & 2 deletions packages/common-library/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ orjson==3.10.10
# via
# -c requirements/../../../requirements/constraints.txt
# -r requirements/_base.in
pydantic==2.9.2
pydantic==2.10.2
# via
# -c requirements/../../../requirements/constraints.txt
# -r requirements/_base.in
# pydantic-extra-types
pydantic-core==2.23.4
pydantic-core==2.27.1
# via pydantic
pydantic-extra-types==2.9.0
# via -r requirements/_base.in
Expand Down
4 changes: 2 additions & 2 deletions packages/common-library/requirements/_test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ pluggy==1.5.0
# via pytest
pprintpp==0.4.0
# via pytest-icdiff
pydantic==2.9.2
pydantic==2.10.2
# via
# -c requirements/../../../requirements/constraints.txt
# -c requirements/_base.txt
# pydantic-settings
pydantic-core==2.23.4
pydantic-core==2.27.1
# via
# -c requirements/_base.txt
# pydantic
Expand Down
7 changes: 7 additions & 0 deletions packages/common-library/src/common_library/basic_types.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
from enum import StrEnum

from pydantic_core import PydanticUndefined

# SEE https://github.com/fastapi/fastapi/blob/master/fastapi/_compat.py#L75-L78
#
# Use as default when default_factory
Undefined = PydanticUndefined
pcrespov marked this conversation as resolved.
Show resolved Hide resolved


class LogLevel(StrEnum):
DEBUG = "DEBUG"
Expand Down
4 changes: 2 additions & 2 deletions packages/dask-task-models-library/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ partd==1.4.2
# via dask
psutil==6.0.0
# via distributed
pydantic==2.9.2
pydantic==2.10.2
# via
# -c requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
# -c requirements/../../../packages/models-library/requirements/../../../packages/common-library/requirements/../../../requirements/constraints.txt
Expand All @@ -92,7 +92,7 @@ pydantic==2.9.2
# -r requirements/_base.in
# pydantic-extra-types
# pydantic-settings
pydantic-core==2.23.4
pydantic-core==2.27.1
# via pydantic
pydantic-extra-types==2.9.0
# via
Expand Down
4 changes: 2 additions & 2 deletions packages/models-library/requirements/_base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ orjson==3.10.7
# -c requirements/../../../requirements/constraints.txt
# -r requirements/../../../packages/common-library/requirements/_base.in
# -r requirements/_base.in
pydantic==2.9.2
pydantic==2.10.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
pydantic-core==2.27.1
# via pydantic
pydantic-extra-types==2.9.0
# via
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Worker(BaseModel):

class Scheduler(BaseModel):
status: str = Field(..., description="The running status of the scheduler")
workers: WorkersDict | None = Field(default_factory=dict)
workers: Annotated[WorkersDict | None, Field(default_factory=dict)]

@field_validator("workers", mode="before")
@classmethod
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import TypeAlias

from pydantic import BaseModel, Field, PositiveFloat
from pydantic import BaseModel, PositiveFloat

from ..projects_nodes_io import NodeID

Expand All @@ -18,7 +18,7 @@ class Limits(BaseModel):
class Activity(BaseModel):
stats: Stats
limits: Limits
queued: bool = Field(None) # TODO: review since it in NOT filled
queued: bool | None = None # TODO: review since it in NOT filled
pcrespov marked this conversation as resolved.
Show resolved Hide resolved


ActivityStatusDict: TypeAlias = dict[NodeID, Activity]
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ class ProjectGet(OutputSchema):
)
state: ProjectState | None = None
ui: EmptyModel | StudyUI | None = None
quality: dict[str, Any] = Field(
default_factory=dict, json_schema_extra={"default": {}}
)
quality: Annotated[
dict[str, Any], Field(default_factory=dict, json_schema_extra={"default": {}})
]
dev: dict | None
permalink: ProjectPermalink | None = None
workspace_id: WorkspaceID | None
Expand Down Expand Up @@ -122,16 +122,20 @@ class ProjectReplace(InputSchema):
last_change_date: DateTimeStr
workbench: NodesDict
access_rights: dict[GroupIDStr, AccessRights]
tags: list[int] | None = Field(
default_factory=list, json_schema_extra={"default": []}
)
classifiers: list[ClassifierID] | None = Field(
default_factory=list, json_schema_extra={"default": []}
)
tags: Annotated[
list[int] | None, Field(default_factory=list, json_schema_extra={"default": []})
]

classifiers: Annotated[
list[ClassifierID] | None,
Field(default_factory=list, json_schema_extra={"default": []}),
]

ui: StudyUI | None = None
quality: dict[str, Any] = Field(
default_factory=dict, json_schema_extra={"default": {}}
)

quality: Annotated[
dict[str, Any], Field(default_factory=dict, json_schema_extra={"default": {}})
]


class ProjectPatch(InputSchema):
Expand All @@ -141,7 +145,7 @@ class ProjectPatch(InputSchema):
HttpUrl | None,
BeforeValidator(empty_str_to_none_pre_validator),
PlainSerializer(lambda x: str(x) if x is not None else None),
] = Field(default=None)
] = None
access_rights: dict[GroupIDStr, AccessRights] | None = Field(default=None)
classifiers: list[ClassifierID] | None = Field(default=None)
dev: dict | None = Field(default=None)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# mypy: disable-error-code=truthy-function
from typing import Any, Literal, TypeAlias
from typing import Annotated, Any, Literal, TypeAlias

from pydantic import ConfigDict, Field

Expand Down Expand Up @@ -29,16 +29,23 @@ class NodePatch(InputSchemaWithoutCamelCase):
service_key: ServiceKey | None = Field(default=None, alias="key")
service_version: ServiceVersion | None = Field(default=None, alias="version")
label: str | None = Field(default=None)
inputs: InputsDict = Field(default=None)
inputs: Annotated[
InputsDict, Field(default_factory=dict, json_schema_extra={"default": {}})
]
inputs_required: list[InputID] | None = Field(default=None, alias="inputsRequired")
input_nodes: list[NodeID] | None = Field(default=None, alias="inputNodes")
progress: float | None = Field(
default=None, ge=0, le=100
) # NOTE: it is used by frontend for File Picker progress
boot_options: BootOptions | None = Field(default=None, alias="bootOptions")
outputs: dict[str, Any] | None = Field(
default=None
) # NOTE: it is used by frontend for File Picker
progress: Annotated[
float | None,
Field(
# NOTE: it is used by frontend for File Picker progress
ge=0,
le=100,
),
] = None
boot_options: Annotated[BootOptions | None, Field(alias="bootOptions")] = None
outputs: dict[
str, Any
] | None = None # NOTE: it is used by frontend for File Picker


class NodeCreated(OutputSchema):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
class WalletGet(OutputSchema):
wallet_id: WalletID
name: IDStr
description: str | None
description: str | None = None
owner: GroupID
thumbnail: str | None
thumbnail: str | None = None
status: WalletStatus
created: datetime
modified: datetime
Expand Down
42 changes: 27 additions & 15 deletions packages/models-library/src/models_library/app_diagnostics.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
from typing import Any
from typing import Annotated, Any

from common_library.basic_types import Undefined
from pydantic import AnyUrl, BaseModel, Field

_Unset: Any = Undefined


class AppStatusCheck(BaseModel):
app_name: str = Field(..., description="Application name")
version: str = Field(..., description="Application's version")
services: dict[str, Any] = Field(
default_factory=dict,
description="Other backend services connected from this service",
json_schema_extra={"default": {}},
)
services: Annotated[
dict[str, Any],
Field(
default_factory=dict,
description="Other backend services connected from this service",
json_schema_extra={"default": {}},
),
] = _Unset

sessions: dict[str, Any] | None = Field(
default_factory=dict,
description="Client sessions info. If single session per app, then is denoted as main",
json_schema_extra={"default": {}},
)
sessions: Annotated[
dict[str, Any] | None,
Field(
default_factory=dict,
description="Client sessions info. If single session per app, then is denoted as main",
json_schema_extra={"default": {}},
),
] = _Unset

url: AnyUrl | None = Field(
default=None,
description="Link to current resource",
)
diagnostics_url: AnyUrl | None = Field(
default=None,
description="Link to diagnostics report sub-resource. This MIGHT take some time to compute",
)

diagnostics_url: Annotated[
AnyUrl | None,
Field(
description="Link to diagnostics report sub-resource. This MIGHT take some time to compute",
),
] = None
19 changes: 11 additions & 8 deletions packages/models-library/src/models_library/callbacks_mapping.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from collections.abc import Sequence
from typing import Final
from typing import Annotated, Final

from pydantic import BaseModel, ConfigDict, Field, NonNegativeFloat, field_validator

Expand Down Expand Up @@ -31,14 +31,17 @@ class CallbacksMapping(BaseModel):
None,
description="command to recover prometheus metrics from a specific user service",
)
before_shutdown: list[UserServiceCommand] = Field(
default_factory=list,
description=(
"commands to run before shutting down the user services"
"commands get executed first to last, multiple commands for the same"
"user services are allowed"
before_shutdown: Annotated[
list[UserServiceCommand],
Field(
default_factory=list,
description=(
"commands to run before shutting down the user services"
"commands get executed first to last, multiple commands for the same"
"user services are allowed"
),
),
)
]
inactivity: UserServiceCommand | None = Field(
None,
description=(
Expand Down
Loading
Loading