diff --git a/tests/conftest.py b/tests/conftest.py index a3641b3..6983ab7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -208,42 +208,28 @@ def moo_main_run(tmp_path_factory, cd_to_root_and_back_session): @pytest.fixture(scope="session") -def stand_alone_opt_package_run(request, tmp_path_factory, cd_to_root_and_back_session): - # parametrize the test to pass in script options in config as relative and absolute paths - if getattr(request, "param", None) == "absolute": - temp_dir = tmp_path_factory.mktemp("temp_dir") - wrapper_path = (TEST_DIR / "scripts/stand_alone_opt_package/wrapper.py").resolve() - config = { - "objective": {"metrics": [{"metric": "mean", "name": "Mean"}, {"metric": "RMSE", "info_only": True}]}, - "generation_strategy": { - "steps": [{"model": "SOBOL", "num_trials": 2}, {"model": "GPEI", "num_trials": -1}] - }, - "scheduler": {"total_trials": 5}, - "parameters": [ - {"bounds": [-5.0, 10.0], "name": "x0", "type": "range"}, - {"bounds": [0.0, 15.0], "name": "x1", "type": "range"}, - ], - "script_options": { - "wrapper_path": str(wrapper_path), - "wrapper_name": "WrapperStandAlone", - "output_dir": str(temp_dir), - "exp_name": "test_experiment", - }, - } - config_path = temp_dir / "config.yaml" - with open(Path(config_path), "w") as file: - json.dump(config, file) - args = f"--config-path {config_path}" - else: - config_path = TEST_DIR / "scripts/stand_alone_opt_package/stand_alone_pkg_config.yaml" - args = f"--config-path {config_path} -td" - +def stand_alone_opt_package_run(tmp_path_factory, cd_to_root_and_back_session): + config_path = TEST_DIR / "scripts/stand_alone_opt_package/stand_alone_pkg_config.yaml" + args = f"--config-path {config_path} -td" yield dunder_main.main(split_shell_command(args), standalone_mode=False) @pytest.fixture(scope="session") -def r_scripts_run(request, tmp_path_factory, cd_to_root_and_back_session): - sub_dir = request.param - config_path = TEST_DIR / f"scripts/other_langs/r_package_{sub_dir}/config.yaml" +def r_full(tmp_path_factory, cd_to_root_and_back_session): + config_path = TEST_DIR / f"scripts/other_langs/r_package_full/config.yaml" + + yield dunder_main.main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False) + + +@pytest.fixture(scope="session") +def r_light(tmp_path_factory, cd_to_root_and_back_session): + config_path = TEST_DIR / f"scripts/other_langs/r_package_light/config.yaml" + + yield dunder_main.main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False) + + +@pytest.fixture(scope="session") +def r_streamlined(tmp_path_factory, cd_to_root_and_back_session): + config_path = TEST_DIR / f"scripts/other_langs/r_package_streamlined/config.yaml" yield dunder_main.main(split_shell_command(f"--config-path {config_path} -td"), standalone_mode=False) diff --git a/tests/integration_tests/test_dunder_main.py b/tests/integration_tests/test_dunder_main.py index 8cc0dbe..ea3125a 100644 --- a/tests/integration_tests/test_dunder_main.py +++ b/tests/integration_tests/test_dunder_main.py @@ -73,18 +73,17 @@ def test_calling_command_line_test_script_doesnt_error_out_and_produces_correct_ # or parametrize the test to use the streamlined version (doesn't use trial_status.json, only use output.json) @pytest.mark.parametrize( "r_scripts_run", - ["full", "light", "streamlined"], - indirect=True, + ["r_full", "r_light", "r_streamlined"], ) @pytest.mark.skipif(not R_INSTALLED, reason="requires R to be installed") def test_calling_command_line_r_test_scripts(r_scripts_run, request): - scheduler = r_scripts_run + scheduler = request.getfixturevalue(r_scripts_run) wrapper = scheduler.experiment.runner.wrapper config = wrapper.config assert len(scheduler.experiment.trials) == config.trials assert scheduler - if "r_package_full" in str(wrapper.config_path): + if "r_full" == r_scripts_run: data = load_jsonlike(get_trial_dir(wrapper.experiment_dir, 0) / "data.json") assert "param_names" in data assert "metric_properties" in data