AWS Thinkbox Discussion Forums

How to get status of task from task ID using API?

Hi,

I am trying to get the status of a particular task by passing the task ID to the API. Something like GetTaskStatus(taskID) and the result being ‘Rendering’ or ‘Suspended’. Is it possible through either the REST API or the standalone Python API?

Try to adapt this for you needs:

import os
from System.IO import *
from Deadline.Scripting import *
from Deadline.Jobs import *

def __main__(*args):
    deadlinePlugin = args[0]
    
    job = deadlinePlugin.GetJob()
    jobId = job.JobId
    job = RepositoryUtils.GetJob(jobId, True)

    for job in RepositoryUtils.GetJobs(True):
        if job.JobStatus != "Pending":
            # continue
    
        jobId = job.JobId
        
        jobName = job.JobName
        
        job = RepositoryUtils.GetJob(jobId, True)

This code cannot run on its own using the Python interpreter right? I’ve been referring to the Python standalone API doc (Standalone Python API — Deadline 10.1.23.6 documentation) and I am unsure how to get the code you shared working.

I hope I’m not muddying the waters her, but there’s not really a “standalone api” and a “rest api”. There’s only REST and running code in the Deadline context (via deadlinecommand or via plugins/hooks in the repository ecosystem).

So in your case, if you want to use the REST API, make sure you’ve set up your web service and then go ahead and use the Deadline.DeadlineConnect module (or wrap your own http calls).

The documentation I was referring to in your other thread needs to be executed in the Deadline context. The same goes for @Kos’ snippet above.

Before I move on: You can make your own custom REST API hooks which is often useful, since the built-in methods are kind of limited. To do that you would place your custom scripts here:
repository\custom\scripts\WebService. Your scripts should define a main method like @Kos did, but this time the args will not contain a deadline plugin payload. Read more here: Web Service Scripts — Deadline 10.1.23.6 documentation

Back to your question and the (default) REST API. Look at the Deadline.DeadlineConnect.DeadlineCon object and specifically Jobs, Tasks and TaskReports.

  1. Query whatever jobs you need. Retain their IDs once you’ve filtered to your liking
  2. Fetch the tasks for each job. Again, retain their IDs. Map internally in whatever way suits you best
  3. Fetch reports for the tasks you’re interested in

Hope this helps.

Cheers

1 Like
Privacy | Site terms | Cookie preferences