def test_properties_of_spawner_sub_modules_are_independent_on_branches(
        turbsim_input, fast_input, tmpdir):
    spawner = FastSimulationSpawner(fast_input, TurbsimSpawner(turbsim_input),
                                    tmpdir)
    branch = spawner.branch()
    spawner.initial_rotor_speed = 8.0
    branch.initial_rotor_speed = 9.0
    assert spawner.initial_rotor_speed != branch.initial_rotor_speed
def test_does_not_create_wind_task_when_wind_file_is_set(
        turbsim_input, fast_input, example_data_folder, tmpdir):
    spawner = FastSimulationSpawner(fast_input, TurbsimSpawner(turbsim_input),
                                    tmpdir)
    spawner.wind_file = path.join(example_data_folder, 'fast_input_files',
                                  'wind_files', 'EDC+R+2.0.wnd')
    task = spawner.spawn(path.join(tmpdir, 'a'), {})
    assert len(task.requires()) == 0
    task.run()
    assert task.complete()
Beispiel #3
0
def _create_spawner(tmpdir, turbsim_input_file, fast_input_file,
                    fast_input_cls):
    turbsim_input = TurbsimInput.from_file(turbsim_input_file)
    wind_spawner = TurbsimSpawner(turbsim_input)
    fast_input = fast_input_cls.from_file(fast_input_file)
    spawner = FastSimulationSpawner(fast_input, wind_spawner, tmpdir)
    spawner.wind_speed = 8.0
    spawner.output_start_time = 0.0
    spawner.simulation_time = 1.0
    return spawner
def test_spawns_tests_requiring_wind_generation_when_wind_changed(
        turbsim_input, fast_input):
    temp_dir = tempfile.TemporaryDirectory()
    spawner = FastSimulationSpawner(fast_input, TurbsimSpawner(turbsim_input),
                                    temp_dir.name)
    spawner.wind_type = 'bladed'  # ensure need to generate wind file
    task = spawner.spawn(path.join(temp_dir.name, 'a'), {})
    s2 = spawner.branch()
    s2.wind_speed = 8.0
    task2 = s2.spawn(path.join(temp_dir.name, 'b'), {})
    assert isinstance(task2.requires()[0], WindGenerationTask)
    s2.initial_yaw = 10.0
    task3 = s2.spawn(path.join(temp_dir.name, 'c'), {})
    assert task2.requires()[0]._id != task.requires()[0]._id
    assert task3.requires()[0]._id == task2.requires()[0]._id
def test_run_succeeds_with_large_output_start_time_with_branching(
        turbsim_input, fast_input, tmpdir):
    spawner = FastSimulationSpawner(fast_input, TurbsimSpawner(turbsim_input),
                                    tmpdir)
    spawner.output_start_time = 60.0
    spawner = spawner.branch()
    spawner.simulation_time = 30.0  # total run time of 90s
    spawner = spawner.branch()
    spawner.wind_speed = 8.0
    spawner.wind_type = 'bladed'
    task = spawner.spawn(path.join(tmpdir, 'a'), {})
    assert len(task.requires()) == 1
    task.requires()[0].run()
    task.run()
    assert task.complete()
def test_fails_with_invalid_parameter(turbsim_input, fast_input, tmpdir,
                                      plugin_loader):
    spawner = FastSimulationSpawner(fast_input, TurbsimSpawner(turbsim_input),
                                    tmpdir)
    spec_dict = {"spec": {"simulation_time": 1.0, "yaw_angle": 10.0}}
    spec = SpecificationParser(plugin_loader).parse(spec_dict)
    config = CommandLineConfiguration(workers=2,
                                      runner_type='process',
                                      prereq_outdir='prerequisites',
                                      outdir=tmpdir,
                                      local=True)
    scheduler = LuigiScheduler(config)
    scheduler.run(spawner, spec)
def test_spawn_with_additional_directory_puts_tasks_in_new_folders(
        turbsim_input, fast_input, tmpdir):
    runs_dir_1 = path.join(tmpdir, 'runs', '1')
    runs_dir_2 = path.join(tmpdir, 'runs', '2')
    spawner = FastSimulationSpawner(fast_input, TurbsimSpawner(turbsim_input),
                                    tmpdir)
    spawner.wind_type = 'bladed'  # ensure need to generate wind file
    spawner.wind_speed = 6.0
    task1 = spawner.spawn(runs_dir_1, {})
    spawner.wind_speed = 8.0
    task2 = spawner.spawn(runs_dir_2, {})
    assert task1.output().path != task2.output().path
    assert task1.requires()[0].output().path != task2.requires()[0].output(
    ).path
def test_runs_two_tasks_successfully_that_use_same_prerequisite(
        turbsim_input, fast_input, tmpdir, plugin_loader):
    spawner = FastSimulationSpawner(fast_input, TurbsimSpawner(turbsim_input),
                                    tmpdir)
    spec_dict = {
        "spec": {
            "simulation_time": 1.0,
            "wind_speed": 6.0,
            "initial_yaw": [-10.0, 10.0]
        }
    }
    spec = SpecificationParser(plugin_loader).parse(spec_dict)
    config = CommandLineConfiguration(workers=2,
                                      runner_type='process',
                                      prereq_outdir='prerequisites',
                                      outdir=tmpdir,
                                      local=True)
    scheduler = LuigiScheduler(config)
    scheduler.run(spawner, spec)
Beispiel #9
0
def spawner(wind_gen_spawner, fast_v7_input_file, tmpdir):
    return FastSimulationSpawner(Fast7Input.from_file(fast_v7_input_file), wind_gen_spawner, tmpdir)