Exemplo n.º 1
0
    def _get_task_border(as_path=False):
        offsets = generate_expected_offsets(30, 800, 600)
        subtask = SubtaskState()

        definition = RenderingTaskDefinition()
        definition.options = BlenderRendererOptions()
        definition.options.use_frames = False
        definition.resolution = [800, 600]

        for k in range(1, 31):
            subtask.extra_data = {'start_task': k, 'end_task': k}
            border = BlenderTaskTypeInfo.get_task_border(subtask,
                                                         definition,
                                                         30,
                                                         as_path=as_path)
            assert min(border) == (0, offsets[k])
            assert max(border) == (797, offsets[k + 1] - 1)

        definition.options.use_frames = True
        definition.options.frames = list(range(2))
        offsets = generate_expected_offsets(15, 800, 600)

        for k in range(1, 31):
            subtask.extra_data = {'start_task': k, 'end_task': k}
            border = BlenderTaskTypeInfo.get_task_border(subtask,
                                                         definition,
                                                         30,
                                                         as_path=as_path)
            i = (k - 1) % 15 + 1
            assert min(border) == (0, offsets[i])
            assert max(border) == (798, offsets[i + 1] - 1)

        subtask.extra_data = {'start_task': 2, 'end_task': 2}
        definition.options.use_frames = True
        definition.options.frames = list(range(30))
        if as_path:
            assert BlenderTaskTypeInfo.get_task_border(
                subtask, definition, 30, as_path=as_path) == \
                [(0, 600), (800, 600), (800, 0), (0, 0)]
        else:
            assert BlenderTaskTypeInfo.get_task_border(subtask,
                                                       definition,
                                                       30,
                                                       as_path=as_path) == []

        definition.options.use_frames = False
        definition.resolution = (0, 0)
        assert BlenderTaskTypeInfo.get_task_border(subtask,
                                                   definition,
                                                   30,
                                                   as_path=as_path) == []
Exemplo n.º 2
0
    def test_get_task_num_from_pixels(self):
        offsets = generate_expected_offsets(30, 1920, 1080)
        frame_offsets = generate_expected_offsets(15, 1920, 1080)
        task_definition = RenderingTaskDefinition()
        task_definition.options = BlenderRendererOptions()
        task_definition.resolution = [1920, 1080]

        for k in range(1, 31):
            task_definition.options.use_frames = False
            num = BlenderTaskTypeInfo.get_task_num_from_pixels(
                6, offsets[k] + 1, task_definition, 30)
            assert num == k

            task_definition.options.use_frames = True
            task_definition.options.frames = range(30)
            num = BlenderTaskTypeInfo.get_task_num_from_pixels(
                1, 0, task_definition, 30, k)
            assert num == k

            i = (k - 1) % 15 + 1
            task_definition.options.frames = range(2)
            num = BlenderTaskTypeInfo.get_task_num_from_pixels(
                1, frame_offsets[i] + 3, task_definition, 30, (k - 1) / 15 + 1)
            assert num == k

        task_definition.options.use_frames = False
        assert BlenderTaskTypeInfo.get_task_num_from_pixels(
            5, 1200, task_definition, 30) == 30
Exemplo n.º 3
0
    def test_presets(self):
        tdf = RenderingTaskDefinition()
        tdf.subtasks_count = 12
        tdf.options = "Some option"
        tdf.optimize_total = True
        tdf.verification_options = "Option"
        tdf.resolution = [1111, 2222]
        tdf.output_format = ".exr"

        preset = tdf.make_preset()

        assert len(preset) == 6
        assert preset["subtasks_count"] == 12
        assert preset["options"] == "Some option"
        assert preset["optimize_total"]
        assert preset["verification_options"] == "Option"
        assert preset["output_format"] == ".exr"
        assert preset["resolution"] == [1111, 2222]

        tdf2 = RenderingTaskDefinition()
        assert tdf2.subtasks_count == 0
        assert tdf2.options is None
        assert not tdf2.optimize_total
        assert tdf2.verification_options is None
        assert tdf2.resolution == [0, 0]
        assert tdf2.output_format == ""

        tdf2.load_preset(preset)
        assert tdf2.subtasks_count == 12
        assert tdf2.options == "Some option"
        assert tdf2.optimize_total
        assert tdf2.verification_options == "Option"
        assert tdf2.resolution == [1111, 2222]
        assert tdf2.output_format == ".exr"
