def addBatch(self, new_batch, batch_frames): """ A batch corresponds to one or more Deadline Tasks Deadline Tasks must be sequential frames with only a start and end frame """ assert (new_batch is None or type(new_batch) == GafferDispatch.Dispatcher._TaskBatch) # some TaskNodes like TaskList and TaskWedge submit with no frames because they are just hierarchy placeholders # they still need to be in for proper dependency handling if len(batch_frames) > 0: current_task = GafferDeadline.GafferDeadlineTask( new_batch, len(self.getTasks()), start_frame=batch_frames[0], end_frame=batch_frames[0]) self._tasks.append(current_task) for i in range(1, len(batch_frames)): if (batch_frames[i] - batch_frames[i - 1]) > 1: current_task = GafferDeadline.GafferDeadlineTask( new_batch, len(self.getTasks()), start_frame=batch_frames[i], end_frame=batch_frames[i]) self._tasks.append(current_task) else: current_task.setEndFrame(batch_frames[i]) else: # Control nodes like TaskList have no frames but do need tasks created to pass # through dependencies self._tasks.append( GafferDeadline.GafferDeadlineTask(new_batch, len(self.getTasks())))
def testSetFrameRangeFromList(self): dt = GafferDeadline.GafferDeadlineTask(None, 1) self.assertRaises(ValueError, dt.setFrameRangeFromList, [0, 4, 9]) self.assertRaises(ValueError, dt.setFrameRangeFromList, [10, 9, 8]) self.assertRaises(ValueError, dt.setFrameRangeFromList, [1.1, 2.0, 3]) self.assertRaises(ValueError, dt.setFrameRangeFromList, [1, 2.2, 3]) dt.setFrameRangeFromList([1, 2, 3, 4]) self.assertEqual(dt.getStartFrame(), 1) self.assertEqual(dt.getEndFrame(), 4) dt.setFrameRangeFromList([12.0, 13, 14.0]) self.assertEqual(dt.getStartFrame(), 12) self.assertEqual(dt.getEndFrame(), 14) self.assertEqual(type(dt.getStartFrame()), int) self.assertEqual(type(dt.getEndFrame()), int)
def testSetFrameRange(self): self.assertRaises(ValueError, GafferDeadline.GafferDeadlineTask, None, 1, start_frame=1, end_frame=0) dt = GafferDeadline.GafferDeadlineTask(None, 1, start_frame=0, end_frame=1) self.assertRaises(ValueError, dt.setFrameRange, 1, 0) self.assertRaises(ValueError, dt.setFrameRange, 0.1, 100) self.assertRaises(ValueError, dt.setFrameRange, 0, 100.1) dt.setFrameRange(0, 10) self.assertEqual(dt.getStartFrame(), 0) self.assertEqual(dt.getEndFrame(), 10) dt.setFrameRange(55.0, 75.0) self.assertEqual(dt.getStartFrame(), 55) self.assertEqual(dt.getEndFrame(), 75) self.assertEqual(type(dt.getStartFrame()), int) self.assertEqual(type(dt.getEndFrame()), int)