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

   70   4   1
User Avatar
Member
14 posts
Joined: 4月 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
2173 posts
Joined: 9月 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
14 posts
Joined: 4月 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 - 2019年5月17日 14:43:41

Attachments:
houdini_hda_python_error.png (107.6 KB)

User Avatar
Member
2173 posts
Joined: 9月 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
14 posts
Joined: 4月 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 - 2019年5月17日 15:14:22
  • Quick Links