issue showing work_item Error on HDA interface

   1222   1   1
User Avatar
Member
6 posts
Joined: 11月 2022
Offline
Hello Forum.
I am building a TOP HDA, which includes several Python Script TOPs. When something goes wrong in one of these Python Script nodes, I issue a work item Error with a custom error message using
pdg.WorkItem.addError(error_message, fail_task=True)

My problem now is that, when inspecting the failed items on the HDA interface, it seems like the work item Error Message from my Python Script nodes inside the HDA does not bubble up correctly to the HDA interface.

On further investigation, I found out that the work item Error Message, which I can access from the HDA interface, seems to be dependent on which Output Flag is set inside the HDA. Here is a video (GIF) illustrating the behaviour on a very simple Subnet.

- When the Output flag is set on the Output TOP inside the Subnet, I get no Error Message on the Subnet Interface' work items, but just the State "Failed Dependencies".
- When the Output flag is set on the Python Script TOP inside the Subnet, I can display my custom Error Message on the Subnet Interface' work items.

For this Subnet example, I could just have the Output Flag set to the one Python Script TOP so that my Error Messages bubbles up correctly. But the problem in my HDA is, that I have several Python Script TOPs and if I set the Output Flag on the last Python Script and a work item fails in an upstream Python Script, then the Subnet Interface' work items will still only display the State "Failed Dependencies" without my custom error message.

Is this the desired TOP behaviour? Am i doing something wrong, or should i contact support and check if this is a bug?
I checked in SOPs and it seems like when there is an error inside a Subnet, then the errors are collected and bubble up to the Subnet interface like "Invalid Source. Error: Unable to evaluate expression...."
Edited by a41b - 2022年11月22日 04:47:12

Attachments:
nested_work_item_error_message.gif (1.2 MB)

User Avatar
Member
6 posts
Joined: 11月 2022
Offline
I now came up with the following solution:


Inside my Python Nodes I do the following when an error accours and I want to fail the work item:
failure = "My custom error message!"
work_item.setIntAttrib("hasfailure", 1)
work_item.setStringAttrib("failure", failure)
work_item.addError(failure, fail_task=True)

After the Python nodes, I catch the work items with a "Filter By State" TOP and direct the work items to an "Error" TOP at the very end of the HDA/Subnet. There I recreate the work item error again using the previously created attributes @hasfailure and @failure.
The Error TOP is the one whose display flag is always set, this way I will see the failed work items on the HDA inface no matter where the error inside my HDA/Subnet occurs.

What is your optinion about that solution?
Edited by a41b - 2022年11月22日 04:47:21

Attachments:
filter_by_state.jpg (98.4 KB)

  • Quick Links