Getting the job ID of a task after submission

Actually we have a system like that :slight_smile:

Here is a little code, pasted verbatim, just to put you on the right track. You might have to explicitly pend the dependent jobs, to prevent them from running before new dependencies are added.

Deadline uses C# for Python or something like that, hence the odd array call.

A word of warning: since you have to RepositoryUtils.SaveJob, be careful that you do not save the job in multiple processes at once, otherwise you could have race conditions and missing data.

def update_finalize_job_with_output_deps(finalize_job, output_jobs):
    """ Add all output jobs as dependency to finalize job.
    This method is unsafe. Multiple nuke jobs may try to update the finalize job.
    """
    from Deadline.Scripting import RepositoryUtils
    from System import Array, String

    dependency_length = finalize_job.JobDependencyIDs.Length
    deps = Array.Resize[String](
        finalize_job.JobDependencyIDs,
        dependency_length + len(output_jobs))

    for i, j in enumerate(output_jobs):
        deps.SetValue(
            j.JobId,
            dependency_length + i)

    finalize_job.SetJobDependencyIDs(deps)

    return RepositoryUtils.SaveJob(finalize_job)


def pend_jobs(jobs):
    from Deadline.Scripting import RepositoryUtils
    for job in jobs:
        RepositoryUtils.PendJob(job)
1 Like