Submitting Guerilla Jobs via Python

Follow

This is an example of how to submit a job via a simple Python script (which could then be instantiated via the command line) to submit a Guerilla Render job to Conductor. Guerilla is a lighting tool and renderer.

This sample script uses the attached data, which consists of a project with a base model (no textures), and some basic lighting. Rib files are also a part of the archive.  

Typically, the workflow would be to generate the rib files locally on the artist's machine, and then upload those files for rendering to Conductor.

import glob
from conductor.lib import conductor_submit, package_utils, api_client

# When you submit a job, you’ll need to specify which software packages that 
# the job requires. In order to indicate which software packages a job should 
# use, specific software package IDs must be specified when submitting that job.
# For more information, please see: 
# https://support.conductortech.com/hc/en-us/articles/115007771548-Creating-A-Command-Line-Submission-Software-Packages
packages = api_client.request_software_packages()
guerilla_packages = [package for package in packages if package["product"] == "guerilla"]

# This just grabs the first Guerilla package available, for the same of simplicity in 
# this example. Note that all package IDs (and corresponding version numbers) can be 
# found in the resources.yml file in the client tools installation, under resources. 
# You can also call conductor.lib.common.load_resources_file() as a convenience function.
gp = guerilla_packages[0]
guerilla_build_ID = gp['build_id']
guerilla_package_ID = gp['package_id']

# job dictionary, this will have the list of tasks that need to run
# as well as the environment and the packages used
args = {}

# This needs to be a project that you have on your account
args["project"] = "TestProj"
args["cores"] = 2
args["machine_type"] = "standard"

# specify all of the file dependences that the Job requires (accepts files and directories)
args["upload_paths"] = ["/Users/ravi/tmp/supes"]

# Indicate that uploading should occur immediately
# i.e. use the daemon or not
# Using the daemon is recommended
# True - don't use daemon
# False - use daemon
args["local_upload"] =  False

# Give the job a title 
args["job_title"] = "Test Job: Guerilla Standalone Test"

# Indicate which software packages should be made available for the job
args["software_package_ids"] = [guerilla_package_ID]

# Create a custom environment that will provide access to your own custom/studio plugins
custom_environment = {"C_DRIVE": "/Users/ravi", "JOBS": "/Users/ravi/tmp/supes/jobs", "RIBS": "/Users/ravi/tmp/supes/ribs", "IMAGES": "/testrender"}

# Request the packages that you want to use from conductor. 
packages = [package for package in api_client.request_software_packages() if package["package_id"] in args["software_package_ids"]]

# merge the packages' environments with the custom environment
args["environment"] = package_utils.merge_package_environments(packages, base_env=custom_environment)

# Define the task data for the job (the command to execute, etc)
task_list = []
file_list = []

for file in glob.glob("/Users/ravi/tmp/supes/ribs/*RenderPass_[0-9][0-9][0-9][0-9][0-9].rib.gz"):
    file_list.append(file)

file_list.sort()

for file in file_list:
    curr_task = {}
    curr_render_command = 'render --out /testrender {}'.format(file)
    curr_task["command"] = curr_render_command
    curr_task["frames"] = "8"
    task_list.append(curr_task)
    
args["tasks_data"] = task_list

# Define the directory where the rendered images will be found when the tasks complete
args["output_path"] = "/testrender"

# Instantiate a Submit object with the job args
submission = conductor_submit.Submit(args)

# Run the submission
response, response_code = submission.main()

We can use the downloader to track and download the files.