Python node prevents network cook

   2158   7   1
User Avatar
Member
207 posts
Joined: Nov. 2015
Offline
Hi;

I have a LOP network; halfway down my dependency chain, there's a Python node. This python node doesn't actually manipulate the incoming stage at all; it's sort of a utility that reads an image on disk, gathers some info, and promotes this info into params on the node, to which I refer elsewhere in my network. I just used a Python node because it was intuitive to me, and I want to 'trigger' the code in the node as part of how the scene evaluates itself.

However: if I modify anything upstream of the python node, I do not see downstream changes below the node unless I disable/enable the node, or step forward and back a frame; it seems these actions tickle the python node itself, which in turn allows the upstream nodes to cook properly.

Why is this? What can I do to eliminate this behavior? I don't experience this in SOPs that I've noticed...
User Avatar
Member
8507 posts
Joined: July 2007
Online
dhemberg
Why is this? What can I do to eliminate this behavior? I don't experience this in SOPs that I've noticed.
should be the same in SOPs with Python SOP

Python LOP and SOP evaluate the code whenever cooked, they dont need to be cooked until observed or until downstream node needs to cook and requests python to recook

these nodes are not good for adhoc python scripts that have nothing to do with cooking

instead use a python expression in parameter of a null or any node or HDA with python module for scripts unrelated to cooking
Edited by tamte - Aug. 25, 2022 19:07:38
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
207 posts
Joined: Nov. 2015
Offline
Hi;

I'm still ruminating on this, because I don't quite understand it.

if I have a python node, and make a change upstream of it while viewing a node downstream of it, shouldn't this encourage the python code to allow the changes upstream to flow down to the viewed node, regardless of what the code is actually doing? I don't understand why the Python node would "block" or otherwise obfuscate upstream changes.

The problem I'm running into with using the Python Module in an HDA is that my code depends on Context Options, and it's not clear to me how I can trigger the node to cook on a Context Option change; there only seem to be triggers for things like param changes, onCreate, onLoad, etc. So, in trying to take the advice to move my code to an HDA, I'm trading one problem (my scene graph failing to update) for another (the code itself fails to react to changes to Context Options).
User Avatar
Staff
4432 posts
Joined: July 2005
Offline
You are right that a Python LOP shouldn't "block" changes from upstream making it down to the bottom of the chain, regardless of the code in the Python LOP. If you can attach a simplified example showing this behavior we can take a look at it.

I don't really see how code in a python module can replace python code in a Python LOP, since they operate in totally different ways. In particular, when evaluating context options, a callback script on an HDA doesn't even have access to "in-network" context options - it will always see only global context options. If this is acceptable for what you want to do, then you can use the hou.addContextOptionChangeCallback method to add a callback that gets run every time a global context option value changes.
User Avatar
Member
207 posts
Joined: Nov. 2015
Offline
Thank you! Just knowing that this *should* be expected to work is helpful for debugging.

Also, I had no idea there was an hou.addContextOptionChangeCallback method, that's a massive help! Could I trouble you to elaborate on how this would interplay with an HDA module that has a dependency on a global Context Option? Would I add something like:

def myFunction():
...

to the PythonModule of the node, then:

hou.addContextOptionChangeCallback(myFunbction)

to the onCreated section of the same HDA?
User Avatar
Member
18 posts
Joined: Aug. 2016
Offline
I actually want to know if there is a way to stop cook up stream nodes,when I scene import a lot of geo into lop, any manipulate in sop can cost a lot of time to cook the node ,so I want to stop cook up stream and update once
User Avatar
Staff
4432 posts
Joined: July 2005
Offline
If this python functionality is truly "global", I don't see any reason to tie it to a particular HDA at all... You can do this all in the session module for the hip file. Bt if there is some reason you want to not run this callback until an instance of this particular HDA is created, then yes, what you've written there should work to start invoking myFunction in response to global context option changes, starting after the first instance of your HDA is created.
User Avatar
Staff
4432 posts
Joined: July 2005
Offline
heweiping.7
I actually want to know if there is a way to stop cook up stream nodes,when I scene import a lot of geo into lop, any manipulate in sop can cost a lot of time to cook the node ,so I want to stop cook up stream and update once

This is really a completely unrelated question, but I'd recommend a File Cache LOP. Then re-saving the upstream data to disk becomes an explicit operation that only happens when you press a button on the File Cache LOP.
  • Quick Links