Exemplo n.º 4
0
    def test_task_border_path(self):
        typeinfo = LuxRenderTaskTypeInfo(None, None)
        definition = RenderingTaskDefinition()
        definition.resolution = (300, 200)
        border = typeinfo.get_task_border("subtask1",
                                          definition,
                                          10,
                                          as_path=True)

        assert len(border) == 4
        assert (0, 0) in border
        assert (0, 199) in border
        assert (299, 199) in border
        assert (299, 0) in border

        definition.resolution = (0, 0)
        assert typeinfo.get_task_border("subtask1",
                                        definition,
                                        10,
                                        as_path=True) == []
Exemplo n.º 5
0
    def test_compositing(self):
        task_definition = RenderingTaskDefinition()
        task_definition.options = BlenderRendererOptions()
        task_definition.options.use_frames = True
        task_definition.options.frames = [7, 8, 10]
        task_definition.main_scene_file = self.temp_file_name("example.blend")
        task_definition.output_file = self.temp_file_name('output')
        task_definition.output_format = 'PNG'
        task_definition.resolution = [2, 300]
        task_definition.task_id = "ABC"

        def _get_blender_task(task_definition, total_tasks=6):
            return BlenderRenderTask(
                owner=Node(node_name="exmaple-node-name"),
                task_definition=task_definition,
                total_tasks=total_tasks,
                root_path=self.tempdir,
            )

        # Compostiting set to False
        task_definition.options.compositing = False
        bt = _get_blender_task(task_definition)
        assert not bt.compositing

        # Compositing True, use frames, more subtasks than frames
        task_definition.options.compositing = True
        bt = _get_blender_task(task_definition)
        assert not bt.compositing

        # Compositing True, use frames, as many subtasks as frames
        bt = _get_blender_task(task_definition, 3)
        assert not bt.compositing

        # Compositing True, use frames, less subtasks than frames
        bt = _get_blender_task(task_definition, 1)
        assert not bt.compositing

        # Compositing True, use frames is False, as many subtask as frames
        task_definition.options.use_frames = False
        bt = _get_blender_task(task_definition, 3)
        assert not bt.compositing
Exemplo n.º 6
0
    def setUp(self):
        super(TestBlenderFrameTask, self).setUp()
        program_file = self.temp_file_name('program')
        task_definition = RenderingTaskDefinition()
        task_definition.options = BlenderRendererOptions()
        task_definition.options.compositing = False
        task_definition.options.use_frames = True
        task_definition.options.frames = [7, 8, 10]
        task_definition.main_scene_file = self.temp_file_name("example.blend")
        task_definition.output_file = self.temp_file_name('output')
        task_definition.output_format = 'PNG'
        task_definition.resolution = [2, 300]
        self.bt = BlenderRenderTask(
            node_name="example-node-name",
            task_definition=task_definition,
            total_tasks=6,
            root_path=self.tempdir,
        )

        dm = DirManager(self.path)
        self.bt.initialize(dm)
Exemplo n.º 7
0
    def setUp(self):
        super(TestBlenderFrameTask, self).setUp()
        task_definition = RenderingTaskDefinition()
        task_definition.options = BlenderRendererOptions()
        task_definition.options.compositing = False
        task_definition.options.use_frames = True
        task_definition.options.frames = [7, 8, 10]
        task_definition.main_scene_file = self.temp_file_name("example.blend")
        task_definition.output_file = self.temp_file_name('output')
        task_definition.output_format = 'PNG'
        task_definition.resolution = [200, 300]
        task_definition.task_id = str(uuid.uuid4())
        BlenderRenderTask.VERIFICATION_QUEUE._reset()
        self.bt = BlenderRenderTask(
            owner=Node(node_name="example-node-name"),
            task_definition=task_definition,
            total_tasks=6,
            root_path=self.tempdir,
        )

        dm = DirManager(self.path)
        self.bt.initialize(dm)
