Search - User list
Full Version: Node warning in Python processor
Root » PDG/TOPs » Node warning in Python processor
MatFacer
This question might not be specific to PDG/TOPs, but it is where the question is originating for me.

I love that raising an exception in a Python node will show a big ol' red exclamation icon next to the node and display the error message when inspecting the Work Item Info.

Is there a way to trigger a warning from within a Python node instead? I hope to get the same behaviour as the Error SOP when severity is set to Warning instead of Error.

I've found hou.NodeWarning, but it still shows as a full error instead of just a Warning. Calling warnings.warn also does not work, from my testing.
tpetrick
From a Python Processor or a Python Script TOP, you can use the pdg.Node.cookWarning(..) method to add a non-fatal warning to the node. That'll show up as a yellow exclamation mark: https://www.sidefx.com/docs/houdini/tops/pdg/Node.html#cookWarning [www.sidefx.com]

In both of those nodes, that method can be called on the self variable available in the Python code, e.g. self.cookWarning("Missing input files").
MatFacer
That works perfectly. Thank you!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB