22import logging
33from collections .abc import Coroutine
44from contextlib import AsyncExitStack
5- from typing import Any , TypeAlias
5+ from typing import Any , Type , TypeAlias
66
77from aiohttp import web
88from jsonschema import ValidationError as JsonSchemaValidationError
1515from models_library .utils .fastapi_encoders import jsonable_encoder
1616from models_library .utils .json_serialization import json_dumps
1717from models_library .workspaces import UserWorkspaceAccessRightsDB
18- from pydantic import parse_obj_as
18+ from pydantic import TypeAdapter , parse_obj_as
1919from servicelib .aiohttp .long_running_tasks .server import TaskProgress
2020from servicelib .mimetype_constants import MIMETYPE_APPLICATION_JSON
2121from simcore_postgres_database .utils_projects_nodes import (
@@ -132,14 +132,14 @@ async def _copy_project_nodes_from_source_project(
132132 db : ProjectDBAPI = ProjectDBAPI .get_from_app_context (app )
133133
134134 def _mapped_node_id (node : ProjectNode ) -> NodeID :
135- return NodeID (nodes_map [NodeIDStr (f"{ node .node_id } " )])
135+ return NodeID (nodes_map [TypeAdapter ( NodeIDStr ). validate_python (f"{ node .node_id } " )])
136136
137137 return {
138138 _mapped_node_id (node ): ProjectNodeCreate (
139139 node_id = _mapped_node_id (node ),
140140 ** {
141141 k : v
142- for k , v in node .dict ().items ()
142+ for k , v in node .model_dump ().items ()
143143 if k in ProjectNodeCreate .get_field_names (exclude = {"node_id" })
144144 },
145145 )
@@ -157,7 +157,7 @@ async def _copy_files_from_source_project(
157157):
158158 db : ProjectDBAPI = ProjectDBAPI .get_from_app_context (app )
159159 needs_lock_source_project : bool = (
160- await db .get_project_type (parse_obj_as (ProjectID , source_project ["uuid" ]))
160+ await db .get_project_type (TypeAdapter (ProjectID ). validate_python ( source_project ["uuid" ]))
161161 != ProjectTypeDB .TEMPLATE
162162 )
163163
@@ -178,8 +178,7 @@ async def _copy_files_from_source_project(
178178 ):
179179 task_progress .update (
180180 message = long_running_task .progress .message ,
181- percent = parse_obj_as (
182- ProgressPercent ,
181+ percent = TypeAdapter (ProgressPercent ).validate_python (
183182 (
184183 starting_value
185184 + long_running_task .progress .percent * (1.0 - starting_value )
@@ -403,7 +402,7 @@ async def create_project( # pylint: disable=too-many-arguments,too-many-branche
403402 )
404403 )
405404 new_project ["accessRights" ] = {
406- gid : access .dict () for gid , access in workspace_db .access_rights .items ()
405+ gid : access .model_dump () for gid , access in workspace_db .access_rights .items ()
407406 }
408407
409408 # Ensures is like ProjectGet
0 commit comments