def create_tractor_job(): """Create a single Tractor Job. Args: - none """ logger.info("Starting job BUILD") # ################ 0 JOB ################ renderjob = author.Job( title="RFM: {} {} {}-{}".format(self.job.username, self.scenename, self.job.jobstartframe, self.job.jobendframe), priority=10, envkey=[ self.envkey_rfm, self.envkey_maya, "ProjectX", "TYPE={}".format(self.job.envtype), "SHOW={}".format(self.job.envshow), "PROJECT={}".format(self.job.envproject), "SCENE={}".format(self.job.envscene), "SCENENAME={}".format(self.scenebasename) ], metadata=_jsonJobMetaData, comment="User is {} {} {}".format(self.job.useremail, self.job.username, self.job.usernumber), projects=[str(self.job.department)], tier=str(self.job.farmtier), tags=[ "theWholeFarm", ], service="")
def test_mayahandler(): """This test shows how a two task job can be built with many more statements. """ job = author.Job() job.title = "Simple maya job and handler" job.priority = 10 job.comment = "This is a test job" job.projects = ["admin"] job.tier = "batch" job.tags = ["theWholeFarm"] job.envkey = ["maya2017"] mayaTask = author.Task() mayaTask.title = "Maya Job" #mayaTask.service = "Maya" mayaCommand = author.Command() mayaCommand.argv = "maya -batch -version" mayaCommand.service = "Maya" # mayaCommand.type = "RC" mayaTask.addCommand(mayaCommand) job.addChild(mayaTask) print job.asTcl()
def test_long(): """This test shows how a two task job can be built with many more statements. """ job = author.Job() job.title = "two layer job" job.priority = 10 job.after = datetime.datetime(2012, 12, 14, 16, 24, 5) fgTask = author.Task() fgTask.title = "render fg" fgCommand = author.Command() fgCommand.argv = "prman foreground.rib" fgTask.addCommand(fgCommand) bgTask = author.Task() bgTask.title = "render bg" bgCommand = author.Command() bgCommand.argv = "prman background.rib" bgTask.addCommand(bgCommand) compTask = author.Task() compTask.title = "render comp" compCommand = author.Command() compCommand.argv = "comp fg.tif bg.tif final.tif" compCommand.argv = ["comp"] compTask.addCommand(compCommand) compTask.addChild(fgTask) compTask.addChild(bgTask) job.addChild(compTask) print job.asTcl()
def _doDispatch(self, rootBatch): # Construct an object to track everything we need # to generate the job. I have a suspicion that at # some point we'll want a Dispatcher::Job base class # which _doDispatch() must return, in which case this # might just be member data for a subclass of one of those. dispatchData = {} dispatchData["scriptNode"] = rootBatch.preTasks()[0].node().scriptNode( ) dispatchData["scriptFile"] = os.path.join( self.jobDirectory(), os.path.basename(dispatchData["scriptNode"]["fileName"].getValue()) or "untitled.gfr") dispatchData["batchesToTasks"] = {} dispatchData["scriptNode"].serialiseToFile(dispatchData["scriptFile"]) # Create a Tractor job and set its basic properties. context = Gaffer.Context.current() job = author.Job( ## \todo Remove these manual substitutions once #887 is resolved. title=context.substitute(self["jobName"].getValue()) or "untitled", service=context.substitute(self["service"].getValue()), envkey=context.substitute(self["envKey"].getValue()).split(), ) # Populate the job with tasks from the batch tree # that was prepared by our base class. batchesToTasks = {} for upstreamBatch in rootBatch.preTasks(): self.__buildJobWalk(job, upstreamBatch, dispatchData) # Signal anyone who might want to make just-in-time # modifications to the job. self.preSpoolSignal()(self, job) # Save a copy of our job script to the job directory. # This isn't strictly necessary because we'll spool via # the python API, but it's useful for debugging and also # means that the job directory provides a complete record # of the job. with open(self.jobDirectory() + "/job.alf", "w") as alf: alf.write("# Generated by Gaffer " + Gaffer.About.versionString() + "\n\n") alf.write(job.asTcl()) # Finally, we can spool the job. job.spool(block=True)
def to_tractor(self, start_frame, end_frame, file_type): version = cmds.about(version=1) if version == "2022": sys.path.append( "/westworld/inhouse/tool/rez-packages/tractor/2.2.0/platform-linux/arch-x86_64/lib/python3.6/site-packages" ) else: sys.path.append( "/westworld/inhouse/tool/rez-packages/tractor/2.2.0/platform-linux/arch-x86_64/lib/python2.7/site-packages" ) import tractor.api.author as author job = author.Job() job.service = "convert" job.priority = 50 file_title = cmds.file(query=True, sn=True).split(".")[0].split("/")[-1] project_name = self.item.context.project['name'] user_name = self.item.context.user['name'] user_id = os.environ['USER'] temp = "] [" title = [] title.append(user_name) title.append(project_name) title.append(file_title) title.append(self.item.properties['name']) title.append("%d - %d" % (start_frame, end_frame)) title.append(file_type) title = temp.join(title) title = "[" + title + "]" job.title = str(title) master_command = self._get_default_command() command = master_command[:] + ['--', 'mayapy'] command.append(self._temp_file) command = author.Command(argv=command) task = author.Task(title=str(self.item.properties['name'])) task.addCommand(command) rm_command = ['/bin/rm', '-f'] rm_command.append(self._temp_file) rm_command = author.Command(argv=rm_command) rm_task = author.Task(title="rm tmp") rm_task.addCommand(rm_command) rm_task.addChild(task) job.addChild(rm_task) job.spool(hostname="10.0.20.83", owner=user_id)
def test_short(): """This test shows how a two task job can be created with as few statements as possible. """ job = author.Job(title="two layer job", priority=10, after=datetime.datetime(2012, 12, 14, 16, 24, 5)) compTask = job.newTask(title="comp", argv="comp fg.tif bg.tif final.tif") fgTask = compTask.newTask(title="render fg", argv="prman foreground.rib") bgTask = compTask.newTask(title="render bg", argv="prman foreground.rib") print job
def test_bad_attr(): """This test verifies that an exception is raised when trying to set an invalid attribute. """ job = author.Job() try: job.title = "okay to set title" job.foo = "not okay to set foo" except AttributeError, err: print "Good, we expected to get an exception for setting an invalid " \ "attribute: %s" % str(err)
def test_instance(): """This test checks that an instance will be created when a task is added as a child to more than one task. """ job = author.Job(title="two layer job") compTask = job.newTask(title="comp", argv="comp fg.tif bg.tif final.tif") fgTask = compTask.newTask(title="render fg", argv="prman foreground.rib") bgTask = compTask.newTask(title="render bg", argv="prman foreground.rib") ribgen = author.Task(title="ribgen", argv="ribgen 1-10") fgTask.addChild(ribgen) bgTask.addChild(ribgen) print job
def test_spool(): """This tests the spool method on a job.""" job = author.Job( title="two layer job", priority=10, after=datetime.datetime(2012, 12, 14, 16, 24, 5)) compTask = job.newTask( title="comp", argv="comp fg.tif bg.tif out.tif", service="pixarRender") fgTask = compTask.newTask( title="render fg", argv="prman foreground.rib", service="pixarRender") bgTask = compTask.newTask( title="render bg", argv="prman foreground.rib", service="pixarRender") print job.spool(spoolfile="/spool/file", spoolhost="spoolhost", hostname="torchwood", port=8081) print job.spool(spoolfile="/spool/file", spoolhost="spoolhost", hostname="torchwood", port=8080)
def test_postscript_error(): """This builds a job with varios postscript commands. Submit the job to ensure that only the "none", "always", and "error" postscript commands run. """ job = author.Job(title="Test Postscript Error") job.newTask(title="fail", argv="/bin/false", service="pixarRender") job.newPostscript(argv="touch /tmp/postscript.none.%j", service="pixarRender") job.newPostscript(argv="touch /tmp/postscript.done.%j", when="done", service="pixarRender") job.newPostscript(argv="touch /tmp/postscript.error.%j", when="error", service="pixarRender") job.newPostscript(argv="touch /tmp/postscript.always.%j", when="always", service="pixarRender") try: job.newPostscript(argv="touch /tmp/postscript.always.%j", when="nope") except TypeError, err: print "Good, we caught an invalid value for when: %s" % str(err)
def test_spool(): """This testing the spool method on a job.""" job = author.Job(title="two layer job", priority=10, after=datetime.datetime(2012, 12, 14, 16, 24, 5)) compTask = job.newTask(title="comp", argv="comp fg.tif bg.tif out.tif", service="pixarRender") fgTask = compTask.newTask(title="render fg", argv="prman foreground.rib", service="pixarRender") bgTask = compTask.newTask(title="render bg", argv="prman foreground.rib", service="pixarRender") # setEngineClientParam(port=8080) job.spool()
def job_upload_project(): """This job could be to upload a maya project to dabrender """ job = author.Job() job.title = "Upload Project Job" job.priority = 10 job.after = then dabrender = "source" project = "project" job.newDirMap(src="/Volumes/dabrender", dst="dabrender/", zone="LINUX") job.newDirMap(src="/dabrender", dst="/Volumes/dabrender", zone="OSX") job.newAssignment(dabrender, "/Volumes/dabrender") job.newAssignment(project, "/Volumes/dabrender") job.comment = "Uploader to render place" job.metadata = "user=mattg project=dotty" job.editpolicy = "undergraduate" fgTask = author.Task() fgTask.title = "render fg" fgCommand = author.Command() fgCommand.argv = "prman foreground.rib" fgTask.addCommand(fgCommand) bgTask = author.Task() bgTask.title = "render bg" bgCommand = author.Command() bgCommand.argv = "prman background.rib" bgTask.addCommand(bgCommand) compTask = author.Task() compTask.title = "render comp" compCommand = author.Command() compCommand.argv = "comp fg.tif bg.tif final.tif" compCommand.argv = ["comp"] compTask.addCommand(compCommand) compTask.addChild(fgTask) compTask.addChild(bgTask) job.addChild(compTask) print job.asTcl()
def test_spool(): """This test function provides an example of how to establish a connection with the engine and spool a job.""" import tractor.api.author as author job = author.Job(title="a one-task job") task = job.newTask(title="the render task") task.newCommand(argv=["/bin/sleep", "10"], service="pixarRender") print job.asTcl() hostname = os.environ["TRACTOR_HOST"] port = int(os.environ["TRACTOR_PORT"]) user = "******" client = EngineClient(hostname, port, user, password="", debug=True) client.open() result = client.spool(job.asTcl()) #result = client.spool(job.asJSON(), format="JSON") client.close() print result
def build(self): ''' build the job :return: ''' self.job = author.Job(title="Simple Command Job", priority=100, envkey=["maya2015"], service="PixarRender") ############################# task = author.Task(title="Single Command", service="PixarRender") command1 = author.Command(argv=[os.path.join(self.command)]) task.addCommand(command1) self.job.addChild(task) print "\n{}".format(self.job.asTcl())
def batch_render(self): scene = self.bl_scene rm = scene.renderman frame_begin = self.bl_scene.frame_start frame_end = self.bl_scene.frame_end by = self.bl_scene.frame_step if not rm.external_animation: frame_begin = self.bl_scene.frame_current frame_end = frame_begin job = author.Job() scene_name = self.bl_scene.name bl_view_layer = self.depsgraph.view_layer.name job_title = 'untitled' if not bpy.data.filepath else \ os.path.splitext(os.path.split(bpy.data.filepath)[1])[0] job_title += ' %s ' % bl_view_layer job_title += " frames %d-%d" % (frame_begin, frame_end) if frame_end \ else " frame %d" % frame_begin job.title = str(job_title) job.serialsubtasks = True job.service = 'PixarRender' self.add_job_level_attrs(job) threads = self.bl_scene.renderman.batch_threads anim = (frame_begin != frame_end) tasktitle = "Render %s" % (str(scene_name)) parent_task = author.Task() parent_task.title = tasktitle self.generate_rib_render_tasks(anim, parent_task, tasktitle, frame_begin, frame_end, by, threads) job.addChild(parent_task) # Don't denoise if we're baking if rm.hider_type == 'RAYTRACE': parent_task = self.generate_denoise_tasks(frame_begin, frame_end, by) job.addChild(parent_task) bl_filename = bpy.data.filepath if bl_filename == '': jobfile = string_utils.expand_string('<OUT>/<scene>.<layer>.alf', asFilePath=True) else: jobfile = os.path.splitext( bl_filename)[0] + '.%s.alf' % bl_view_layer.replace(' ', '_') jobFileCleanup = author.Command(local=False) jobFileCleanup.argv = [ "TractorBuiltIn", "File", "delete", "%%D(%s)" % jobfile ] job.addCleanup(jobFileCleanup) try: f = open(jobfile, 'w') as_tcl = job.asTcl() f.write(as_tcl) f.close() except IOError as ioe: rfb_log().error('IO Exception when writing job file %s: %s' % (jobfile, str(ioe))) return except Exception as e: rfb_log().error('Could not write job file %s: %s' % (jobfile, str(e))) return self.spool(job, jobfile)
def publish(self, settings, item): """ Executes the publish logic for the given item and settings. :param settings: Dictionary of Settings. The keys are strings, matching the keys returned in the settings property. The values are `Setting` instances. :param item: Item to process """ publisher = self.parent # get the path to create and publish publish_path = item.properties["path"] # ensure the publish folder exists: publish_folder = os.path.dirname(publish_path) self.parent.ensure_folder_exists(publish_folder) # set the alembic args that make the most sense when working with Mari. # These flags will ensure the export of an USD file that contains # all visible geometry from the current scene together with UV's and # face sets for use in Mari. usd_args = [ '-shd "none"', '-dms "none"', '-uvs 1', '-cls 0', '-vis 1', '-mt 0', '-sl', '-sn 1', '-fs %f' % item.properties['sub_frame'], '-ft %f' % item.properties['sub_frame'] ] # find the animated frame range to use: start_frame, end_frame = _find_scene_animation_range() if start_frame and end_frame: usd_args.append("-fr %d %d" % (start_frame, end_frame)) # Set the output path: # Note: The AbcExport command expects forward slashes! sub_components = [ x for x in cmds.ls(allPaths=1, ca=0, transforms=1, l=1) if cmds.listRelatives(x, p=1) and cmds.attributeQuery("Meshtype", node=x, exists=1) and cmds.getAttr(x + ".Meshtype", asString=True) == "component" ] if not sub_components: usd_args.append('-f "%s"' % publish_path.replace("\\", "/")) usd_export_cmd = ("usdExport %s" % " ".join(usd_args)) else: asset_usd_path = self._get_sub_component_path( item.properties['name'], item) usd_args.append('-f "%s"' % asset_usd_path.replace("\\", "/")) usd_export_cmd = ("usdExport %s" % " ".join(usd_args)) script = '' script += 'import maya.standalone\n' script += 'maya.standalone.initialize()\n' script += 'import maya.cmds as cmds\n' script += 'import maya.mel as mel\n' script += '\n' script += '\n' script += 'cmds.file("{}",open=1,force=1,iv=1)\n'.format( cmds.file(query=True, sn=True)) script += 'cmds.select("{}")\n'.format(item.properties['name']) script += 'cmds.loadPlugin("pxrUsd.so")\n' script += 'mel.eval(\'{}\')\n'.format(usd_export_cmd) tmp_path = os.path.splitext(item.properties["path"])[0] + ".py" with open(tmp_path, 'w') as f: f.write(script) import sys sys.path.append( "/westworld/inhouse/tool/rez-packages/tractor/2.2.0/platform-linux/arch-x86_64/lib/python2.7/site-packages" ) import tractor.api.author as author job = author.Job() job.service = "convert" job.priority = 50 file_title = cmds.file(query=True, sn=True).split(".")[0].split("/")[-1] project_name = item.context.project['name'] user_name = item.context.user['name'] user_id = os.environ['USER'] temp = "] [" title = [] title.append(user_name) title.append(project_name) title.append(file_title) title.append(item.properties['name']) title.append("%d - %d" % (start_frame, end_frame)) title = temp.join(title) title = "[" + title + "]" job.title = str(title) command = ['rez-env', 'maya-2019vfarm', 'usd-19.03', '--', 'mayapy'] command.append(tmp_path) command = author.Command(argv=command) task = author.Task(title=str(item.properties['name'])) task.addCommand(command) rm_command = ['/bin/rm', '-f'] rm_command.append(tmp_path) rm_command = author.Command(argv=rm_command) rm_task = author.Task(title="rm tmp") rm_task.addCommand(rm_command) rm_task.addChild(task) job.addChild(rm_task) job.spool(hostname="10.0.20.82", owner=user_id) return
def _render_to_farm(self): import tractor.api.author as author start_frame = int(self.ui.start_frame.text()) end_frame = int(self.ui.end_frame.text()) file_name = FarmAPI.GetKatanaFileName() temp_file = self._get_temp_file(str(file_name)) if not os.path.exists(os.path.dirname(temp_file)): os.makedirs(os.path.dirname(temp_file)) status = shutil.copyfile(file_name, temp_file) for node in self.selected_nodes: job = author.Job() #job.title = '[Katana]' + file_name.split(".")[0].split("/") job.service = "Linux64" job.priority = 50 file_title = file_name.split(".")[0].split("/")[-1] project_name = self._app.context.project['name'] user_name = self._app.context.user['name'] user_id = os.environ['USER'] select_node = str(node.getName()) temp = "] [" title = [] title.append(user_name) title.append(project_name) title.append(file_title) title.append(select_node) title.append("%d - %d" % (start_frame, end_frame)) title = temp.join(title) title = "[" + title + "]" job.title = str(title) for frame in range(start_frame, end_frame + 1): task = author.Task(title=str(frame)) if os.environ['REZ_KATANA_VERSION'] == "3.1v2": command = [ 'rez-env', 'katana-3.1v2', 'renderman-22', 'usd-19.03', 'yeti', '--', 'katana' ] else: command = [ 'rez-env', 'katana-2.6v4', 'renderman-21.8', 'usd-19.03', 'yeti-2.2.9', '--', 'katana' ] command.append("--batch") command.append("--katana-file=%s" % temp_file) command.append("--render-node=%s" % node.getName()) command.append(str("--t=%d-%d" % (frame, frame))) command = author.Command(argv=command) task.addCommand(command) job.addChild(task) job.spool(hostname="10.0.20.82", owner=user_id) self.close() return
def createJob(self): self.job = author.Job(title="pulsar-test", priority=100, service=self.pool, projects=["TD"]) self.job.serialsubtasks = 1 self.job.newDirMap(src="I:/SynologyDrive/A_PIPE", dst="/marvin/A_PIPE", zone="NFS") self.job.newDirMap(src="C:/Houdini17/bin/hython.exe", dst="/opt/hfs17.5/bin/hython", zone="NFS") self.job.newDirMap(src="C:/Houdini17/bin/hrender.py", dst="/opt/hfs17.5/bin/hrender.py", zone="NFS") ########################### ##### DIR MAP WINDOWS ##### ########################### ##### DIR MAP MARVIN ##### self.job.newDirMap(src="I:/SynologyDrive/ARAL", dst="//marvin/PFE_RN_2020/ARAL", zone="UNC") self.job.newDirMap(src="I:/SynologyDrive/CLAIR_DE_LUNE", dst="//marvin/PFE_RN_2020/CLAIR_DE_LUNE", zone="UNC") self.job.newDirMap(src="I:/SynologyDrive/FORGOT_YOUR_PASSWORD", dst="//marvin/PFE_RN_2020/FORGOT_YOUR_PASSWORD", zone="UNC") self.job.newDirMap(src="I:/SynologyDrive/LOREE", dst="//marvin/PFE_RN_2020/LOREE", zone="UNC") self.job.newDirMap(src="I:/SynologyDrive/RESURGENCE", dst="//marvin/PFE_RN_2020/RESURGENCE", zone="UNC") self.job.newDirMap(src="I:/SynologyDrive/TIMES_DOWN", dst="//marvin/PFE_RN_2020/TIMES_DOWN", zone="UNC") ##### DIR MAP TARS ##### self.job.newDirMap(src="I:/SynologyDrive/ASCEND", dst="//tars/PFE_RN_2020/ASCEND", zone="UNC") self.job.newDirMap(src="I:/SynologyDrive/ISSEN_SAMA", dst="//tars/PFE_RN_2020/ISSEN_SAMA", zone="UNC") self.job.newDirMap(src="I:/SynologyDrive/LONE", dst="//tars/PFE_RN_2020/LONE", zone="UNC") self.job.newDirMap(src="I:/SynologyDrive/MOON_KEEPER", dst="//tars/PFE_RN_2020/MOON_KEEPER", zone="UNC") ##### DIR MAP ANA ##### self.job.newDirMap(src="I:/SynologyDrive/BREACH", dst="//ana/PFE_RN_2020/BREACH", zone="UNC") self.job.newDirMap(src="I:/SynologyDrive/HARU", dst="//ana/PFE_RN_2020/HARU", zone="UNC") self.job.newDirMap(src="I:/SynologyDrive/VERLAN", dst="//ana/PFE_RN_2020/VERLAN", zone="UNC") ######################### ##### DIR MAP LINUX ##### ######################### ##### DIR MAP MARVIN ##### self.job.newDirMap(src="I:/SynologyDrive/ARAL", dst="/marvin/ARAL", zone="NFS") self.job.newDirMap(src="I:/SynologyDrive/CLAIR_DE_LUNE", dst="/marvin/CLAIR_DE_LUNE", zone="NFS") self.job.newDirMap(src="I:/SynologyDrive/FORGOT_YOUR_PASSWORD", dst="/marvin/FORGOT_YOUR_PASSWORD", zone="NFS") self.job.newDirMap(src="I:/SynologyDrive/LOREE", dst="/marvin/LOREE", zone="NFS") self.job.newDirMap(src="I:/SynologyDrive/RESURGENCE", dst="/marvin/RESURGENCE", zone="NFS") self.job.newDirMap(src="I:/SynologyDrive/TIMES_DOWN", dst="/marvin/TIMES_DOWN", zone="NFS") ##### DIR MAP TARS ##### self.job.newDirMap(src="I:/SynologyDrive/ASCEND", dst="/tars/ASCEND", zone="NFS") self.job.newDirMap(src="I:/SynologyDrive/ISSEN_SAMA", dst="/tars/ISSEN_SAMA", zone="NFS") self.job.newDirMap(src="I:/SynologyDrive/LONE", dst="/tars/LONE", zone="NFS") self.job.newDirMap(src="I:/SynologyDrive/MOON_KEEPER", dst="/tars/MOON_KEEPER", zone="NFS") ##### DIR MAP ANA ##### self.job.newDirMap(src="I:/SynologyDrive/BREACH", dst="/ana/BREACH", zone="NFS") self.job.newDirMap(src="I:/SynologyDrive/HARU", dst="/ana/HARU", zone="NFS") self.job.newDirMap(src="I:/SynologyDrive/VERLAN", dst="/ana/VERLAN", zone="NFS") # node = self.taskNodes.pop(0) # self.addTask(job, node) self.executionOrder = self.executionPriority.keys() self.executionOrder.sort() self.addTaskLayers()
def export(self): self.close() # Get user, project, and time info so we can make a temp folder user = self.environment.get_current_username() projectName = self.project.get_name().lower() time_now = datetime.datetime.now() #Make a temp folder for the rib files based on the user and the current time ribDir = self.project.get_project_dir( ) + '/ribs/' + user + '_' + time_now.strftime('%m%d%y_%H%M%S') print 'ribDir', ribDir, ' renderNodes size: ', len(self.renderNodes) os.makedirs(ribDir) # Sanitize job title title = re.sub(r'[{}"\']', '', str(self.jobName.text())).strip(' \t\n\r') if len(title) == 0: title = self.empty_text numCores = int( re.sub(r'[{}"\']', '', str(self.numCores.text())).strip(' \t\n\r')) if numCores < 1: numCores = 1 # This job we send to tractor job = author.Job() job.title = title job.priority = self.priority.currentIndex() path = '/opt/pixar/RenderManProServer-21.5/bin/' job.envkey = [ 'setenv PATH=' + path + ' RMANTREE=/opt/pixar/RenderManProServer-21.5' ] job.service = 'PixarRender' job.comment = 'Spooled by ' + user # Loop through each frame of our nodes and create frame tasks and append it to the job script for index, node in enumerate(self.renderNodes): # Make sure this node was selected for export print node.name() if self.select.item(index).isSelected(): name = node.name() validFrameRange = node.parm('trange').eval() if validFrameRange == 0: start = int(hou.frame()) end = int(hou.frame()) step = 1 else: start = int(node.parm('f1').eval()) end = int(node.parm('f2').eval()) step = int(node.parm('f3').eval()) task = author.Task() task.title = '%s [%d-%d]' % (name, start, end) oldOutputMode = node.parm('rib_outputmode').eval() try: oldDiskFile = node.parm('soho_diskfile').expression() useExpression = True print 'We are getting rid of expressiion' except: oldDiskFile = node.parm('soho_diskfile').eval() useExpression = False print 'we didn\'t get rid of them' # Activate rib output node.parm('rib_outputmode').set(True) node.parm('soho_diskfile').deleteAllKeyframes() node.parm('soho_diskfile').set(ribDir + ('/%s_$F04.rib' % name)) print 'start rib making' script = os.path.join(self.project.get_project_dir(), 'byu-pipeline-tools', 'houdini-tools', 'parallelRibs', 'taskDistribution.sh') subprocess.call([ 'sh', script, str(start), str(end), str(node.path()), str(saveHipRenderCopy()), str(numCores) ]) print 'finish rib making' # Loop through every frame in framerange for frame in range(start, end + 1, step): subtask = author.Task() subtask.title = 'Frame %04d' % (frame) ribFile = '%s/%s_%04d.rib' % (ribDir, name, frame) print 'Here is the rib file ', ribFile # Commands for Debugging cmdPATH = author.Command() cmdPATH.argv = ['echo', '${PATH}'] cmdRMANTREE = author.Command() cmdRMANTREE.argv = ['echo', '${RMANTREE}'] printenv = author.Command() printenv.argv = ['printenv'] # subtask.addCommand(cmdPATH) # subtask.addCommand(cmdRMANTREE) # subtask.addCommand(printenv) # Real Commands command = author.Command() command.argv = ['prman', '-progress', ribFile] command.service = 'PixarRender' subtask.addCommand(command) task.addChild(subtask) job.addChild(task) # Restore rib output node.parm('soho_outputmode').set(oldOutputMode) if useExpression: node.parm('soho_diskfile').setExpression(oldDiskFile) else: node.parm('soho_diskfile').set(oldDiskFile) command = author.Command() command.argv = ['rm', '-rf', ribDir] job.addCleanup(command) # print 'This is the new job script \n', job.asTcl() # Attempt to spool job, with the option to keep trying choice = True while choice: try: job.spool() message_gui.info('Job sent to Tractor!') break except Exception as err: choice = message_gui.yes_or_no( 'We ran into this problem while spooling the job:\nWould you like to try again?', details=str(err), title='Continue?') #Cleanup ifd files, if they didn't want to retry if not choice: shutil.rmtree(ribDir)
def makeJob(entries): for entry in entries: field = entry[0] text = entry[1].get() print('%s: "%s"' % ( field, text)) mayaversion = entries[0][1].get() mayaprojectpath = entries[1][1].get() mayascene = entries[2][1].get() mayascenefullpath = "%s/%s" % (mayaprojectpath, mayascene) mayascenebase = os.path.splitext(mayascene)[0] startframe = (entries[3][1].get()) endframe = (entries[4][1].get()) byframe = (entries[5][1].get()) chunks = (entries[6][1].get()) options = (entries[7][1].get()) job = author.Job(title="MayaBatch Render Job", priority=100, envkey=["maya%s" % mayaversion], service="PixarRender") task = author.Task(title="Copy Project Locally", service="PixarRender") copyin = author.Command(argv=["scp", "remote:%s" % (mayaprojectpath), "/Volume/localrender/"]) task.addCommand(copyin) job.addChild(task) task = author.Task(title="Make output directory", service="PixarRender") makediectory = author.Command(argv=["mkdir", "%s/%s/%s" % (mayaprojectpath, "images", mayascenebase)]) task.addCommand(makediectory) job.addChild(task) if ( int(chunks) > (int(endframe) - int(startframe)) ): chunk = 1 framesperchunk = (int(endframe) - int(startframe) + 1) remainder = 0 else: (framesperchunk, remainder) = divmod((int(endframe) - int(startframe) + 1), int(chunks)) chunk = chunks # print int(startframe),int(endframe),int(chunk),int(chunks),int(remainder),int(framesperchunk) task = author.Task(title="Rendering", service="PixarRender") for i in range(0, int(chunk)): sf = (int(startframe) + (i * int(framesperchunk)) ) ef = (int(startframe) + (i * int(framesperchunk)) + int(framesperchunk) - 1 ) if (ef >= int(endframe) or (i == int(chunks) - 1)): ef = int(endframe) render = author.Command(argv=["mayabatch", options, "-proj", mayaprojectpath, "-start", "%s" % (sf), "-end", "%s" % (ef), "-by", byframe, mayascenefullpath]) task.addCommand(render) job.addChild(task) task = author.Task(title="Copy Project Back", service="PixarRender") copyout = author.Command(argv=["scp", "/local/file.tif", "remote:/path/file.tif"]) task.addCommand(copyout) job.addChild(task) print "\n{}".format(job.asTcl())
def test_all(): """This test covers setting all possible attributes of the Job, Task, Command, and Iterate objects. """ job = author.Job() job.title = "all attributes job" job.after = datetime.datetime(2012, 12, 14, 16, 24, 5) job.afterjids = [1234, 5678] job.paused = True job.tier = "express" job.projects = ["animation"] job.atleast = 2 job.atmost = 4 job.newAssignment("tempdir", "/tmp") job.newDirMap(src="X:/", dst="//fileserver/projects", zone="UNC") job.newDirMap(src="X:/", dst="/fileserver/projects", zone="NFS") job.etalevel = 5 job.tags = ["tag1", "tag2", "tag3"] job.priority = 10 job.service = "linux||mac" job.envkey = ["ej1", "ej2"] job.comment = "this is a great job" job.metadata = "show=rat shot=food" job.editpolicy = "canadians" job.addCleanup(author.Command(argv="/utils/cleanup this")) job.newCleanup(argv=["/utils/cleanup", "that"]) job.addPostscript(author.Command(argv=["/utils/post", "this"])) job.newPostscript(argv="/utils/post that") compTask = author.Task() compTask.title = "render comp" compTask.resumeblock = True compCommand = author.Command() compCommand.argv = "comp /tmp/*" compTask.addCommand(compCommand) job.addChild(compTask) for i in range(2): task = author.Task() task.title = "render layer %d" % i task.id = "id%d" % i task.chaser = "chase file%i" % i task.preview = "preview file%i" % i task.service = "services&&more" task.atleast = 7 task.atmost = 8 task.serialsubtasks = 0 task.addCleanup(author.Command(argv="/utils/cleanup file%i" % i)) command = author.Command() command.argv = "prman layer%d.rib" % i command.msg = "command message" command.service = "cmdservice&&more" command.tags = ["tagA", "tagB"] command.metrics = "metrics string" command.id = "cmdid%i" % i command.refersto = "refersto%i" % i command.expand = 0 command.atleast = 1 command.atmost = 5 command.samehost = 1 command.envkey = ["e1", "e2"] command.retryrc = [1, 3, 5, 7, 9] command.resumewhile = [ "/usr/utils/grep", "-q", "Checkpoint", "file.%d.exr" % i ] command.resumepin = bool(i) task.addCommand(command) compTask.addChild(task) iterate = author.Iterate() iterate.varname = "i" iterate.frm = 1 iterate.to = 10 iterate.addToTemplate( author.Task(title="process task", argv="process command")) iterate.addChild(author.Task(title="process task", argv="ls -l")) job.addChild(iterate) instance = author.Instance(title="id1") job.addChild(instance) print job.asTcl()
def build(self): self.__mayascenefullpath = "%s/%s" % (self.mayaprojectpath, self.mayascene) self.__mayascenebase = os.path.splitext(self.mayascene)[0] self.job = author.Job(title="MayaBatch Render Job", priority=100, envkey=["maya%s" % self.mayaversion], service="PixarRender") ############### task 1 ############## task = author.Task(title="Make output directory", service="PixarRender") makediectory = author.Command( argv=["mkdir", os.path.join(self.mayaprojectpath, "images")]) task.addCommand(makediectory) self.job.addChild(task) ############### task 2 ########### task = author.Task(title="Copy Project Locally", service="PixarRender") copyin = author.Command(argv=[ "scp", "%s:%s" % (self.centralworkarea, self.mayaprojectpath), "%s:%s" % (self.localhost, self.localworkarea) ]) task.addCommand(copyin) self.job.addChild(task) ############### task 3 ############## task = author.Task(title="Rendering", service="PixarRender") if ((self.endframe - self.startframe) < self.framechunks): self.framechunks = 1 chunkend = self.endframe else: chunkend = self.startframe + self.framechunks chunkstart = self.startframe while (self.endframe >= chunkstart): if chunkend >= self.endframe: chunkend = self.endframe render = author.Command(argv=[ "mayabatch", self.options, "-proj", self.mayaprojectpath, "-start", "%s" % (chunkstart), "-end", "%s" % (chunkend), "-by", self.byframe, "-rd", self.renderdirectory, "-im", self.imagetemplate, "-r", self.renderer, self.options, self.__mayascenefullpath ]) task.addCommand(render) chunkstart = chunkend + 1 chunkend = chunkend + self.framechunks self.job.addChild(task) ############### task 4 ############### task = author.Task(title="Copy Project Back", service="PixarRender") copyout = author.Command(argv=[ "scp", "%s:%s" % (self.localhost, self.localworkarea), "%s:%s" % (self.centralworkarea, self.mayaprojectpath) ]) task.addCommand(copyout) self.job.addChild(task) print "\n{}".format(self.job.asTcl())