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.limits: layer.set_limits(layerData.limits) if layerData.dependType and lastLayer: if layerData.dependType == 'Layer': layer.depend_all(lastLayer) else: layer.depend_on(lastLayer) return layer
def testShortHandDepend(self): ol = outline.Outline(name="depend_test_v2") ol.add_layer(Shell("bah1", command=["/bin/ls"])) ol.add_layer(Shell("bah2", command=["/bin/ls"], require=["bah1:all"])) job = outline.cuerun.launch(ol, range="1", pause=True) self.assertEquals(1, job.stats.dependFrames) cue.test(job)
def setUp(self): self.ol = outline.Outline() self.layer = outline.Layer("composite") self.ol.add_layer(self.layer) self.layer.add_child(Shell("blah1", command=["ls", "-l"])) self.layer.add_child(Shell("blah2", command=["ls", "-1"])) self.layer.add_child(Shell("blah3", command=["ls"])) self.event = self.ol.get_layer("composite")
def testShell(self): """Test a simple shell command.""" ol = outline.Outline(name="depend_test_v1") ol.add_layer(Shell("bah1", command=["/bin/ls"])) ol.add_layer(Shell("bah2", command=["/bin/ls"])) ol.get_layer("bah1").depend_all("bah2") job = outline.cuerun.launch(ol, range="1", pause=True) self.assertEquals(1, job.stats.dependFrames) cue.test(job)
def testShellToString(self, systemMock): """Test a string shell command.""" command = '/bin/ls -l ./' shell = Shell('bah', command=command) shell._execute(FrameSet('5-6')) systemMock.assert_has_calls([ mock.call(command, frame=5), mock.call(command, frame=6), ])
def testShell(self, systemMock): """Test a simple shell command.""" command = ['/bin/ls'] shell = Shell('bah', command=command) shell._execute(FrameSet('5-6')) systemMock.assert_has_calls([ mock.call(command, frame=5), mock.call(command, frame=6), ])
def testAnyFrameDepend(self): ol = outline.Outline(name="depend_test_any_frame") ol.add_layer(Shell("bah1", command=["/bin/ls"], range="1-2")) ol.add_layer( Shell("bah2", command=["/bin/ls"], require=["bah1:any"], range="1-1")) job = outline.cuerun.launch(ol, pause=True) self.assertEquals(1, job.stats.dependFrames) cue.test(job)
def setUp(self): from outline.modules.shell import Shell self.ol = outline.Outline() self.layer = outline.Layer("composite") self.ol.add_layer(self.layer) self.layer.add_child(Shell("blah1", command=["ls", "-l"])) self.layer.add_child(Shell("blah2", command=["ls", "-1"])) self.layer.add_child(Shell("blah3", command=["ls"])) self.event = self.ol.get_layer("composite") self.ol.setup()
def testShell(self): """Test a simple shell command.""" layer1Name = 'bah1' layer2Name = 'bah2' layer1 = Shell(layer1Name, command=['/bin/ls']) layer2 = Shell(layer2Name, command=['/bin/ls']) ol = outline.Outline(name='depend_test_v1') ol.add_layer(layer1) ol.add_layer(layer2) ol.get_layer(layer1Name).depend_all(layer2Name) depends = ol.get_layer(layer1Name).get_depends() self.assertEqual(1, len(depends)) self.assertEqual(DependType.LayerOnLayer, depends[0].get_type()) self.assertEqual(layer2, depends[0].get_depend_on_layer())
def testFailedShell(self): """Test that a failed frame throws an OutlineException in test mode.""" ol = outline.Outline(name="shell_test_v2", current=True) ol.add_layer(Shell("bah", command=["/bin/lssdsdasdsd"])) self.assertRaises(outline.OutlineException, cuerun.launch, ol, range="1", test=True)
def test_add_get_remove_layer(self): self.ol.add_layer(Shell("shell_command", cmd=["/bin/ls"])) self.assertEquals(2, len(self.ol.get_layers())) self.assertTrue(isinstance(self.ol.get_layer("shell_command"), Shell)) self.ol.remove_layer(self.ol.get_layer("shell_command")) self.assertEquals(1, len(self.ol.get_layers()))
def testShortHandDepend(self): with TemporarySessionDirectory(): layer1Name = 'bah1' layer2Name = 'bah2' layer1 = Shell(layer1Name, command=['/bin/ls']) layer2 = Shell(layer2Name, command=['/bin/ls'], require=['%s:all' % layer1Name]) ol = outline.Outline(name='depend_test_v2') ol.add_layer(layer1) ol.add_layer(layer2) ol.setup() depends = ol.get_layer(layer2Name).get_depends() self.assertEqual(1, len(depends)) self.assertEqual(DependType.LayerOnLayer, depends[0].get_type()) self.assertEqual(layer1, depends[0].get_depend_on_layer())
def testAnyFrameDepend(self): with TemporarySessionDirectory(): layer1Name = 'bah1' layer2Name = 'bah2' layer1 = Shell(layer1Name, command=['/bin/ls'], range='1-2') layer2 = Shell(layer2Name, command=['/bin/ls'], range='1-1', require=['%s:any' % layer1Name]) ol = outline.Outline(name='depend_test_any_frame') ol.add_layer(layer1) ol.add_layer(layer2) ol.setup() depends = ol.get_layer(layer2Name).get_depends() self.assertEqual(1, len(depends)) self.assertEqual(DependType.FrameByFrame, depends[0].get_type()) self.assertEqual(layer1, depends[0].get_depend_on_layer())
def test_add_get_remove_layer(self): with TemporarySessionDirectory(): ol = outline.load_outline(self.path) ol.add_layer(Shell("shell_command", cmd=["/bin/ls"])) self.assertEquals(2, len(ol.get_layers())) self.assertTrue(isinstance(ol.get_layer("shell_command"), Shell)) ol.remove_layer(ol.get_layer("shell_command")) self.assertEquals(1, len(ol.get_layers()))
def buildLayer(layerData, command): """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 """ layer = Shell(layerData.name, command=command.split(), chunk=layerData.chunk, threads=float(layerData.cores), range=str(layerData.layerRange)) if layerData.dependType and layerData.dependsOn: if layerData.dependType == 'Layer': layer.depend_all(layerData.dependsOn) else: layer.depend_all(layerData.dependsOn) return layer
Layer.LayerData.buildFactory(**NUKE_POST_TO_DISCORD), Layer.LayerData.buildFactory(**NUKE_POST_TO_FTRACK), Layer.LayerData.buildFactory(**NUKE_UPDATE_EDIT), ] } # 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())
def testShell(self): """Test a simple shell command.""" ol = outline.Outline(name="shell_test_v1") ol.add_layer(Shell("bah", command=["/bin/ls"])) cuerun.launch(ol, range="1", test=True)
def testShellToString(self): """Test a string shell command.""" ol = outline.Outline(name="string_test_v1") ol.add_layer(Shell("string_test", command="/bin/ls -l ./")) cuerun.launch(ol, range="1", test=True)
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