Python in HDA - how to NodeError without bringing up console?

   5352   8   2
User Avatar
Member
26 posts
Joined: April 2009
Offline
Hey guys!

I'm building a HDA that uses python code and I can't figure out how to make the HDA node error in a houdini-esque fashion.
i.e. the HDA's file parm pointing to an unreadable file.
Whenever I manage to make it error, the python console appears, making it look to the user, like the code crashed.

These are the things I've tried:

1. Python node inside the HDA's graph, connected to its output node:
Errors get propagated properly, but on the first cook, the python node does not pass through its incoming geometry.
Also this setup can lead to unwanted recooks, when the python node changes nodes upstream.

2. Python node inside the HDA, but not part of its graph. The python node is one of the HDA's message nodes, to propagate its error upwards and is force cooked through callbacks from the HDA's parms:
The propagated errors appears as warnings on the HDA node and the python console comes up, stating that the node being ‘callbacked’ has errored.

3. Python module raising NodeError:
The HDA errors as expected, but also the python console appears, making it look like the HDA crashed, rather than a user error.

4. Python node or Python module driving an “error” node inside the HDA's graph.
As soon as the HDA is locked, attempting to change the error through python results in a permission error.
Making the “error” node editable, would allow user interference.

I will try adding invisible parms to the HDA, driving those through python and referencing them from the error node, but this feels like an elaborate and dirty workaround.


There surely must be a way to make an HDA node error without raising the console, but how?

Kindly,
-Sascha
User Avatar
Member
7733 posts
Joined: Sept. 2011
Offline
Number 3 is the normal way. What do you mean the the console appears? I don't see anything printed to standard out when a node errors. The error message from the exception is visible when looking at the node's middle mouse info.
User Avatar
Member
26 posts
Joined: April 2009
Offline
Here's an example.

Is this case it only brings up the python console with the error and doesn't even show it on the node.

I understand that the error printed, is because the callback failed, but how else to run code from the python module, if not through a callback from a parm?
Edited by saschaherfort - May 17, 2019 14:43:41

Attachments:
houdini_hda_python_error.png (107.6 KB)

User Avatar
Member
7733 posts
Joined: Sept. 2011
Offline
Oh, that's because it was raised from the python module. It behaves as expected when raised from a python node's cook script, such as in a python sop.

Another option is to use an error sop with expressions on the parameters. The error sop can be selected as the hda's message node.
User Avatar
Member
26 posts
Joined: April 2009
Offline
Yes I got NodeErrors just fine, when using a python inside the HDA, but then it fails to pass through its incoming geo on the first cook.
Also my python code modifies nodes upstream, so this may cause a recook loop.

When I tried having the python sop outside of the HDA's main graph and have it be a message node, the errors would only show up as warnings on the HDA.
Also force cooking the python sop with a callback brings up the console again.

I finally used an error sop with references to invisible parameters on the HDA, but that feels like it can't be the ‘official’ way.
Edited by saschaherfort - May 17, 2019 15:14:22
User Avatar
Member
126 posts
Joined: Aug. 2010
Offline
I'm having a similar problem. Is there any other solution?

My HDA script is triggered by a button, I would like to be able to raise a warning in case this script stops working.
User Avatar
Member
17 posts
Joined: Feb. 2014
Offline
saschaherfort
I finally used an error sop with references to invisible parameters on the HDA, but that feels like it can't be the 'official' way.

I’m very interested in this. Did that result in a proper clean error, i.e. not an Invalid Source or a warning, which are the two things I’m getting over and over? If so, could you let me know which parameters you linked?

Thanks in advance!
User Avatar
Member
26 posts
Joined: April 2009
Offline
Unai
saschaherfort
I finally used an error sop with references to invisible parameters on the HDA, but that feels like it can't be the 'official' way.

I’m very interested in this. Did that result in a proper clean error, i.e. not an Invalid Source or a warning, which are the two things I’m getting over and over? If so, could you let me know which parameters you linked?

Thanks in advance!


This is my setup that will make the node error without raising the python console:

  • my HDA contains an error node hooked up just before the 'output' node
  • it also has invisible custom parameters for the error toggle and message that are being referenced by the error node
  • the HDA script (inside the 'edit operator type' window) changes these parameters when required

IIRC, editing the parameters on the error directly, or from a python SOP inside the HDA resulted in a permission error. Hence the workaround through custom parameters and the HDA python module.

It still proclaims 'invalid source', but since the python console no longer pops up, it seems to not look like a bug/crash to other users anymore.
Edited by saschaherfort - July 5, 2021 12:52:10

Attachments:
hda_python_error.png (9.0 KB)

User Avatar
Member
17 posts
Joined: Feb. 2014
Offline
Ah, good to know! Thanks Sascha!
  • Quick Links