Exemplo n.º 8
0
 def _get_frame_task(self, use_frames=True, num_tasks=3):
     files_ = self.additional_dir_content([3])
     rt = RenderingTaskDefinition()
     rt.options = FrameRendererOptions()
     rt.options.use_frames = use_frames
     rt.options.frames = list(range(6))
     rt.main_scene_file = files_[1]
     rt.output_format = "PNG"
     rt.output_file = files_[2]
     rt.resources = []
     rt.resolution = [800, 600]
     rt.timeout = 3600
     rt.subtask_timeout = 600
     rt.estimated_memory = 1000
     rt.max_price = 15
     task = FrameRenderingTaskMock(files_[0],
                                   owner=Node(node_name="ABC"),
                                   task_definition=rt,
                                   total_tasks=num_tasks,
                                   root_path=self.path)
     dm = DirManager(self.path)
     task.initialize(dm)
     return task
Exemplo n.º 9
0
    def build_bt(self, res_x, res_y, total_tasks, frames=None):
        output_file = self.temp_file_name('output')
        if frames is None:
            use_frames = False
            frames = [1]
        else:
            use_frames = True

        task_definition = RenderingTaskDefinition()
        task_definition.options = BlenderRendererOptions()
        task_definition.options.use_frames = use_frames
        task_definition.options.frames = frames
        task_definition.output_file = output_file
        task_definition.output_format = "PNG"
        task_definition.resolution = [res_x, res_y]
        task_definition.main_scene_file = path.join(self.path, "example.blend")
        task_definition.task_id = str(uuid.uuid4())
        bt = BlenderRenderTask(owner=Node(node_name="example-node-name"),
                               task_definition=task_definition,
                               total_tasks=total_tasks,
                               root_path=self.tempdir)
        bt.initialize(DirManager(self.tempdir))
        return bt
Exemplo n.º 10
0
 def test_get_task_num_from_pixels(self):
     typeinfo = LuxRenderTaskTypeInfo(None, None)
     definition = RenderingTaskDefinition()
     definition.resolution = (0, 0)
     assert typeinfo.get_task_num_from_pixels(10, 10, definition, 10) == 1
Exemplo n.º 11
0
    def test_get_task_border(self):
        typeinfo = LuxRenderTaskTypeInfo(None, None)
        definition = RenderingTaskDefinition()
        definition.resolution = (4, 4)
        border = typeinfo.get_task_border("subtask1", definition, 10)
        for i in range(4):
            assert (i, 0) in border
            assert (i, 3) in border
        for j in range(4):
            assert (0, j) in border
            assert (3, j) in border

        definition.resolution = (300, 200)
        border = typeinfo.get_task_border("subtask1", definition, 10)
        for i in range(300):
            assert (i, 0) in border
            assert (i, 199) in border
        for j in range(200):
            assert (0, j) in border
            assert (299, j) in border
        assert (300, 199) not in border
        assert (299, 201) not in border
        assert (0, 200) not in border
        assert (300, 0) not in border

        definition.resolution = (300, 300)
        border = typeinfo.get_task_border("subtask1", definition, 10)
        for i in range(200):
            assert (i, 0) in border
            assert (i, 199) in border
        for j in range(200):
            assert (0, j) in border
            assert (199, j) in border
        assert (200, 199) not in border
        assert (199, 200) not in border
        assert (0, 200) not in border
        assert (200, 0) not in border

        definition.resolution = (1000, 100)
        border = typeinfo.get_task_border("subtask1", definition, 10)
        for i in range(300):
            assert (i, 0) in border
            assert (i, 29) in border
        for j in range(30):
            assert (0, j) in border
            assert (299, j) in border
        assert (30, 299) not in border
        assert (29, 200) not in border
        assert (0, 30) not in border
        assert (300, 0) not in border

        definition.resolution = (100, 1000)
        border = typeinfo.get_task_border("subtask1", definition, 10)
        for i in range(20):
            assert (i, 0) in border
            assert (i, 199) in border
        for j in range(200):
            assert (0, j) in border
            assert (19, j) in border
        assert (20, 199) not in border
        assert (19, 200) not in border
        assert (20, 0) not in border
        assert (0, 200) not in border

        definition.resolution = (0, 4)
        assert typeinfo.get_task_border("subtask1", definition, 10) == []
        definition.resolution = (4, 0)
        assert typeinfo.get_task_border("subtask1", definition, 10) == []
        definition.resolution = (0, 0)
        assert typeinfo.get_task_border("subtask1", definition, 10) == []