def test_blender_docker_env(self): env = BlenderEnvironment() self.assertTrue( all(isinstance(img, DockerImage) for img in env.docker_images)) image_available = any(img.is_available() for img in env.docker_images) self.assertEqual(image_available, env.check_support().is_ok())
def test_get_performance(self): """Changing estimated performance in ClientConfigDescriptor.""" env = BlenderEnvironment() fake_performance = 2345.2 cfg_desc = ClientConfigDescriptor() cfg_desc.estimated_blender_performance = fake_performance result = env.get_performance(cfg_desc) self.assertEquals(result, fake_performance)
def __init__(self): RendererDefaults.__init__(self) self.output_format = "EXR" self.main_program_file = BlenderEnvironment().main_program_file self.min_subtasks = 1 self.max_subtasks = 100 self.default_subtasks = 6
def test_get_min_accepted_performance(self): # given p = Performance(environment_id=BlenderEnvironment.get_id(), min_accepted_step=100) p.save() MinPerformanceMultiplier.set(3.141) # then self.assertEqual(MinPerformanceMultiplier.get(), 3.141) self.assertEqual(self.env.get_min_accepted_performance(), 314.1)
class BlenderEnvTest(DatabaseFixture, PEP8MixIn): PEP8_FILES = ["apps/blender/blenderenvironment.py"] def setUp(self): super().setUp() self.env = BlenderEnvironment() def test_blender(self): """Basic environment test.""" self.assertTrue(self.env.check_support()) def test_get_performance(self): """Changing estimated performance in ClientConfigDescriptor.""" assert self.env.get_performance() == 0.0 # given fake_performance = 2345.2 p = Performance(environment_id=BlenderEnvironment.get_id(), value=fake_performance) p.save() # then self.assertEqual(self.env.get_performance(), fake_performance) def test_get_min_accepted_performance_default(self): self.assertEqual(MinPerformanceMultiplier.get(), 0.0) self.assertEqual(self.env.get_min_accepted_performance(), 0.0) def test_get_min_accepted_performance(self): # given p = Performance(environment_id=BlenderEnvironment.get_id(), min_accepted_step=100) p.save() MinPerformanceMultiplier.set(3.141) # then self.assertEqual(MinPerformanceMultiplier.get(), 3.141) self.assertEqual(self.env.get_min_accepted_performance(), 314.1) def test_main_program_file(self): assert path.isfile(BlenderEnvironment().main_program_file)
def test_get_performance(self): """Changing estimated performance in ClientConfigDescriptor.""" assert self.env.get_performance() == 0.0 # given fake_performance = 2345.2 p = Performance(environment_id=BlenderEnvironment.get_id(), value=fake_performance) p.save() # then self.assertEqual(self.env.get_performance(), fake_performance)
def run_benchmark(self, env_id): # TODO: move benchmarks to environments from apps.blender.blenderenvironment import BlenderEnvironment from apps.lux.luxenvironment import LuxRenderEnvironment deferred = Deferred() if env_id == BlenderEnvironment.get_id(): self.task_server.task_computer.run_blender_benchmark( deferred.callback, deferred.errback) elif env_id == LuxRenderEnvironment.get_id(): self.task_server.task_computer.run_lux_benchmark( deferred.callback, deferred.errback) else: raise Exception("Unknown environment: {}".format(env_id)) result = yield deferred returnValue(result)
def test_run_benchmark(self, *_): from apps.blender.blenderenvironment import BlenderEnvironment from apps.blender.benchmark.benchmark import BlenderBenchmark benchmark_manager = self.client.task_server.benchmark_manager benchmark_manager.run_benchmark = Mock() benchmark_manager.run_benchmark.side_effect = lambda b, tb, e, c, ec: \ c(True) with self.assertRaisesRegex(Exception, "Unknown environment"): sync_wait(self.client.run_benchmark(str(uuid.uuid4()))) sync_wait(self.client.run_benchmark(BlenderEnvironment.get_id())) assert benchmark_manager.run_benchmark.call_count == 1 assert isinstance(benchmark_manager.run_benchmark.call_args[0][0], BlenderBenchmark) assert benchmark_manager.run_benchmark.call_count == 1
def __init__(self): Benchmark.__init__(self) self.normalization_constant = 9360 self.blender_task_path = os.path.join( os.path.dirname(os.path.abspath(__file__)), "test_task") self.task_definition.output_file = os.path.join( tempfile.gettempdir(), "blender_benchmark.png") self.task_definition.task_type = "Blender" self.task_definition.output_format = "png" self.task_definition.options = BlenderRendererOptions() self.task_definition.options.frames = [1] self.task_definition.task_id = u"{}".format("blender_benchmark") self.task_definition.main_scene_file = os.path.join( self.blender_task_path, "scene-Helicopter-27-cycles.blend") self.task_definition.main_program_file = BlenderEnvironment( ).main_program_file self.task_definition.resources.add( os.path.normpath(self.task_definition.main_scene_file))
def test_run_benchmark(self, *_): from apps.blender.blenderenvironment import BlenderEnvironment from apps.lux.luxenvironment import LuxRenderEnvironment task_computer = self.client.task_server.task_computer task_computer.run_blender_benchmark.side_effect = lambda c, e: c(True) task_computer.run_lux_benchmark.side_effect = lambda c, e: c(True) with self.assertRaises(Exception): sync_wait(self.client.run_benchmark(str(uuid.uuid4()))) sync_wait(self.client.run_benchmark(BlenderEnvironment.get_id())) assert task_computer.run_blender_benchmark.called assert not task_computer.run_lux_benchmark.called task_computer.run_blender_benchmark.called = False task_computer.run_lux_benchmark.called = False sync_wait(self.client.run_benchmark(LuxRenderEnvironment.get_id())) assert not task_computer.run_blender_benchmark.called assert task_computer.run_lux_benchmark.called
def test_main_program_file(self): assert path.isfile(BlenderEnvironment().main_program_file)
def setUp(self): super(SubtaskResultsVerifyBaseTest, self).setUp() self.env = BlenderEnvironment() self.main_program_file = self.env.main_program_file
def _get_better_task_def(self): ctd = ComputeTaskDef() ctd['docker_images'] = [ di.to_dict() for di in BlenderEnvironment().docker_images ] return ctd
def setUp(self): super(SubtaskResultsVerifyBaseTest, self).setUp() self.env = BlenderEnvironment()
def setUp(self): super().setUp() self.env = BlenderEnvironment()
def __init__(self): super(BlenderRendererOptions, self).__init__() self.environment = BlenderEnvironment() self.compositing = False
def test_blender(self): """Basic environment test.""" env = BlenderEnvironment() self.assertTrue(env.supported()) self.assertTrue(env.check_software())
def _get_better_task_def(self): ctd = ComputeTaskDef() ctd.docker_images = BlenderEnvironment().docker_images return ctd