How to get Task of Job?


#1

Trying to create an event to log info of each Task upon job completion. How do I get the list of Task belonging to that particular job?

Looking at class Jobs, I see nothing related to task that would return a list? Or is there other way I can query tasks using job ID?


#2

This should do the trick.

tasks = RepositoryUtils.GetJobTasks(job, True)
task = tasks.TaskCollectionTasks
for t in task: 
   print "{0} Task:{2} - {1}".format(t.TaskSlaveName, t.TaskProgress, t.TaskId)

#3

Thank you panze.

May I ask another question. Is Deadline’s DateTime object documented somewhere? I used dir() to get it’s method, where else can I find that out?


#4

Good question, I’m not sure I know where it’s documented (or if it is). I’ve just checked what it outputs and hacked from there.

For example task render time in seconds.

for t in task: 
    taskTimeRaw = t.TaskRenderTime
    taskTime = datetime.datetime.strptime(str(taskTimeRaw), '%H:%M:%S.%f0')
    t2 = datetime.datetime(1900,1,1)
    TaskRenderTimeInSeconds = (taskTime-t2).total_seconds()