Access job object from Python script

Hey guys,

I’m trying to do some post-render processing that spans over several Maya render jobs, so I’m feeling like the best approach is to submit a standalone job (Python) with the above jobs as dependencies. In this scenario, the Python job will fire once all specified jobs have finished rendering.

However, I’m coming up short on how to access the job object within my Python job. Essentially I need access to the Deadline.* objects to look up my job dependency and in turn what those other jobs produced for output. I could, I think, submit a dummy job that finishes instantly and hook in with a PostJob script, but that seems a bit counter intuitive.

I’ve had a quick look at the Python plugin, but from what I can find it seems unlikely that I’m able to execute my script within the right environment.

Any thoughts?

Hmm, seems like I can do:
deadlinecommand.exe -ExecuteScriptNoGui <the script>.

Maybe I’ll farm that out as a dependent job instead of a straight up Python script.

Anyway, I’d love to hear your thoughts.

Edit: No, I still can’t access the current job object, only jobs I know the ID of. And I don’t see a way to pass more command line parameters to deadlinecommand.exe which can make their way to my script file

So, after X number of Maya jobs, create special job Y? Yeah, I do think an OnJobCompleted event is a good way to go there. The PostJob scripts are the ancient way of running something once a job completes and isn’t ideal.

A good example of how we handle this in Deadline itself is Draft. Take a look at “[repo]/events/DraftEventPlugin/DraftEventPlugin.py” as that is exactly what we’re doing, but we create a job after one has completed. You’ll have full access to the internal Python API in an event script though so you can poll for the other jobs.

Thanks for the reply, Edwin.

What I ended up doing, at least in the meantime, is submit a dummy command-line job with the right dependencies and have a PostJobScript to execute the magic. Aka my non-preferred option from the original post.

The reasoning was simple (and lazy): I had access to all the job IDs at submission time (from a Python module), and could mess around with the dependency graph at that point. I figured if I wrote an event hook for this, it would become a logistical challenge to figure out how many jobs I was waiting on, what their IDs are, etc.

For what it’s worth, I still think this is a roundabout way of getting things done. But the dummy job executes in about 1 second, so it’s not much of an overhead.

Anyway, here’s a screenshot of the whole mess. I’m happy to revisit this in the future if you have any thoughts. Although, you know, if it ain’t broken… etc.

Cheers