Each Job if submitted from inside of third party application (such as Maya, Max, AE and etc) is assigned a pair of Job Info parameters-values: OutputDirectory#
and OutputFilename#
:
`OutputDirectory0=/dirnameA/dirnameB/dirnameC`
`OutputFilename0=imageName.[####].png`
If there were multiple layers/comps/passes defined in submitted file there will be multiple OutputDirectory#
-OutputFilename#
attribute pairs. The values for these attributes can be previewd by going to job’s Job Properties > Submission Params tab.
Each OutputDirectory#
parameter is used to build Job Output>Explore Output>OutputDirectory#
job’s right-click menu in Deadline Monitor.
Similarly OutputFilename#
is used to build Job Output>View Output>OutputFilename#
to view or playback an image sequence rendered.
Aside from convenience of accessing the rendered folders or images from Deadline right-click menu these attributes are used in other places (Draft Event for instance reads them to build a list of input-output arguments for the files to be processed).
I’ve edited some of Deadline Plugin’s PreRenderTasks()
method so it reads submitted file collecting an information on where the file’s render output folder is. Each job then (even the one submitted from outside of application (via Deadline>Submit>AppName
) gets valid OutputDirectory#
-OutputFilename#
keyValue assigned using .set_JobOutputFileNames(list)
and .set_JobOutputDirectories(list)
.
After new job’s keyValue is assigned I verify it’s now a property of Job using .JobOutputDirectories()
and .JobOutputFileNames()
. But even while .JobOutputDirectories()
and .JobOutputFileNames()
print out the new keyValues are assigned Job Output>Explore Output>OutputDirectory#
and Job Output>View Output>OutputFilename#
right click menu are still not updated. Aside from not being able to update Job’s right click menu the job’s Properties>Submission
tab’s information is not updated too. I would like to know which Job property needs to be modified to force all job GUI element to update (so right-click menu point to a new output folder location).
Deadline6 is not using any text files (other than submission plugin.job and info.job). After the job is submitted I assume the job parameters are stored in database. Please advice on how it would be possible to modify Job attrs/values so the changes that took place via scripting and API (via Plugin’s PreRenderTasks(),PostRenderTasks() or custom Deadline Events) are propagated through and out to every Deadline GUI element making after-submission-changes to Job attributes appear the same as “by the time Job was submitted” attributes.
Thanks in advance.
1 Like
Since there was no response from Thinkbox I am posting a partial answer to myself here.
There are two methods available:
RepositoryUtils.SetJobOutputDirectories(job,outputDirectories )
and
RepositoryUtils.UpdateJobOutputFileNames(job, outputFileNames )
Both method accepts two arguments.
A first argument is an instance of Deadline’s Job Class. It is clear.
A QUESTION 1:
.SetJobOutputDirectories()
As it has been briefly mentioned in so-called “Deadline-6-1-54655-Scripting-Reference”
as a second argument this method expects: “The list of output directories.” And it is object…
Will it take a list of string like:
['/path/to/output/dir1','/path/to/output/dir2']
A QUESTION 2:
.UpdateJobOutputFileNames(job, outputFileNames)
This method could be useful and probably does exactly what I want.
But the description in docs is completely missing on this method. Can a following list to be supplied as a second argument?
['/path/to/output/dir1/Comp 1.00001.tga','/path/to/output/dir1/Comp 1.00002.tga']
What is the syntax for these methods?
I wonder if anyone is reading this.
Here it goes.
I ended up using UpdateJobOutputFileNames method
RepositoryUtils.UpdateJobOutputFileNames(job, outputFileNames )
since it does two things at once: it sets the JobOutputDirectories and it sets OutputFileNames. Deadline Monitor right-click menu as well as Job Properties are all updated.
The syntax for the list argument “outputFileNames”:
outputFileNames=["/volume/drive/full/path/to/directoryA/ifSingleFileOrMovieNoPaddingNeeded.mov", “/volume/drive/full/path/to/directoryB/filenameWithFrameNumbersPaddingNeeded.####.sgi”, “/volume/drive/full/path/to/directoryC/filenameWithFrameNumbersPaddingNeeded _ ##.mov”]
Thanks for support!
I’m pretty sure the API doesn’t let you change things like output location in the job during the pre-post job stuffs. It’s either that, or the job information needs to be saved somewhere.
I’ll chat with the guys and see if I can get you a meaningful answer.
You can change Job’s output folder and Job output filenames as well as to set a new frame list in PreRenderTasksCallback() and in PostRenderTasksCallback():
There are several methods available:
job.set_OutputDirectories() sets the value to Job.OutputDirectories Job’s attribute but won’t update any GUI elements.
outputDirs=['/volume/diskA/dirA/','/volume/diskB/dirB/']
job.set_OutputDirectories(outputDirs)
RepositoryUtils.SetJobOutputDirectories(job, outputDirs ) will do the same: it will set the Job.OutputDirectories Job’s attrubute and update GUI element (right click menu - Job Output > Explore Output > DirName).
RepositoryUtils.UpdateJobOutputFileNames(job, newOutputFileNames) will set all associated GUI elements, Job.OutputDirectories Job’s Attribute as well as job.JobOutputFileNames Job’s attribute.
job.set_OutputFileNames(newOutputFileNames) sets job.JobOutputFileNames Job’s attribute but won’t update any GUI elements.
job.set_FramesList(frameRange) sets or updates job.JobFramesList Job’s attribute. It won’t update any GUI. Argument variable frameRange should be a string variable ‘firstNumber-lastNumber’. Example
myFrameRange='12-128'
Please let me know if there is any method to update Job’s Frame List attribute so all Gui elements are updated as well.
P.s. When used with RepositoryUtils.UpdateJobOutputFileNames(job, newOutputFileNames) newOutputFileNames list of filenames variable should list entire filepath to the images (not just the file names) such as : ‘’ [’/volume/diskA/dirA/image.###.tga’, ‘/volume/diskB/dirB/image.#.sgi’, ‘/volume/diskC/dirC/movie.mov’]
Hi,
Just wanted to dive in here and clarify something. (I’m not too sure how I missed this forum post until now…)
Once you grab an instance of the “job” object, you can change it’s properties and then you need to save the job object:
RepositoryUtils.SaveJob( job )
In the scripting API each property has a [get] or [get, set], meaning you can read only or read & write the property. In the case of “JobFramesList”, this property can only be read. I’m not to sure why you would want to change the frame list during a pre or post job script, as it sounds like the job at this point should be dealt with in other ways, such as deleted, completed, suspended. There’s a new handy API function in v6.2 onwards called: “RepositoryUtils.ResubmitJob” which using the job object you already have, would allow you to change the frameList for the new job and then you could get rid of the old job. As this function returns the new job object once submitted, it’s easy to change a few properties, saveJob and perhaps, hit resumeJob. Could you provide a little more context to what your trying to achieve, as I might have misunderstood you 
I agree. There are a few places where the docstrings could be improved in the API ref guide. Noted.
Regards,
Mike
Thanks Mike, If at Job Submission time the frame range (FrameList) was not known I am using Plugin’s PreRenderTasks() method to launch an application, read the content of the file yet to be rendered. From reading a file I get an information was missing from the submission: what folder the file is set to render images, the number of Render Items, frame range to be rendered and etc). Knowing all bits of info on file submitted the Job’s attributes are set, re-set or updated.
I was successful with setting/overriding/updating Job’s OutputDirectory# and OutputFilename# attributes. But I can’t find a way on how to set or to update Job’s FrameList attribute (so a new FrameList Attribute value is shown in Deadline Monitor Job’s Property Page).
If I use job.set_FramesList(newFrameList) the Job FrameList attribute gets updated “programmatically” (the new or updated Job’s FrameList attribute value is picked up by renderer or Event Listener later). But GUI is not picking up or showing the update.
RepositoryUtils.UpdateJobOutputFileNames(job, newOutputFilepaths) is what I need for job’s FrameList attribute: update the value so it is available to all further processes to happen later (rendering, event, post, etc) AND update GUI elements (such as JobProperty Page, right-click menu, etc).
I think the problem here is that some of these functions are performed on a job instance and some are done by modifying the database directly. Whichever (SaveJob(job) versus RepositoryUtils.UpdateJobOutputFileNames()) happens last is what sticks.
Have you tried saving that job object after you’ve modified it? This sort of race condition to the database has bitten people before.
Thanks Mike!
RepositoryUtils.SaveJob(job)
works like a charm!
Of course, Job’s attributes need to be set/reset/updated before saving the Job). Great to know this little trick!
If I understand it correctly some of Job’s attributes are both getters and setters all at the same time?
For example, to query a job name I can use:
job.JobName
But if to follow this logic I could be using the same JobName attribute as setter such as:
job.JobName('New Job Name')
But if I run it I am getting a RenderPluginException
-- Error in PreRenderTasks: TypeError : 'unicode' object is not callable (Python.Runtime.PythonException)
Please clarify how set get mechanism is implemented and how to use it
Here is the answer:
As getter:
myJobName=job.JobName
as setter:
job.JobName=‘New Name’
This is sort of what I am looking for but would like some help/info on the following:
I see that you can copy the output path to the clipboard, but how would I get this via a script i.e what is the command e.g( job.getOutputPath )
I need to grab information about a current job in the queue which has an incorrect render output so I can make new job files and resubmit with the updated job files that have the correct location. I am looking to change the render output location in the existing job and resubmit as a deadlinecommand submission with the new job files I will create from the existing one.
I believe it will be a repositoryUtils action, but am still new to command line submissions, so any help will be appreciated.
Thanks
The Scripting API docs have a “job” class and once you instantiate a job object, you can query/set some/all of the job properties. Don’t forget to save the job object once your done using:
RepositoryUtils.SaveJob(job)
Here’s some example code that could be used in a right-click monitor job script:
[code]selectedJobs = MonitorUtils.GetSelectedJobs()
jobCount = len( selectedJobs )
if jobCount > 0:
for job in selectedJobs:
print job.JobName
print job.JobPlugin
for i in range( 0, len(job.JobOutputFileNames) ):
print job.JobOutputFileNames[i]
for i in range( 0, len(job.JobOutputDirectories) ):
print job.JobOutputDirectories[i][/code]
In Deadline v6.2 we shipped with a new job script we wrote called “BatchResubmit.py”, it’s the perfect example of how to grab a job, query all/any of it’s job properties and resubmit the job. It also showcases how you can manipulate tasks as well as frames. However, ignoring that stuff, it shows how you could expose a UI, take it’s settings from user input and for each job selected, maybe change the job output filename and/or output directories, write out the 2 x job files and resubmit the job.
The writing of this example script actually led to the introduction of this new script API command in Deadline v6.2, which obviously makes things much simpler:
RepositoryUtils.ResubmitJob( job, frameList, chunkSize, submitSuspended )
Thanks Mike, I had worked out a way to do it, but the information you have provided is very welcome. I forgot to say I was writing it for Deadline 5, so is the code for resubmitting still the same? We are in the process of updating for 6.
Many thanks 
The code is the same, except the last function:
RepositoryUtils.ResubmitJob
which was introduced in v6.2.
So how do you call the resubmit with Deadline 5? Or is the code snippet above the string to use? Also, I am looking for the resubmit python file for deadline 5, is it available? I have the script set to do what I need, I just need the code for resubmitting in Deadline 5. Sorry if I am a little vague, jumping between projects at the moment.
Many thanks 
Re-submit in Deadline v5 will be a more manual python affair using DeadlineCommand. You will use the approach outlined in the code snippet previously posted, write out the 2 x job info files and then execute a submit function to “re-submit” the job. Have a look at your repository/plugins/JobTransfer/JobTransfer.py on how this is achieved in v5.
So its not really a resubmit but a completely new submission based on a rewrite of the job files? I was unable to find any information in the docs for version 5, if there is any documented information about resubmitting that I have missed, please direct me to it as there is a need to alter the files when files are submitted from outside the studio. Also, why does the plugin file get converted to xml once submitted? Makes rewriting the code a chore, do you have any code to convert it back to ini format from xml?
Correct. “Re-submission” is “submission”. Technically the new API function in v6.2 (RepositoryUtils.ResubmitJob(job)) is a submission as well.
If you need to alter some of the settings when a job is submitted from outside the studio, you can use an event plugin to alter the job after it’s been submitted or alternatively before it’s started for the first time.
XML is the internal use only format for how the architecture in v5 works. This was replaced by the whole Mongo DB backend in v6 onwards. It’s not best practice to directly access the XML as we are unable to support un-protected calls, although it’s possible. Alternatively, we provide a supported API.
Ok, here is what I am doing in Deadline 5.2 as I am not currently using version 6:
The job is submitted from outside the UK and the max_job_info.job file and the associated file which is a conversion to xml (lets call it 123456789ab.job for example) have incorrect paths in them. I have written a script to edit the paths in each file in the original submission folder so that the path is correct in each, but when I use the resubmit function after the edits, it creates a new job and ID but while the max_job_info.job has the correct path, the other new id xml based job file is created with the original submission path, meaning that monitor functions do not go to the correct folders etc when the user wants to look at assets or paths.
The max_job_info.job will render to the right location, which is ultimately what we need, but can you shed some light on why the other file reverts? is it pulling information from somewhere other than the xml job file? Is the original data stored on a database that we have no control over or is there another file I need to change prior to resubmitting?
Ultimately, I will have to do as suggested and recreate the two job files, both in INI format and then submit as a new job, I just need to get a solution to the artists so that the farm is not held up.
Once we move over to version 6 and having the new features and exposure will be a great help.
Thanks
Burrows already have a propriety event plugin that does exactly this…