|
24 | 24 |
|
25 | 25 | import logging |
26 | 26 | import sys |
| 27 | +from http import HTTPStatus |
27 | 28 | from typing import Any, Dict, Optional |
28 | 29 |
|
29 | 30 | from decoder.decoder import TextEncoding, decode |
@@ -259,26 +260,40 @@ def _handle_pod_message(self, msg: PodMessage) -> None: |
259 | 260 | # Project directory, while also marking the Step as DONE (successfully). |
260 | 261 | # We pass the outputs to the DM via a call to the API adapter's realise_outputs(). |
261 | 262 | # In return it copies (links) these files to the Project directory. |
262 | | - # |
263 | | - # We then inspect the Workflow to determine the next step. |
264 | | - |
265 | 263 | wfid = rwf_response["workflow"]["id"] |
266 | 264 | assert wfid |
267 | 265 | wf_response, _ = self._wapi_adapter.get_workflow(workflow_id=wfid) |
268 | 266 | _LOGGER.debug("API.get_workflow(%s) returned: -\n%s", wfid, str(wf_response)) |
269 | 267 |
|
| 268 | + error_num: int | None = None |
| 269 | + error_msg: str | None = None |
270 | 270 | if output_values := get_workflow_output_values_for_step(wf_response, step_name): |
271 | 271 | # Got some output values |
272 | 272 | # Inform the DM so it can link them to the Project directory |
273 | | - self._wapi_adapter.realise_outputs( |
| 273 | + response, status_code = self._wapi_adapter.realise_outputs( |
274 | 274 | running_workflow_step_id=r_wfsid, |
275 | 275 | outputs=output_values, |
276 | 276 | ) |
| 277 | + if status_code != HTTPStatus.OK: |
| 278 | + error_num = status_code |
| 279 | + error_msg = ( |
| 280 | + response["error"] |
| 281 | + if "error" in response |
| 282 | + else "Undisclosed error when realising outputs" |
| 283 | + ) |
277 | 284 |
|
278 | | - # Now we can mark this step as DONE... |
| 285 | + if error_num is not None: |
| 286 | + # The job was successful but linking outputs (back to the Project directory) |
| 287 | + # appears to have failed. |
| 288 | + self._set_step_error(step_name, r_wfid, r_wfsid, error_num, error_msg) |
| 289 | + return |
| 290 | + |
| 291 | + # We then inspect the Workflow to determine the next step. |
279 | 292 | self._wapi_adapter.set_running_workflow_step_done( |
280 | 293 | running_workflow_step_id=r_wfsid, |
281 | | - success=True, |
| 294 | + success=error_num is None, |
| 295 | + error_num=error_num, |
| 296 | + error_msg=error_msg, |
282 | 297 | ) |
283 | 298 |
|
284 | 299 | # We have the step from the Instance that's just finished, |
|
0 commit comments