Estimated Average Frame Time [Web Service]

Hi All

Hope all is well,

I am new to code so please go easy, but this is what i am having trouble with.

I am trying to add the estimated frame time into my monitor using the Web Service through Pulse.
I cant seem to find the code to get the job details Statistics, (RunningTime, Estimated Time Remaining, Total Task Time, Total Task Startup Time, ETC…)
I have tried the following code but from my guess is this only seems to work with the older deadline 5, We have just updated to Deadline 6.2

JobId = str(jobs[index][“JobId”])
job = RepositoryUtils.GetJob( JobId, True )
tasks = RepositoryUtils.GetJobTasks( job, False)
stats = JobUtils.CalculateJobStatistics( job, tasks)

AFT = stats.AverageFrameTime

Using Deadline 6.2 This usually kicks up an error like this…

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:

Your help would be much appreciated thanks for your time in advanced.

Chris

Hey Chris,

I just made a quick test shim and it ran great. From what you’re seeing, it looks like we might have a bug in the API somewheres. Can you send us the whole script? Note that because the job ids changed between 5.2 and 6.0 there may be some changes with how we grab those IDs.

Here’s the one I cooked up and ran through deadlinecommand:

[code]from Deadline.Scripting import *
from Deadline.Jobs import *

def main():
#JobId = str(jobs[index][“JobId”])
JobId = “546a53a7f4b70de8acb129aa”
job = RepositoryUtils.GetJob( JobId, True )
print(job)
tasks = RepositoryUtils.GetJobTasks( job, False)
stats = JobUtils.CalculateJobStatistics( job, tasks)

AFT = stats.AverageFrameTime 

print("  Average time: {0}".format(AFT))[/code]

Should run as:
“c:\Program Files\Thinkbox\Deadline6\bin\deadlinecommand.exe” executescript C:\full\path\to\stats.py

Hi Eamsler

Thanks for your help and sorry for the late replay, being my first post i though it would notify me through email which was not sent or due to the festive period missed.

We are trying to run this through Pulse Web service and get the Average time to print on the webpage.

Below is your code with a few alterations to work with the web service

from Deadline.Scripting import *
from Deadline.Jobs import *

def __main__( dlArgs, qsArgs ):
	
	jobs = PulseUtils.GetPulseJobs()
	
	JobId = str(jobs[0]["JobId"])
	#JobId = "546a53a7f4b70de8acb129aa"
	job = RepositoryUtils.GetJob( JobId, True )
	#print(job)
	tasks = RepositoryUtils.GetJobTasks( job, False)
	stats = JobUtils.CalculateJobStatistics( job, tasks)

	AFT = stats.AverageFrameTime 

	#print("  Average time: {0}".format(AFT))
	return str("  Average time: {0}".format(AFT))

Going through the web service this code still chucks out the error noted in my last first post.

I am very new to deadline and scripting so sorry if i am missing any basic knowledge of how i should be running it.
The idea is to have a customized monitor webpage i can easily script to give me all the information i need with extra bells and whistles to make my life easier.
I can get most of the other information fine its just any thing under (Job details then Statistics) i cant seem to access through the web service. If there is another way of getting this information then maybe we could give that a go.

Kind Regards

Chris

Well, I tried your script by creating a file as “[repo]/custom/scripts/WebService/Blah2.py” and it’s working quite nicely… I’m going to try in 6.

I’m assuming you’re running things correctly here. The error you’re seeing is because something in CalculateJobStatistics() is trying to create more than one singleton of DeadlineApplicationManager. That’s the object internally that keeps track of a bunch of different things (database connection, likely the internal cache, etc) and gets plumbed everywhere.

What version of Deadline are you running this on? 6.2.1 or 6.2.0?

Edit: Testied your script on Deadline 6.2.1.50 and things seem alright there as well.

Hi Eamsler

That’s very strange so it points to how we are set up over hear. Is there any logs i can send to you to see why this is happening our end?
Could this be incorrectly installed or configured? If so do you have any ideas on how we could fix this?
Happy to run a re-install of the whole system but if we don’t have to do that it would help massively due to losing all of our current settings and data.

Thanks for your help so far and if you have any suggestions to what would be the best solution please let me know there must be an easy fix.

Regards,

Chris.

I’m thinking a verbose Pulse log might be helpful, but it’s likely only going to show the same exceptions you’ve been posting.

If you run this script via DeadlineCommand, I’m curious to see what’s up there. Info on how to do that:
docs.thinkboxsoftware.com/produc … mmand-line

Would you have some time this week to look at this one on one? I’m in Winnipeg (Central standard time, GMT-6), if you’re in the UK, is there some time in the afternoon after 3:00pm that would work for you?

Feel free to e-mail me at edwinamsler@thinkboxsoftware.com to iron out the time.