How to "Submit Graph as Job" automatically from within TOPs?

   2020   3   2
User Avatar
Member
4 posts
Joined: Aug. 2019
Offline
Hi,

I'm currently cooking a set of assets on a build farm using the “Submit Graph as Job” festure in the HQueue scheduler.
There are multiple Jobs needed for creating all the assets.
It works just fine, but I wanted to streamline the process a bit.
Instead of clicking the “submit” button multiple times to trigger all the Jobs I need, I would like to automate that - ideally in a second TOPs network.

Currently, I'm trying to do that via a python node in a separate TOPs network.
I copy&pasted some code I found in /pdg/job/top.py:

import hou
node = hou.node("/obj/TOPNET")              # find TOPs for current asset
node.cook(force=True)                       # create PDG graph
node.executeGraph(False, True, False, True) # execute PDG graph

I run the TOPs network containing tis code via “Tasks->Dirty and cook output node” on my local PC.

It does do the job, but unlike the “Submit graph as Job”, it doesn't seem to run he TOPNET on the build farm (as I hoped it would), but rather on my local PC.
I don't see any job coming up on the HQueue dashboard (the web frontend) when I run that script.
Playing around with the booelan arguments didn't help either.

Any ideas what I might be doing wrong?
User Avatar
Member
10 posts
Joined: Oct. 2015
Offline
Maybe try using the “submitGraphAsJob” function instead of execute, something like:
import hou
from pdg import scheduler
schedulerNode = hou.node("/obj/TOPNET/hqueuescheduler") 

scheduler.submitGraphAsJob({}, schedulerNode, "mySchedulerName")
The first argument isn't actually used in the function, the second is the scheduler node and the third is just a nice name to give the scheduler for the pop-up telling you the graph was submitted. There's also a 4th kwarg for quiet (which disables the pop-up) which might be handy if you're doing this multiple times.

You can find this in pdg/scheduler.py for a bit more info on how the arguments get used but from the looks of things this is the function which is ultimately called by the “Submit” button on the scheduler.
Matt Traynar

Software Developer @ MPC
User Avatar
Member
4 posts
Joined: Aug. 2019
Offline
Matt, you're the man. Thanks a lot!
Edited by rmayster - July 31, 2020 09:23:47
User Avatar
Member
10 posts
Joined: Oct. 2015
Offline
All good!
Matt Traynar

Software Developer @ MPC
  • Quick Links