Hi everyone,
I’ve written a script that I’ve inserted inside Deadline’s Repository (vers. 10.2) because I had the following problems:
1- a few frames get stuck in a loopè not completing the render for no particular reason (nuke and blender);
2- a few frames are completed in a few seconds with a 0 KB file (blender only).
The script is in the repository’s “events” in a custom folder
The script is as follows:
import os
import time
from future import absolute_import
from Deadline.Events import DeadlineEventListener
from Deadline.Scripting import PathUtils, RepositoryUtils
def GetDeadlineEventListener():
return MyDeadlineEventListener()
class MyDeadlineEventListener (DeadlineEventListener):
def init(self):
self.OnJobStartedCallback += self.OnJobStarted
self.OnTaskCompletedCallback += self.OnTaskCompleted
def OnJobStarted(self, job):
if job.JobStatus == "Rendering":
self.ScheduleTaskChecking(job)
def OnTaskCompleted(self, task):
job = RepositoryUtils.GetJob(task.JobId)
if job.JobStatus == "Rendering" and task.TaskStatus == "Completed":
self.ScheduleTaskChecking(job)
def ScheduleTaskChecking(self, job):
jobFramesFolder = job.JobOutputDirectories[0] # Cartella dei frame renderati
completedTasks = RepositoryUtils.GetJobTasks(job, True, "Completed") # Elenco dei task completati
averageTime = self.CalculateAverageTime(completedTasks) # Calcolo del tempo medio dei task completati
for task in completedTasks:
if task.TaskOutputFileByteSize == 0: # Verifica se la dimensione finale del task è pari a zero byte
RepositoryUtils.RequeueTask(task) # Rimanda in rendering il task
if len(completedTasks) >= 5: # Verifica se ci sono almeno cinque task completati
renderingTasks = RepositoryUtils.GetJobTasks(job, True, "Rendering") # Elenco dei task in rendering
for task in renderingTasks:
if self.IsTaskExceedingTimeLimit(task, averageTime): # Verifica se il tempo di rendering supera il limite
task.TaskStatus = "Suspended" # Sospende il task
RepositoryUtils.RequeueTask(task) # Rimanda in rendering il task
self.ScheduleCallback(30) # Richiama la verifica ogni 30 secondi
def CalculateAverageTime(self, tasks):
totalSeconds = 0
for task in tasks:
taskSeconds = (task.TaskEndTime - task.TaskStartTime).TotalSeconds
totalSeconds += taskSeconds
return totalSeconds / len(tasks)
def IsTaskExceedingTimeLimit(self, task, averageTime):
taskSeconds = (DateTime.Now - task.TaskStartTime).TotalSeconds
return taskSeconds > (averageTime * 4)
def ScheduleCallback(self, interval):
deadlinePlugin = GetDeadlinePlugin()
deadlinePlugin.SetScriptCallbackDeadlineCommand(interval)
It’s parameter’s file is like this:
[State]
Type=Enum
Items=Global Enabled;Disabled
Category=Options
CategoryOrder=0
CategoryIndex=0
Label=State
Default=Disabled
Description=If Global, all jobs and Workers will trigger the events for this plugin. If Disabled, no events are triggered for this plugin.
[FrameReloaderEvent]
Type=enum
Values=On Job Started;On Job Finished;On Job Started and On Job Finished
Category=Options
CategoryOrder=0
Index=1
Default=On Job Started
Label=Perform Frame Check
Description=It analyses frames at 0 KB or stuck in a loop and reques them.
This is the menu I’ve built
I really have no clue in how to fix it, it has to be something simple but I really can’t figure it out.
Thank you in advance
AB