def get_dependents(self): """Return a list of dependencies that depend on this layer.""" result = [] for layer in self.__outline.get_layers(): for depend in layer.get_depends(): if depend.get_depend_on_layer() == self: result.append(depend) return result
def testSubmitMayaAndShellJob(self, launchMock): cuesubmit.Submission.submitJob({ 'name': 'arbitrary-maya-shell-job', 'shot': 'arbitrary-shot-name', 'show': 'arbitrary-show-name', 'username': '******', 'layers': [ cuesubmit.Layer.LayerData.buildFactory(**MAYA_LAYER_DATA), cuesubmit.Layer.LayerData.buildFactory(**SHELL_LAYER_DATA) ], }) ol = launchMock.call_args[0][0] self.assertEqual(2, len(ol.get_layers())) mayaLayer = ol.get_layer(MAYA_LAYER_DATA['name']) self.assertEqual(MAYA_LAYER_DATA['name'], mayaLayer.get_name()) self.assertEqual([ 'Render', '-r', 'file', '-s', '#IFRAME#', '-e', '#IFRAME#', '-cam', MAYA_LAYER_DATA['cmd']['camera'], MAYA_LAYER_DATA['cmd']['mayaFile'] ], mayaLayer.get_arg('command')) self.assertEqual(MAYA_LAYER_DATA['layerRange'], mayaLayer.get_frame_range()) self.assertEqual('maya', mayaLayer.get_service()) shellLayer = ol.get_layer(SHELL_LAYER_DATA['name']) self.assertEqual(SHELL_LAYER_DATA['name'], shellLayer.get_name()) self.assertEqual(['echo', '#IFRAME#'], shellLayer.get_arg('command')) self.assertEqual(SHELL_LAYER_DATA['layerRange'], shellLayer.get_frame_range()) self.assertEqual('shell', shellLayer.get_service()) self.assertEqual(1, len(shellLayer.get_depends())) depend = shellLayer.get_depends()[0] self.assertEqual(mayaLayer, depend.get_depend_on_layer()) self.assertEqual(shellLayer, depend.get_dependant_layer()) self.assertEqual(outline.depend.DependType.FrameByFrame, depend.get_type())
def depend_on(self, on_layer, depend_type=outline.depend.DependType.FrameByFrame, propigate=False, any_frame=False): """ Setup a frame by frame on layer depend on the given layer. :type on_layer: L{Layer} :param on_layer: The L{Layer} to depend on. :type propigate: boolean :param propigate: Whether or not to propigate the depend to other layers. Default to False. :type any_frame: boolean :param any_frame: Wheaether or not to setup a depend any. Default to False. """ # Check for duplicates. for depend in self.__depends: if depend.get_depend_on_layer() == on_layer: logger.info("Skipping duplicated depend %s on %s", self, on_layer) return if str(self) == str(on_layer): logger.info("Skipping setting up dependency on self %s", self) return try: on_layer = self.__resolve_layer_name(on_layer) except outline.exception.LayerException: logger.warning("%s layer does not exist, depend failed", on_layer) return logger.info("adding depend %s on %s", self, on_layer) # # Handle the depend any bullshit # if any_frame or depend_type == outline.depend.DependType.LayerOnAny: if isinstance(self, LayerPreProcess): depend_type = outline.depend.DependType.LayerOnLayer else: depend_type = outline.depend.DependType.FrameByFrame any_frame = False for pre in self.get_preprocess_layers(): pre.depend_on(on_layer, outline.depend.DependType.LayerOnLayer, any_frame=True) depend = outline.depend.Depend(self, on_layer, depend_type, propigate, any_frame) self.__depends.append(depend) # Setup pre-process dependencies for my_preprocess in self.get_preprocess_layers(): for on_preprocess in on_layer.get_preprocess_layers(): # Depend on the layer's pre-process my_preprocess.depend_on(on_preprocess, outline.depend.DependType.LayerOnLayer) # # Handle depend propagation. # # Propagation occurs when a layer A depends on layer B, and # layer C depends on layer D, but Layer A also depends on Layer # C, which means layer D must now also depend on layer B. # # Currently this creates a depend-all (LayerOnLayer) between # the propigated depends. # for depend in on_layer.get_depends(): if depend.is_propigated(): for my_depend in self.get_depends(): dependant = my_depend.get_depend_on_layer() logger.info("propagating dependency %s -> %s", dependant, depend.get_depend_on_layer()) dependant.depend_all(depend.get_depend_on_layer(), propigate=False)