1818from models_library .projects_nodes_io import DownloadLink , NodeID , PortLink
1919from models_library .projects_ui import StudyUI
2020from models_library .services import ServiceKey , ServiceVersion
21- from pydantic import AnyUrl , HttpUrl , parse_obj_as
21+ from pydantic import AnyUrl , HttpUrl , TypeAdapter
2222from servicelib .logging_utils import log_decorator
2323
2424from ..projects .db import ProjectDBAPI
3232_logger = logging .getLogger (__name__ )
3333
3434
35- _FILE_PICKER_KEY : ServiceKey = parse_obj_as (
36- ServiceKey , "simcore/services/frontend/file-picker"
35+ _FILE_PICKER_KEY : ServiceKey = TypeAdapter ( ServiceKey ). validate_python (
36+ "simcore/services/frontend/file-picker"
3737)
38- _FILE_PICKER_VERSION : ServiceVersion = parse_obj_as (ServiceVersion , "1.0.0" )
38+ _FILE_PICKER_VERSION : ServiceVersion = TypeAdapter (ServiceVersion ). validate_python ( "1.0.0" )
3939
4040
4141def _generate_nodeids (project_id : ProjectID ) -> tuple [NodeID , NodeID ]:
@@ -55,12 +55,12 @@ def _create_file_picker(download_link: str, output_label: str | None):
5555 # also to name the file in case it is downloaded
5656
5757 data = {}
58- data ["downloadLink" ] = url = parse_obj_as (AnyUrl , download_link )
58+ data ["downloadLink" ] = url = TypeAdapter (AnyUrl ). validate_python ( download_link )
5959 if output_label :
6060 data ["label" ] = Path (output_label ).name
6161 elif url .path :
6262 data ["label" ] = Path (url .path ).name
63- output = DownloadLink .parse_obj (data )
63+ output = DownloadLink .model_validate (data )
6464
6565 output_id = "outFile"
6666 node = Node (
@@ -69,7 +69,7 @@ def _create_file_picker(download_link: str, output_label: str | None):
6969 label = "File Picker" ,
7070 inputs = {},
7171 inputNodes = [],
72- outputs = {output_id : output }, # type: ignore[dict-item]
72+ outputs = {output_id : output },
7373 progress = 0 ,
7474 )
7575 return node , output_id
@@ -94,12 +94,12 @@ def _create_project(
9494 uuid = project_id ,
9595 name = name ,
9696 description = description ,
97- thumbnail = thumbnail , # type: ignore[arg-type]
97+ thumbnail = thumbnail ,
9898 prjOwner = owner .email ,
9999 accessRights = {owner .primary_gid : access_rights }, # type: ignore[dict-item]
100100 creationDate = DateTimeStr (now_str ()),
101101 lastChangeDate = DateTimeStr (now_str ()),
102- workbench = workbench , # type: ignore[arg-type]
102+ workbench = workbench ,
103103 ui = StudyUI (workbench = workbench_ui ), # type: ignore[arg-type]
104104 )
105105
@@ -153,7 +153,7 @@ def _create_project_with_filepicker_and_service(
153153 version = viewer_info .version ,
154154 label = viewer_info .label ,
155155 inputs = {
156- viewer_info .input_port_key : PortLink ( # type: ignore[dict-item]
156+ viewer_info .input_port_key : PortLink (
157157 nodeUuid = file_picker_id ,
158158 output = file_picker_output_id ,
159159 )
0 commit comments