Skip to content

Commit 353d240

Browse files
author
Alan Christie
committed
fix: Now handles errors from realising outputs
1 parent c1ef2ec commit 353d240

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

workflow/workflow_engine.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import logging
2626
import sys
27+
from http import HTTPStatus
2728
from typing import Any, Dict, Optional
2829

2930
from decoder.decoder import TextEncoding, decode
@@ -259,26 +260,36 @@ def _handle_pod_message(self, msg: PodMessage) -> None:
259260
# Project directory, while also marking the Step as DONE (successfully).
260261
# We pass the outputs to the DM via a call to the API adapter's realise_outputs().
261262
# In return it copies (links) these files to the Project directory.
262-
#
263-
# We then inspect the Workflow to determine the next step.
264-
265263
wfid = rwf_response["workflow"]["id"]
266264
assert wfid
267265
wf_response, _ = self._wapi_adapter.get_workflow(workflow_id=wfid)
268266
_LOGGER.debug("API.get_workflow(%s) returned: -\n%s", wfid, str(wf_response))
269267

268+
error_num: int | None = None
269+
error_msg: str | None = None
270270
if output_values := get_workflow_output_values_for_step(wf_response, step_name):
271271
# Got some output values
272272
# 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(
274274
running_workflow_step_id=r_wfsid,
275275
outputs=output_values,
276276
)
277+
if status_code != HTTPStatus.OK:
278+
error_num = status_code
279+
error_msg = response["error"]
280+
281+
if error_num is not None:
282+
# The job was successful but linking outputs (back to the Project directory)
283+
# appears to have failed.
284+
self._set_step_error(step_name, r_wfid, r_wfsid, error_num, error_msg)
285+
return
277286

278-
# Now we can mark this step as DONE...
287+
# We then inspect the Workflow to determine the next step.
279288
self._wapi_adapter.set_running_workflow_step_done(
280289
running_workflow_step_id=r_wfsid,
281-
success=True,
290+
success=error_num is None,
291+
error_num=error_num,
292+
error_msg=error_msg,
282293
)
283294

284295
# We have the step from the Instance that's just finished,

0 commit comments

Comments
 (0)