diff --git a/scripts/maintenance/migrate_project/src/cli.py b/scripts/maintenance/migrate_project/src/cli.py index 6012e97bbd6..5d7525efcac 100644 --- a/scripts/maintenance/migrate_project/src/cli.py +++ b/scripts/maintenance/migrate_project/src/cli.py @@ -1,5 +1,4 @@ from pathlib import Path -from typing import Optional import typer from db import ( @@ -15,7 +14,7 @@ def main(config: Path = typer.Option(..., exists=True)): assert config.exists() # nosec settings = Settings.load_from_file(config) - typer.echo(f"Detected settings:\n{settings.json(indent=2)}\n") + typer.echo(f"Detected settings:\n{settings.model_dump_json(indent=2)}\n") r_clone_config_path = assemble_config_file( # source diff --git a/scripts/maintenance/migrate_project/src/models.py b/scripts/maintenance/migrate_project/src/models.py index 68649c2a392..964d95de550 100644 --- a/scripts/maintenance/migrate_project/src/models.py +++ b/scripts/maintenance/migrate_project/src/models.py @@ -92,5 +92,7 @@ class Config: if __name__ == "__main__": # produces an empty configuration to be saved as starting point print( - Settings.model_validate(Settings.Config.schema_extra["example"]).json(indent=2) + Settings.model_validate( + Settings.Config.schema_extra["example"] + ).model_dump_json(indent=2) ) diff --git a/services/web/server/src/simcore_service_webserver/folders/_folders_db.py b/services/web/server/src/simcore_service_webserver/folders/_folders_db.py index 6c78855995e..38ad97f44ed 100644 --- a/services/web/server/src/simcore_service_webserver/folders/_folders_db.py +++ b/services/web/server/src/simcore_service_webserver/folders/_folders_db.py @@ -323,7 +323,7 @@ async def update( """ Batch/single patch of folder/s """ - # NOTE: exclude unset can also be done using a pydantic model and dict(exclude_unset=True) + # NOTE: exclude unset can also be done using a pydantic model and model_dump(exclude_unset=True) updated = as_dict_exclude_unset( name=name, parent_folder_id=parent_folder_id, diff --git a/services/web/server/src/simcore_service_webserver/licenses/_licensed_items_db.py b/services/web/server/src/simcore_service_webserver/licenses/_licensed_items_db.py index e468c10f55d..415dec7149d 100644 --- a/services/web/server/src/simcore_service_webserver/licenses/_licensed_items_db.py +++ b/services/web/server/src/simcore_service_webserver/licenses/_licensed_items_db.py @@ -145,7 +145,7 @@ async def update( ) -> LicensedItemDB: # NOTE: at least 'touch' if updated_values is empty _updates = { - **updates.dict(exclude_unset=True), + **updates.model_dump(exclude_unset=True), "modified": func.now(), } diff --git a/services/web/server/src/simcore_service_webserver/projects/_folders_db.py b/services/web/server/src/simcore_service_webserver/projects/_folders_db.py index 2e5001343d4..d8c965be26b 100644 --- a/services/web/server/src/simcore_service_webserver/projects/_folders_db.py +++ b/services/web/server/src/simcore_service_webserver/projects/_folders_db.py @@ -129,7 +129,7 @@ async def update_project_to_folder( """ Batch/single patch of project to folders """ - # NOTE: exclude unset can also be done using a pydantic model and dict(exclude_unset=True) + # NOTE: exclude unset can also be done using a pydantic model and model_dump(exclude_unset=True) updated = as_dict_exclude_unset( user_id=user_id, ) diff --git a/services/web/server/src/simcore_service_webserver/workspaces/_workspaces_db.py b/services/web/server/src/simcore_service_webserver/workspaces/_workspaces_db.py index 5264a112419..b88bdd918ae 100644 --- a/services/web/server/src/simcore_service_webserver/workspaces/_workspaces_db.py +++ b/services/web/server/src/simcore_service_webserver/workspaces/_workspaces_db.py @@ -217,7 +217,7 @@ async def update_workspace( ) -> WorkspaceDB: # NOTE: at least 'touch' if updated_values is empty _updates = { - **updates.dict(exclude_unset=True), + **updates.model_dump(exclude_unset=True), "modified": func.now(), } diff --git a/services/web/server/tests/unit/with_dbs/03/test_trash.py b/services/web/server/tests/unit/with_dbs/03/test_trash.py index 6ab597e3972..f582747ef95 100644 --- a/services/web/server/tests/unit/with_dbs/03/test_trash.py +++ b/services/web/server/tests/unit/with_dbs/03/test_trash.py @@ -409,7 +409,7 @@ async def workspace( # CREATE a workspace resp = await client.post("/v0/workspaces", json={"name": "My first workspace"}) data, _ = await assert_status(resp, status.HTTP_201_CREATED) - workspace = WorkspaceGet.parse_obj(data) + workspace = WorkspaceGet.model_validate(data) yield workspace @@ -433,7 +433,7 @@ async def test_trash_empty_workspace( resp = await client.get("/v0/workspaces") await assert_status(resp, status.HTTP_200_OK) - page = Page[WorkspaceGet].parse_obj(await resp.json()) + page = Page[WorkspaceGet].model_validate(await resp.json()) assert page.meta.total == 1 assert page.data[0] == workspace @@ -441,7 +441,7 @@ async def test_trash_empty_workspace( resp = await client.get("/v0/workspaces", params={"filters": '{"trashed": true}'}) await assert_status(resp, status.HTTP_200_OK) - page = Page[WorkspaceGet].parse_obj(await resp.json()) + page = Page[WorkspaceGet].model_validate(await resp.json()) assert page.meta.total == 0 # ------------- @@ -457,16 +457,16 @@ async def test_trash_empty_workspace( resp = await client.get("/v0/workspaces") await assert_status(resp, status.HTTP_200_OK) - page = Page[WorkspaceGet].parse_obj(await resp.json()) + page = Page[WorkspaceGet].model_validate(await resp.json()) assert page.meta.total == 0 # LIST trashed resp = await client.get("/v0/workspaces", params={"filters": '{"trashed": true}'}) await assert_status(resp, status.HTTP_200_OK) - page = Page[WorkspaceGet].parse_obj(await resp.json()) + page = Page[WorkspaceGet].model_validate(await resp.json()) assert page.meta.total == 1 - assert page.data[0].dict(exclude=_exclude_attrs) == workspace.dict( + assert page.data[0].model_dump(exclude=_exclude_attrs) == workspace.model_dump( exclude=_exclude_attrs ) assert page.data[0].trashed_at is not None @@ -483,9 +483,9 @@ async def test_trash_empty_workspace( resp = await client.get("/v0/workspaces") await assert_status(resp, status.HTTP_200_OK) - page = Page[WorkspaceGet].parse_obj(await resp.json()) + page = Page[WorkspaceGet].model_validate(await resp.json()) assert page.meta.total == 1 - assert page.data[0].dict(exclude=_exclude_attrs) == workspace.dict( + assert page.data[0].model_dump(exclude=_exclude_attrs) == workspace.model_dump( exclude=_exclude_attrs ) @@ -496,5 +496,5 @@ async def test_trash_empty_workspace( resp = await client.get("/v0/workspaces", params={"filters": '{"trashed": true}'}) await assert_status(resp, status.HTTP_200_OK) - page = Page[WorkspaceGet].parse_obj(await resp.json()) + page = Page[WorkspaceGet].model_validate(await resp.json()) assert page.meta.total == 0 diff --git a/services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces.py b/services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces.py index 362eca1d82b..7e45b93400a 100644 --- a/services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces.py +++ b/services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces.py @@ -93,7 +93,7 @@ async def test_workspaces_workflow( resp, status.HTTP_200_OK, include_meta=True, include_links=True ) assert len(data) == 1 - assert WorkspaceGet.parse_obj(data[0]) == added_workspace + assert WorkspaceGet.model_validate(data[0]) == added_workspace assert meta["count"] == 1 assert links @@ -126,7 +126,7 @@ async def test_workspaces_workflow( resp = await client.get(f"{url}") data, _ = await assert_status(resp, status.HTTP_200_OK) assert len(data) == 1 - assert WorkspaceGet.parse_obj(data[0]) == replaced_workspace + assert WorkspaceGet.model_validate(data[0]) == replaced_workspace # DELETE a workspace url = client.app.router["delete_workspace"].url_for( diff --git a/services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces__folders_and_projects_crud.py b/services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces__folders_and_projects_crud.py index 477413d274d..3d5c2d7991a 100644 --- a/services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces__folders_and_projects_crud.py +++ b/services/web/server/tests/unit/with_dbs/04/workspaces/test_workspaces__folders_and_projects_crud.py @@ -296,7 +296,7 @@ async def test_workspaces_delete_folders( }, ) data, _ = await assert_status(resp, status.HTTP_201_CREATED) - added_workspace = WorkspaceGet.parse_obj(data) + added_workspace = WorkspaceGet.model_validate(data) # Create project in workspace project_data = deepcopy(fake_project)