Loading .gitlab-ci.yml +16 −2 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ test_audiotools_convert: - python3 -m pytest -n auto tests/test_audiotools_convert.py # run the test configs for the selection experiments experiments: .experiments: stage: test tags: - linux Loading @@ -89,8 +89,22 @@ experiments: when: on_failure expire_in: 1 week # test the lab/category-wise config creation experiment-setup: stage: test tags: - linux script: - *print-common-info - python3 -m pytest tests/test_experiments.py::test_experiment_setup -n auto | tee log.txt artifacts: paths: - log.txt when: always expire_in: "1 week" # run some test configs for item creation test_processing: .test_processing: stage: test rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' Loading experiments/create_experiment_config.py +8 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ def _patch_value(line: str, value) -> str: return ':'.join(line_split) def create_experiment_setup(experiment, lab): def create_experiment_setup(experiment, lab) -> list[str]: default_cfg_path = HERE.joinpath(f"selection/{experiment}/config/{experiment}.yml") with open(default_cfg_path) as f: Loading @@ -30,6 +30,8 @@ def create_experiment_setup(experiment, lab): categories = [f"cat{i}" for i in range(1, 7)] if experiment in EXPERIMENTS_P800 else [""] seed = _get_seed(experiment, lab) base_path = Path(HERE.name).joinpath(f"selection/{experiment}") cfgs = list() for cat in categories: input_path = base_path.joinpath("proc_input").joinpath(cat) output_path = base_path.joinpath("proc_output").joinpath(cat) Loading Loading @@ -66,6 +68,11 @@ def create_experiment_setup(experiment, lab): output_path.mkdir(parents=True, exist_ok=True) bg_noise_path.parent.mkdir(parents=True, exist_ok=True) cfgs.append(cat_cfg) # Return the lsit of configs that were generated. Not strictly necessary, but makes testing easier. return cfgs if __name__ == "__main__": parser = argparse.ArgumentParser() Loading tests/test_experiments.py +10 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ from tests.constants import ( NCHAN_TO_FILE, TESTS_DIR, ) from experiments import create_experiment_config BG_NOISE_NAME = "background_noise_cat.wav" Loading Loading @@ -132,3 +133,12 @@ def test_categories(exp_name): setup_input_files_for_config(config, cat) create_items(exp_name) @pytest.mark.parametrize("exp_name", ["P800-1"]) @pytest.mark.parametrize("lab_id", ["a", "b", "c", "d"]) def test_experiment_setup(exp_name, lab_id): cfgs = create_experiment_config.create_experiment_setup(exp_name, lab_id) for cfg in cfgs: # create config for validation of folder structure to be present config = TestConfig(cfg) No newline at end of file Loading
.gitlab-ci.yml +16 −2 Original line number Diff line number Diff line Loading @@ -74,7 +74,7 @@ test_audiotools_convert: - python3 -m pytest -n auto tests/test_audiotools_convert.py # run the test configs for the selection experiments experiments: .experiments: stage: test tags: - linux Loading @@ -89,8 +89,22 @@ experiments: when: on_failure expire_in: 1 week # test the lab/category-wise config creation experiment-setup: stage: test tags: - linux script: - *print-common-info - python3 -m pytest tests/test_experiments.py::test_experiment_setup -n auto | tee log.txt artifacts: paths: - log.txt when: always expire_in: "1 week" # run some test configs for item creation test_processing: .test_processing: stage: test rules: - if: $CI_PIPELINE_SOURCE == 'merge_request_event' Loading
experiments/create_experiment_config.py +8 −1 Original line number Diff line number Diff line Loading @@ -21,7 +21,7 @@ def _patch_value(line: str, value) -> str: return ':'.join(line_split) def create_experiment_setup(experiment, lab): def create_experiment_setup(experiment, lab) -> list[str]: default_cfg_path = HERE.joinpath(f"selection/{experiment}/config/{experiment}.yml") with open(default_cfg_path) as f: Loading @@ -30,6 +30,8 @@ def create_experiment_setup(experiment, lab): categories = [f"cat{i}" for i in range(1, 7)] if experiment in EXPERIMENTS_P800 else [""] seed = _get_seed(experiment, lab) base_path = Path(HERE.name).joinpath(f"selection/{experiment}") cfgs = list() for cat in categories: input_path = base_path.joinpath("proc_input").joinpath(cat) output_path = base_path.joinpath("proc_output").joinpath(cat) Loading Loading @@ -66,6 +68,11 @@ def create_experiment_setup(experiment, lab): output_path.mkdir(parents=True, exist_ok=True) bg_noise_path.parent.mkdir(parents=True, exist_ok=True) cfgs.append(cat_cfg) # Return the lsit of configs that were generated. Not strictly necessary, but makes testing easier. return cfgs if __name__ == "__main__": parser = argparse.ArgumentParser() Loading
tests/test_experiments.py +10 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,7 @@ from tests.constants import ( NCHAN_TO_FILE, TESTS_DIR, ) from experiments import create_experiment_config BG_NOISE_NAME = "background_noise_cat.wav" Loading Loading @@ -132,3 +133,12 @@ def test_categories(exp_name): setup_input_files_for_config(config, cat) create_items(exp_name) @pytest.mark.parametrize("exp_name", ["P800-1"]) @pytest.mark.parametrize("lab_id", ["a", "b", "c", "d"]) def test_experiment_setup(exp_name, lab_id): cfgs = create_experiment_config.create_experiment_setup(exp_name, lab_id) for cfg in cfgs: # create config for validation of folder structure to be present config = TestConfig(cfg) No newline at end of file