Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

⬆️ Pydantic v2 migration #6578

Merged
merged 80 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
d2d81c0
⬆️ Upgrade models-library (pydantic v2) (#6333)
giancarloromeo Sep 18, 2024
19e3923
♻️ Add common library (#6495)
giancarloromeo Oct 7, 2024
1d92881
⬆️ Upgrade libraries (pydantic v2) (#6366)
giancarloromeo Oct 9, 2024
329b00d
Upgrade agent service (Pydantic v2) (#6508)
giancarloromeo Oct 10, 2024
6786b92
Upgrade EFS guardian service (Pydantic v2) (#6516)
giancarloromeo Oct 11, 2024
bbe92a2
Upgrade invitations service (Pydantic v2) (#6513)
giancarloromeo Oct 11, 2024
42c0a68
Upgrade clusters keeper service (Pydantic v2) (#6519)
giancarloromeo Oct 14, 2024
1c833e0
Merge remote-tracking branch 'origin/master' into pydantic_v2_migrati…
sanderegg Oct 22, 2024
cac8134
♻️Pydantic V2 upgrade: autoscaling (#6535)
sanderegg Oct 15, 2024
e97258e
🎨 pydantic2 migration: fixed unit-tests for dynamic-sidecar (#6534)
GitHK Oct 18, 2024
463488b
🎨 pydantic2 migration: fixed unit-tests for dynamic-scheduler (#6547)
GitHK Oct 18, 2024
c2b4983
🎨 pydantic2 migration: fixed unit-tests for agent (#6546)
GitHK Oct 18, 2024
64293f0
🎨 pydantic2 migration: fixed unit-tests for payments (#6553)
GitHK Oct 18, 2024
cf5546b
Upgrade resource usage tracker (Pydantic v2) (#6517)
giancarloromeo Oct 21, 2024
3b188f5
Merge remote-tracking branch 'origin/master' into pydantic_v2_migrati…
sanderegg Oct 22, 2024
4716e55
Merge remote-tracking branch 'origin/master' into pydantic_v2_migrati…
sanderegg Oct 22, 2024
84f1e51
missing file from re-creating branch
sanderegg Oct 22, 2024
cf95d81
restored from old pydanitc_v2_migration branch
sanderegg Oct 22, 2024
7be9541
fixes after merge
sanderegg Oct 22, 2024
6199ed6
⬆️Dask sidecar: migration to v2 (#6591)
sanderegg Oct 24, 2024
cd6f545
♻️Use correct import (#6597)
sanderegg Oct 24, 2024
3cf68ba
⬆️Datcore adapter: migration (#6594)
sanderegg Oct 24, 2024
fb48eb1
Merge remote-tracking branch 'upstream/master' into update-branch
sanderegg Oct 25, 2024
82c69d0
Merge pull request #6600 from sanderegg/update-branch
sanderegg Oct 25, 2024
7410516
⬆️Migration: Storage (#6599)
sanderegg Oct 25, 2024
39aed6a
⬆️ Upgrade API Server service (Pydantic v2) (#6580)
giancarloromeo Oct 25, 2024
e38cf4e
♻️Fix settings library tests (#6605)
sanderegg Oct 28, 2024
00f8674
Merge remote-tracking branch 'upstream/master' into update-branch2
sanderegg Oct 28, 2024
06df37d
Merge pull request #6609 from sanderegg/update-branch2
sanderegg Oct 28, 2024
3195f1e
Merge remote-tracking branch 'upstream/master' into upgrade-master-3
sanderegg Oct 29, 2024
7033151
Merge remote-tracking branch 'upstream/master' into upgrade-master-3
sanderegg Oct 29, 2024
4fd252f
Merge pull request #6626 from sanderegg/upgrade-master-3
sanderegg Oct 29, 2024
afa0b3c
⬆️ upgrades `iter_model_examples_in_module` to enable all example te…
pcrespov Oct 29, 2024
9e76d4f
⬆️Pydantic V2: Diverse fixes after merges from master (#6627)
sanderegg Oct 29, 2024
fefd1b9
Merge remote-tracking branch 'upstream/master' into upgrade-master-5
sanderegg Oct 29, 2024
05cff9e
Merge pull request #6637 from sanderegg/upgrade-master-5
sanderegg Oct 29, 2024
34c9f3e
⬆️ pydantic migration catalog (#6629)
pcrespov Oct 31, 2024
ee66b3d
Merge remote-tracking branch 'upstream/master' into update-master-6
sanderegg Nov 1, 2024
01769ac
Merge pull request #6645 from sanderegg/update-master-6
sanderegg Nov 1, 2024
2486b38
♻️Pydantic V2 migration: various fixes (#6647)
sanderegg Nov 1, 2024
add4b61
Merge remote-tracking branch 'upstream/master' into update-master-7
sanderegg Nov 1, 2024
1fe311d
Merge pull request #6650 from sanderegg/update-master-7
sanderegg Nov 1, 2024
24218c1
⬆️ Pydantic V2: after upstream merge -> fixes (#6651)
sanderegg Nov 1, 2024
b01c4a7
⬆️ Fix custom settings class with `pydantic-settings~=2.6` (#6644)
pcrespov Nov 5, 2024
8402270
⬆️ Upgrade Web Server service (Pydantic v2) (#6584)
giancarloromeo Nov 6, 2024
0527b1e
🐛 pydantic v2 fixed broken unit tests (#6649)
GitHK Nov 6, 2024
7d0fbdb
Merge remote-tracking branch 'upstream/master' into update-from-maste…
sanderegg Nov 8, 2024
c106d0a
Merge pull request #6689 from sanderegg/update-from-master-10
sanderegg Nov 8, 2024
60fe257
🎨 Add examples to pydantic response models (#6658)
bisgaard-itis Nov 8, 2024
f07afbf
🐛 Fixed packages mypy, pylint and tests (#6678)
GitHK Nov 11, 2024
a00d55f
pydantic2 making ported services green (#6701)
GitHK Nov 13, 2024
f335bca
WIP: ⬆️ Upgrade Director v2 service (Pydantic v2) (#6619)
giancarloromeo Nov 14, 2024
db084cd
Merge remote-tracking branch 'upstream/master' into update-master-20
sanderegg Nov 14, 2024
44bc9f7
Merge pull request #6724 from sanderegg/update-master-20
sanderegg Nov 15, 2024
a2d3742
♻️ Fix unit tests after master merge (#6727)
giancarloromeo Nov 15, 2024
327beab
⬆️ Align versions for pydantic/fastapi (#6730)
giancarloromeo Nov 15, 2024
84c4c85
♻️Fixed Unit test director v2 (#6733)
sanderegg Nov 15, 2024
8eac56b
♻️ Fix deprecated stuff (Pydantic v2) (#6732)
giancarloromeo Nov 18, 2024
65665ec
♻️ Migrate scripts (Pydantic v2) (#6741)
giancarloromeo Nov 18, 2024
57058f9
Merge remote-tracking branch 'upstream/master' into update-from-maste…
sanderegg Nov 18, 2024
44f85bf
Merge pull request #6744 from sanderegg/update-from-master-XXX
sanderegg Nov 18, 2024
fa57c9e
pydantic2 migration made integration tests green (#6719)
GitHK Nov 18, 2024
a6802c9
⬆️✅ Fixes settings tests (#6753)
pcrespov Nov 18, 2024
75f06e4
🐛 Fixed webserver API endpoints (#6751)
GitHK Nov 19, 2024
aa756f0
Merge remote-tracking branch 'upstream/master' into update-master-XXX
sanderegg Nov 19, 2024
bcf3327
Merge remote-tracking branch 'upstream/master' into update-master-XXX
sanderegg Nov 19, 2024
373c314
Merge pull request #6754 from sanderegg/update-master-XXX
sanderegg Nov 19, 2024
f442e63
⬆️Pydantic V2: Migrate director v0 + some fixes from query PR (#6755)
sanderegg Nov 19, 2024
c10d7d0
⬆️♻️ Fix/test models (#6758)
pcrespov Nov 19, 2024
3250e5d
♻️ Greenify pylint (after Pydantic v2 migration) (#6747)
giancarloromeo Nov 19, 2024
dcdc863
🎨 Ensure profiling middleware is compatible with fastapi (#6760)
bisgaard-itis Nov 19, 2024
c50d79c
♻️Pydantic V2: Unify errors dv 2 (#6763)
sanderegg Nov 19, 2024
0aea337
Uses typing_extensions.TypedDict in all instances used in pydantic mo…
pcrespov Nov 19, 2024
c49f421
♻️ Cleanup network AnyHttpUrlLegacy and HttpUrlLegacy (#6767)
giancarloromeo Nov 20, 2024
a0b8a2f
All errors in dynamic-sidecar inherit from `OsparcErrorMixin` (#6764)
GitHK Nov 20, 2024
66a492f
♻️ Fix agent tests (#6772)
giancarloromeo Nov 20, 2024
c38b064
Fixes [unit] webserver 03 and [unit] settings-library (both mypy and …
pcrespov Nov 20, 2024
150b17a
Merge remote-tracking branch 'upstream/master' into update-master-XXXXX
sanderegg Nov 20, 2024
17d1702
Merge pull request #6780 from sanderegg/update-master-XXXXX
sanderegg Nov 20, 2024
47e3570
⬆️Pydantic V2: missing import in director-v0 (#6781)
sanderegg Nov 20, 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
  •  
  •  
  •  
6 changes: 3 additions & 3 deletions .env-devel
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ AUTOSCALING_EC2_ACCESS=null
AUTOSCALING_EC2_INSTANCES=null
AUTOSCALING_LOGLEVEL=INFO
AUTOSCALING_NODES_MONITORING=null
AUTOSCALING_POLL_INTERVAL=10
AUTOSCALING_POLL_INTERVAL="00:00:10"
AUTOSCALING_SSM_ACCESS=null
AUTOSCALING_TRACING={}

Expand Down Expand Up @@ -120,13 +120,13 @@ DYNAMIC_SIDECAR_IMAGE=${DOCKER_REGISTRY:-itisfoundation}/dynamic-sidecar:${DOCKE
DYNAMIC_SIDECAR_LOG_LEVEL=DEBUG
DYNAMIC_SIDECAR_PROMETHEUS_MONITORING_NETWORKS=[]
DYNAMIC_SIDECAR_PROMETHEUS_SERVICE_LABELS={}
DYNAMIC_SIDECAR_API_SAVE_RESTORE_STATE_TIMEOUT=3600
DYNAMIC_SIDECAR_API_SAVE_RESTORE_STATE_TIMEOUT=01:00:00
DIRECTOR_V2_TRACING={}

# DYNAMIC_SCHEDULER ----
DYNAMIC_SCHEDULER_LOGLEVEL=DEBUG
DYNAMIC_SCHEDULER_PROFILING=1
DYNAMIC_SCHEDULER_STOP_SERVICE_TIMEOUT=PT1H
DYNAMIC_SCHEDULER_STOP_SERVICE_TIMEOUT=01:00:00
DYNAMIC_SCHEDULER_TRACING={}

FUNCTION_SERVICES_AUTHORS='{"UN": {"name": "Unknown", "email": "[email protected]", "affiliation": "unknown"}}'
Expand Down
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Makefile @pcrespov @sanderegg
/api/ @sanderegg @pcrespov @matusdrobuliak66
/ci/ @sanderegg @pcrespov
/docs/ @pcrespov
/packages/models-library/ @sanderegg @pcrespov @matusdrobuliak66
/packages/common-library/ @giancarloromeo
/packages/models-library/ @sanderegg @pcrespov @matusdrobuliak66 @giancarloromeo
/packages/postgres-database/ @matusdrobuliak66
/packages/pytest-simcore/ @pcrespov @sanderegg
/packages/service-integration/ @pcrespov @sanderegg @GitHK
Expand Down
45 changes: 45 additions & 0 deletions .github/workflows/ci-testing-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
aws-library: ${{ steps.filter.outputs.aws-library }}
dask-task-models-library: ${{ steps.filter.outputs.dask-task-models-library }}
models-library: ${{ steps.filter.outputs.models-library }}
common-library: ${{ steps.filter.outputs.common-library }}
notifications-library: ${{ steps.filter.outputs.notifications-library }}
postgres-database: ${{ steps.filter.outputs.postgres-database }}
service-integration: ${{ steps.filter.outputs.service-integration }}
Expand Down Expand Up @@ -110,6 +111,8 @@ jobs:
- 'services/docker-compose*'
- 'scripts/mypy/*'
- 'mypy.ini'
common-library:
- 'packages/common-library/**'
notifications-library:
- 'packages/notifications-library/**'
- 'packages/postgres-database/**'
Expand Down Expand Up @@ -1799,6 +1802,47 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}

unit-test-common-library:
needs: changes
if: ${{ needs.changes.outputs.common-library == 'true' || github.event_name == 'push' }}
timeout-minutes: 18 # if this timeout gets too small, then split the tests
name: "[unit] common-library"
runs-on: ${{ matrix.os }}
strategy:
matrix:
python: ["3.11"]
os: [ubuntu-22.04]
fail-fast: false
steps:
- uses: actions/checkout@v4
- name: setup docker buildx
id: buildx
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: setup python environment
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- name: install uv
uses: yezz123/setup-uv@v4
- uses: actions/cache@v4
id: cache-uv
with:
path: ~/.cache/uv
key: ${{ runner.os }}-${{ github.job }}-python-${{ matrix.python }}-uv
- name: show system version
run: ./ci/helpers/show_system_versions.bash
- name: install
run: ./ci/github/unit-testing/common-library.bash install
- name: typecheck
run: ./ci/github/unit-testing/common-library.bash typecheck
- name: test
run: ./ci/github/unit-testing/common-library.bash test
- uses: codecov/[email protected]
with:
flags: unittests #optional

unit-test-notifications-library:
needs: changes
if: ${{ needs.changes.outputs.notifications-library == 'true' || github.event_name == 'push' }}
Expand Down Expand Up @@ -1919,6 +1963,7 @@ jobs:
unit-test-dynamic-sidecar,
unit-test-efs-guardian,
unit-test-models-library,
unit-test-common-library,
unit-test-notifications-library,
unit-test-osparc-gateway-server,
unit-test-payments,
Expand Down
36 changes: 17 additions & 19 deletions api/specs/web-server/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
from typing import Any, ClassVar, NamedTuple

import yaml
from common_library.json_serialization import json_dumps
from common_library.pydantic_fields_extension import get_type
from fastapi import FastAPI, Query
from models_library.basic_types import LogLevel
from models_library.utils.json_serialization import json_dumps
from pydantic import BaseModel, Field, create_model
from pydantic.fields import FieldInfo
from servicelib.fastapi.openapi import override_fastapi_openapi_method
Expand All @@ -37,31 +38,28 @@ def __modify_schema__(cls, field_schema: dict[str, Any]) -> None:

def as_query(model_class: type[BaseModel]) -> type[BaseModel]:
fields = {}
for field_name, model_field in model_class.__fields__.items():
for field_name, field_info in model_class.model_fields.items():

field_type = model_field.type_
default_value = model_field.default
field_type = get_type(field_info)
default_value = field_info.default

kwargs = {
"alias": model_field.field_info.alias,
"title": model_field.field_info.title,
"description": model_field.field_info.description,
"gt": model_field.field_info.gt,
"ge": model_field.field_info.ge,
"lt": model_field.field_info.lt,
"le": model_field.field_info.le,
"min_length": model_field.field_info.min_length,
"max_length": model_field.field_info.max_length,
"regex": model_field.field_info.regex,
**model_field.field_info.extra,
"alias": field_info.alias,
"title": field_info.title,
"description": field_info.description,
"metadata": field_info.metadata,
"json_schema_extra": field_info.json_schema_extra,
}

if issubclass(field_type, BaseModel):
# Complex fields
assert "json_schema_extra" in kwargs # nosec
assert kwargs["json_schema_extra"] # nosec
field_type = _create_json_type(
description=kwargs["description"],
example=kwargs.get("example_json"),
example=kwargs.get("json_schema_extra", {}).get("example_json"),
)

default_value = json_dumps(default_value) if default_value else None

fields[field_name] = (field_type, Query(default=default_value, **kwargs))
Expand Down Expand Up @@ -147,7 +145,7 @@ def create_and_save_openapi_specs(
)
with file_path.open("wt") as fh:
yaml.safe_dump(openapi, fh, indent=1, sort_keys=False)
print("Saved OAS to", file_path)
print("Saved OAS to", file_path) # noqa: T201


class ParamSpec(NamedTuple):
Expand All @@ -169,8 +167,8 @@ def assert_handler_signature_against_model(

# query and path parameters
implemented_params = [
ParamSpec(field.name, field.type_, field.field_info)
for field in model_cls.__fields__.values()
ParamSpec(name, get_type(info), info)
for name, info in model_cls.model_fields.items()
]

implemented_names = {p.name for p in implemented_params}
Expand Down
43 changes: 43 additions & 0 deletions ci/github/unit-testing/common-library.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
# http://redsymbol.net/articles/unofficial-bash-strict-mode/
set -o errexit # abort on nonzero exitstatus
set -o nounset # abort on unbound variable
set -o pipefail # don't hide errors within pipes
IFS=$'\n\t'

install() {
make devenv
# shellcheck source=/dev/null
source .venv/bin/activate
pushd packages/common-library
make install-ci
popd
uv pip list
}

test() {
# shellcheck source=/dev/null
source .venv/bin/activate
pushd packages/common-library
make tests-ci
popd
}

typecheck() {
# shellcheck source=/dev/null
source .venv/bin/activate
uv pip install mypy
pushd packages/common-library
make mypy
popd
}

# Check if the function exists (bash specific)
if declare -f "$1" >/dev/null; then
# call arguments verbatim
"$@"
else
# Show a helpful error
echo "'$1' is not a known function name" >&2
exit 1
fi
30 changes: 19 additions & 11 deletions ci/helpers/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
# This file was autogenerated by uv via the following command:
# uv pip compile requirements.in
# uv pip compile requirements.in -o requirements.txt
aiohttp==3.9.5
# via
# -c ../../requirements/constraints.txt
# -r requirements.in
aiosignal==1.3.1
# via aiohttp
annotated-types==0.7.0
# via pydantic
anyio==4.3.0
# via starlette
async-timeout==4.0.3
# via aiohttp
attrs==23.2.0
# via aiohttp
exceptiongroup==1.2.1
# via anyio
fastapi==0.99.1
fastapi==0.115.0
# via -r requirements.in
frozenlist==1.4.1
# via
# aiohttp
Expand All @@ -24,16 +26,22 @@ multidict==6.0.5
# via
# aiohttp
# yarl
pydantic==1.10.15
# via fastapi
pydantic==2.9.2
# via
# -c ../../requirements/constraints.txt
# fastapi
pydantic-core==2.23.4
# via pydantic
sniffio==1.3.1
# via anyio
starlette==0.27.0
# via fastapi
starlette==0.38.6
# via
# -c ../../requirements/constraints.txt
# fastapi
typing-extensions==4.11.0
# via
# anyio
# fastapi
# pydantic
# pydantic-core
yarl==1.9.4
# via aiohttp
1 change: 1 addition & 0 deletions packages/aws-library/requirements/_base.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Specifies third-party dependencies for 'aws-library'
#
--constraint ../../../requirements/constraints.txt
--requirement ../../../packages/common-library/requirements/_base.in
--requirement ../../../packages/models-library/requirements/_base.in
--requirement ../../../packages/service-library/requirements/_base.in
--requirement ../../../packages/settings-library/requirements/_base.in
Expand Down
Loading
Loading