def buildLayer(layerData, command, lastLayer=None): """Create a PyOutline Layer for the given layerData. @type layerData: ui.Layer.LayerData @param layerData: layer data from the ui @type command: str @param command: command to run @type lastLayer: outline.layer.Layer @param lastLayer: layer that this new layer should be dependent on if dependType is set. """ if float(layerData.cores) >= 2: threadable = True else: threadable = False layer = Shell(layerData.name, command=command.split(), chunk=layerData.chunk, threads=float(layerData.cores), range=str(layerData.layerRange), threadable=threadable) if layerData.services: layer.set_service(layerData.services[0]) if layerData.dependType and lastLayer: if layerData.dependType == 'Layer': layer.depend_all(lastLayer) else: layer.depend_on(lastLayer) return layer
} # SUBMIT ############################################################ outline = Outline(jobData['name'], shot=jobData['shot'], show=jobData['show'], user=jobData['username']) layers = [] for layerData in jobData['layers']: layer = Shell(layerData.name, command=layerData.cmd.split(), chunk='1', threads=float(layerData.cores), range=str(layerData.layerRange), threadable=True) layer.set_service(layerData.services[0]) layers.append(layer) layer_count = 0 for layer in layers: if layer_count > 0: layer.depend_all(layers[layer_count - 1]) layer_count += 1 outline.add_layer(layer) jobs = cuerun.launch(outline, use_pycuerun=False, pause=True) for job in jobs: print(job.name()) job.setPriority(10) job.setMaxCores(1500) job.setMaxRetries(3)
def __acquireLayer(self, batch, dispatchData): layer = dispatchData["batchesToLayers"].get(batch) if layer is not None: return layer # Make a layer. nodeName = batch.node().relativeName(dispatchData["scriptNode"]) layerName = nodeName # Generate a `gaffer execute` command line suitable for # executing all the frames in the batch. args = [ "gaffer", "execute", "-script", dispatchData["scriptFile"], "-nodes", nodeName, ] frames = None if batch.frames(): frames = str( IECore.frameListFromList([int(x) for x in batch.frames()])) args.extend(["-frames", frames]) layerName += "_" + frames scriptContext = dispatchData["scriptNode"].context() contextArgs = [] for entry in [ k for k in batch.context().keys() if k != "frame" and not k.startswith("ui:") ]: if entry not in scriptContext.keys( ) or batch.context()[entry] != scriptContext[entry]: contextArgs.extend( ["-" + entry, IECore.repr(batch.context()[entry])]) if contextArgs: args.extend(["-context"] + contextArgs) # Apply any custom dispatch settings to the command. service = None layerArgs = { "command": args, "chunk": batch.node()["dispatcher"]["batchSize"].getValue(), "range": frames, "threads": None, "threadable": None, "memory": None, "tags": None, } opencuePlug = batch.node()["dispatcher"].getChild("opencue") if opencuePlug is not None: threadable = opencuePlug["threadable"].getValue() threads = opencuePlug["threads"].getValue() layerArgs["threadable"] = threadable if not threadable: layerArgs["threads"] = 1 elif threads > 0: layerArgs["threads"] = threads memory = opencuePlug["memory"].getValue() if memory > 0: layerArgs["memory"] = memory tags = opencuePlug["tags"].getValue() if tags: layerArgs["tags"] = tags service = opencuePlug["service"].getValue() # Create an OpenCue Shell to execute that command line, which is a subclassed layer layer = Shell( layerName, command=layerArgs['command'], chunk=layerArgs['chunk'], range=layerArgs['range'], threads=layerArgs['threads'], threadable=layerArgs['threadable'], memory=layerArgs['memory'], tags=layerArgs['tags'], ) layer.set_service(service) # Remember the task for next time, and return it. dispatchData["batchesToLayers"][batch] = layer return layer