Node warning in Python processor

   1529   2   1
User Avatar
Member
4 posts
Joined: April 2014
Offline
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.

Attachments:
2022-02-17 12_52_36-e__easc-p4_code_dl_packages_EASC.WeightTransfer.Pipeline_dev_otl_18.5_WeightTran.png (14.7 KB)
2022-02-17 12_53_00-e__easc-p4_code_dl_packages_EASC.WeightTransfer.Pipeline_dev_otl_18.5_WeightTran.png (5.1 KB)

User Avatar
Staff
585 posts
Joined: May 2014
Offline
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").
Edited by tpetrick - Feb. 17, 2022 17:55:39
User Avatar
Member
4 posts
Joined: April 2014
Offline
That works perfectly. Thank you!
  • Quick Links