Job Scripting: Render Stats

I just decided to get into python scripting. First thing I’m attempting is to create a mysql database for render statistics. So I simply set up a PostTask script that looks at the GetCurrentSlaveInfoValue to get jobid, taskid, rendertime etc. At first everything was going fine. But then I noticed some of the values were a little off. Sometimes they would have the values from the previous frame or even job, or sometimes just were blank. It then occurred to me that its not getting those values directly from the slave is it…its getting them from slaveinfo file on the server. Which is only updated every 30 seconds or so I believe. And if you have extremely short frames on a particular job…it won’t have the correct info. Is there another way to go about getting the current render stats?

Jeff

When retrieving slave information it is indeed grabbed from the repository where the slave will only update roughly every 30 seconds. If you’re simply trying to retrieve info on all currently rendering jobs you could use “GetJobsFilter status=rendering” which will retrieve the info from the jobs directly which will be more up to date. This can however take a few seconds if you have a large job list. Another option if to use “GetJob [jobId]” to retrieve specific jobs. Retrieving info about the slave, however, is limited to the latest info that the slave posted to the repository.

-Cody

Okay, that’s a possibility. But remember I’m running this as a post task script. How do I figure out the id of the task that just finished? The only place I thought I could get that was the slaveinfo, but apparently that info could be out of date.

Oh sorry, I missed that you were running it as a post task script. The commands I gave you were for deadlinecommand.

Unfortunately, there’s not much you can do when getting info from the slave, it will always be limited by the last time it updated.
You could try to making the slave report its info before you grab it, that might make the info more up to date.

Add from Deadline.Slaves import *

Now before grabbing the slave info try adding the following lines:

slaveManager = SlaveManager.GetInstance()
slaveManager.Slave.ReportSlaveInfo()

Let me know if that works. What data specifically are you trying to retrieve?

-Cody

I can’t get to this right away, but I’ll be sure to check this later.

What does ReportSlaveInfo() return. Is it an array of all the slave info…or do you give it an argument to return a specific value?

What I’m after is what task just finished and how long it took, so I can send that info to a mysql database.

ReportSlaveInfo doesn’t return anything. What it does is it tells the slave to update its slave info file on the repository, that way when you grab a value from the slave info it should hopefully be up to date.

Nope sorry that didn’t work. But here’s a question. I know pretty much nothing about python…but if you’re able to get access to the slave instance…can’t you just get the render time directly from it?

Jeff

Hehe, actually that would work as well. The Slave class is actually a .NET class that we can access because of IronPython.

You can use slaveManager.Slave.RenderingTime to return a TimeSpan.

Keep in mind that if the slave is running multiple concurrent tasks you may need to go in and retrieve the render time for each task. You can do this using slaveManager.Slave.CurrentTasks which returns an array of tasks. Each task has an ID, RenderTime, CompletedDateTime, and Status that you might need to use.

Hope this helps.

-Cody

Yes! that did work. I was trying to figure out what the other variables were, but unlike renderingtime they don’t seem to be the same as their slaveinfo counterparts. The other three I need to grab are Jobid, taskid (i see currenttasks would have this, but I bet it also has a the one actually rendering, and that would be one less step) and username. That’s all the variables I need for my database. So I don’t need to ask in the future…is there a function to get a list of all the variables. I saw something about a dict table…but that didn’t seem to work in this case…that might only work on other python modules…not sure.

Jeff

One way to display all the properties of an object is to use TypeDescriptor.

from System.ComponentModel import * to import

The following code prints off all the properties of the Slave class and their values as strings.

for descriptor in TypeDescriptor.GetProperties(slaveManager.Slave):
    print "\tName: " + descriptor.Name + " - Value: " + descriptor.GetValue(slaveManager.Slave).ToString()

To get the current JobId use slaveManager.Slave.CurrentJob.JobId

Because a slave may be rendering multiple tasks at a time, the slave keeps an array of tasks. Slave.RenderingTime is actually keeping track of the total time the slave has been rendering all of its current tasks. To retrieve the individual render times you’ll need to go into the task array and grab each one.