@@ -104,6 +104,7 @@ def _handle_errors_context(project_id: UUID):
104
104
) from err
105
105
106
106
except httpx .TimeoutException as err :
107
+ # TODO: refer resource?
107
108
oec = create_error_code (err )
108
109
err_detail = (
109
110
f"Service handling job operation on '{ project_id } ' timed out [{ oec } ]"
@@ -121,6 +122,21 @@ def _handle_errors_context(project_id: UUID):
121
122
detail = err_detail ,
122
123
) from err
123
124
125
+ except httpx .HTTPError as err :
126
+ oec = create_error_code (err )
127
+ err_detail = f"Unexpected error while processing job '{ project_id } ' [{ oec } ]"
128
+ _logger .exception (
129
+ "%s: %s" ,
130
+ err_detail ,
131
+ to_httpx_command (err .request ),
132
+ extra = {"error_code" : oec },
133
+ )
134
+
135
+ raise HTTPException (
136
+ status_code = status .HTTP_500_INTERNAL_SERVER_ERROR ,
137
+ detail = err_detail ,
138
+ ) from err
139
+
124
140
125
141
class DirectorV2Api (BaseServiceClientApi ):
126
142
async def create_computation (
@@ -129,17 +145,18 @@ async def create_computation(
129
145
user_id : PositiveInt ,
130
146
product_name : str ,
131
147
) -> ComputationTaskGet :
132
- response = await self .client .post (
133
- "/v2/computations" ,
134
- json = {
135
- "user_id" : user_id ,
136
- "project_id" : str (project_id ),
137
- "start_pipeline" : False ,
138
- "product_name" : product_name ,
139
- },
140
- )
141
- response .raise_for_status ()
142
- return ComputationTaskGet (** response .json ())
148
+ with _handle_errors_context (project_id ):
149
+ response = await self .client .post (
150
+ "/v2/computations" ,
151
+ json = {
152
+ "user_id" : user_id ,
153
+ "project_id" : str (project_id ),
154
+ "start_pipeline" : False ,
155
+ "product_name" : product_name ,
156
+ },
157
+ )
158
+ response .raise_for_status ()
159
+ return ComputationTaskGet (** response .json ())
143
160
144
161
async def start_computation (
145
162
self ,
@@ -149,11 +166,8 @@ async def start_computation(
149
166
groups_extra_properties_repository : GroupsExtraPropertiesRepository ,
150
167
cluster_id : ClusterID | None = None ,
151
168
) -> ComputationTaskGet :
152
-
153
169
with _handle_errors_context (project_id ):
154
-
155
170
extras = {}
156
-
157
171
use_on_demand_clusters = (
158
172
await groups_extra_properties_repository .use_on_demand_clusters (
159
173
user_id , product_name
@@ -180,9 +194,7 @@ async def start_computation(
180
194
async def get_computation (
181
195
self , project_id : UUID , user_id : PositiveInt
182
196
) -> ComputationTaskGet :
183
-
184
197
with _handle_errors_context (project_id ):
185
-
186
198
response = await self .client .get (
187
199
f"/v2/computations/{ project_id } " ,
188
200
params = {
0 commit comments