2020 GroupExtraProperties ,
2121 GroupExtraPropertiesRepo ,
2222)
23+ from simcore_service_webserver .director_v2 ._client import get_directorv2_client
2324
2425from ..application_settings import get_application_settings
2526from ..db .plugin import get_database_engine
3940#
4041# PIPELINE RESOURCE ----------------------
4142#
42- # TODO: REFACTOR! the client class above and the free functions below are duplicates of the same interface!
4343
4444
4545@log_decorator (logger = _logger )
4646async def create_or_update_pipeline (
47- app : web .Application , user_id : UserID , project_id : ProjectID , product_name : str
47+ app : web .Application ,
48+ user_id : UserID ,
49+ project_id : ProjectID ,
50+ product_name : ProductName ,
4851) -> DataType | None :
52+ # NOTE https://github.com/ITISFoundation/osparc-simcore/issues/7527
4953 settings : DirectorV2Settings = get_plugin_settings (app )
5054
5155 backend_url = settings .base_url / "computations"
@@ -61,7 +65,7 @@ async def create_or_update_pipeline(
6165 product_name = product_name ,
6266 ),
6367 }
64- # request to director-v2
68+
6569 try :
6670 computation_task_out = await request_director_v2 (
6771 app , "POST" , backend_url , expected_status = web .HTTPCreated , data = body
@@ -102,18 +106,14 @@ async def is_pipeline_running(
102106async def get_computation_task (
103107 app : web .Application , user_id : UserID , project_id : ProjectID
104108) -> ComputationTask | None :
105- settings : DirectorV2Settings = get_plugin_settings (app )
106- backend_url = (settings .base_url / f"computations/{ project_id } " ).update_query (
107- user_id = int (user_id )
108- )
109109
110- # request to director-v2
111110 try :
112- computation_task_out_dict = await request_director_v2 (
113- app , "GET" , backend_url , expected_status = web . HTTPOk
111+ dv2_computation = await get_directorv2_client ( app ). get_computation (
112+ project_id = project_id , user_id = user_id
114113 )
115- task_out = ComputationTask .model_validate (computation_task_out_dict )
114+ task_out = ComputationTask .model_validate (dv2_computation , from_attributes = True )
116115 _logger .debug ("found computation task: %s" , f"{ task_out = } " )
116+
117117 return task_out
118118 except DirectorServiceError as exc :
119119 if exc .status == status .HTTP_404_NOT_FOUND :
@@ -129,13 +129,8 @@ async def get_computation_task(
129129async def stop_pipeline (
130130 app : web .Application , * , user_id : PositiveInt , project_id : ProjectID
131131):
132- settings : DirectorV2Settings = get_plugin_settings (app )
133- await request_director_v2 (
134- app ,
135- "POST" ,
136- url = settings .base_url / f"computations/{ project_id } :stop" ,
137- expected_status = web .HTTPAccepted ,
138- data = {"user_id" : user_id },
132+ await get_directorv2_client (app ).stop_computation (
133+ project_id = project_id , user_id = user_id
139134 )
140135
141136
@@ -147,6 +142,8 @@ async def delete_pipeline(
147142 * ,
148143 force : bool = True ,
149144) -> None :
145+ # NOTE https://github.com/ITISFoundation/osparc-simcore/issues/7527
146+
150147 settings : DirectorV2Settings = get_plugin_settings (app )
151148 await request_director_v2 (
152149 app ,
@@ -171,6 +168,7 @@ async def get_batch_tasks_outputs(
171168 project_id : ProjectID ,
172169 selection : TasksSelection ,
173170) -> TasksOutputs :
171+ # NOTE https://github.com/ITISFoundation/osparc-simcore/issues/7527
174172 settings : DirectorV2Settings = get_plugin_settings (app )
175173 response_payload = await request_director_v2 (
176174 app ,
@@ -193,18 +191,13 @@ async def get_batch_tasks_outputs(
193191 return TasksOutputs (** response_payload )
194192
195193
196- #
197- # WALLETS ----------------------
198- #
199-
200-
201194async def get_wallet_info (
202195 app : web .Application ,
203196 * ,
204197 product : Product ,
205198 user_id : UserID ,
206199 project_id : ProjectID ,
207- product_name : str ,
200+ product_name : ProductName ,
208201) -> WalletInfo | None :
209202 app_settings = get_application_settings (app )
210203 if not (
0 commit comments