Deadline Statistics in the API

Hi

I was just wondering if someone knew how to get the Job Statistics through Python API?

For example…
Average Ram usage.
Average task time.
Estimate time remaining.

I have been through the “Deadline-6.2.1-Standalone-Python-Reference.pdf” and cant find any information to get these results.
Is it possible to get this info through the Standalone Python API?

Thanks for your time
Chris
www.rendernow.co.uk

Hello Chris,

As far as I am told, this is possible, you would look in job object portion of the scripting docs. If you aren’t sure what you’re looking for, please advise and I can have one of our coders look it up for you.

(continuing on the support ticket)

Hi,
The Standalone Python API doesn’t currently have the ability to calculate stats.

It can be accessed via the Scripting API as follows:

[code]from Deadline.Scripting import *

def main( *args ):

# Grab all jobs
alljobs = RepositoryUtils.GetJobs( True )

# Filter down to only "Active" jobs
jobs=[]
for job in alljobs:
    if job.JobStatus == "Active":
        jobs.append( job )

for job in jobs:

    print "JobStatus: %s" % job.JobStatus

    jobId = job.JobId
    print "JobId: %s" % jobId
    
    jobName = job.JobName
    print "JobName: %s" % jobName
    
    jobPool = job.JobPool
    print "JobPool: %s" % jobPool

    jobCompletedChunks = job.CompletedChunks
    print "JobCompletedChunks: %s" % jobCompletedChunks

    job = RepositoryUtils.GetJob( jobId, True )
    tasks = RepositoryUtils.GetJobTasks( job, True )
    stats = JobUtils.CalculateJobStatistics( job, tasks )

    jobAverageFrameTime = stats.AverageFrameTime
    jobAverageRamUsage = stats.AverageRamUsage/1024/1024

    print "JobAverageFrameTime: %s" %  jobAverageFrameTime
    print "JobAverageRamUsage: %sMb" % jobAverageRamUsage[/code]

This could also be executed externally via DeadlineCommand on your machine:

../DeadlineCommand.exe -ExecuteScript "/path/to/script.py"

CalcStats.py.zip (560 Bytes)

FYI. CalculateJobStats function to be exposed to our Standalone Python API has now been added to our wishlist.

Hi Mike

Thanks for letting me know this isn’t in the Deadline API.
What would be the best way to use Python API to call a script running though deadline (…/DeadlineCommand.exe -ExecuteScript “/path/to/script.py”) then grab the results and print them in python API is this possible?

Thanks for your time.

Chris

Hi Chris,
Exactly, execute the script just like you describe and my example script above shows how you can return the information your after.
For other values, see our API:
docs.thinkboxsoftware.com/produc … entry.html

EDIT: Sorry sir, misread your post. I think your asking how to spawn the actual DeadlineCommand.exe process. I would use subprocess:
docs.python.org/2/library/subprocess.html

Thanks Mike

I will check this out as soon as i get a moment to see if it works.

When running your script its coming up with an error…

An error occurred while executing script “RNDeadline.py” for the Pulse WebService:
Python Error: InvalidOperationException : can not create two instances of DeadlineApplicationManager
at Deadline.Monitor.MonitorManager…ctor()
at Deadline.Scripting.JobUtils.CalculateJobStatistics(Job job, TaskCollection taskCollection) (Python.Runtime.PythonException)
Stack Trace:
[’ File “none”, line 32, in main\n’]

Have you seen this error before.

Thanks for everything so far.

Ah. “CalculateJobStatistics” wasn’t added until Deadline v7.0. What version of Deadline are you running?

I am currently running v6.2

I’m now re-installing Deadline and upgrading to 7.1 I will try your code when this is done.
Maybe the re-install will solve any bugs as well.

The upgrade to 7.1 was a bit of a pain I’m sure there is better ways of updating the software than the route I took.
But looks like everything is working so far Including your code…

Thanks for your help Mike

Just a follow up on this one after awhile.

Deadline 8.1 beta now has a ​CalculateJobStatistics() function you can call to grab stats while in the standalone Python API.

If you want to grab it via HTTP directly, the endpoint is the same for jobs, just with an additional parameter:

“/api/jobs?JobID=[job id]&Statistics=true”