From 03073d2967a8f9a0200e63c7c4381b4722d7d8e2 Mon Sep 17 00:00:00 2001 From: Yousef Moazzam Date: Tue, 12 Nov 2024 12:34:34 +0000 Subject: [PATCH] Remove pipeline file extension check --- httomo/cli_utils.py | 11 ----------- httomo/ui_layer.py | 11 ++--------- tests/test_ui_layer.py | 19 ------------------- 3 files changed, 2 insertions(+), 39 deletions(-) diff --git a/httomo/cli_utils.py b/httomo/cli_utils.py index aa98abe26..dada6db35 100644 --- a/httomo/cli_utils.py +++ b/httomo/cli_utils.py @@ -9,17 +9,6 @@ def is_sweep_pipeline(file_path: Path) -> bool: """ Determine if the given pipeline contains a parameter sweep """ - extension = file_path.suffix.lower() - if extension == ".yaml": - return _does_yaml_pipeline_contain_sweep(file_path) - else: - raise ValueError(f"Unrecognised pipeline file extension: {extension}") - - -def _does_yaml_pipeline_contain_sweep(file_path: Path) -> bool: - """ - Check for `!Sweep` or `!SweepRange` tags - """ with open(file_path) as f: for line in f: if MANUAL_SWEEP_TAG in line or RANGE_SWEEP_TAG in line: diff --git a/httomo/ui_layer.py b/httomo/ui_layer.py index 89c93b914..b0a421023 100644 --- a/httomo/ui_layer.py +++ b/httomo/ui_layer.py @@ -45,15 +45,8 @@ def __init__( self.comm = comm self._preview_config: PreviewConfig | None = None - root, ext = os.path.splitext(self.tasks_file_path) - if ext.upper() in [".YAML", ".YML"]: - # loading yaml file with tasks provided - self.PipelineStageConfig = yaml_loader(self.tasks_file_path) - else: - # TODO option to relocate to yaml_checker - raise ValueError( - f"The extension {ext} of the file {root} with tasks is unknown." - ) + # loading yaml file with tasks provided + self.PipelineStageConfig = yaml_loader(self.tasks_file_path) def build_pipeline(self) -> Pipeline: loader = self._setup_loader() diff --git a/tests/test_ui_layer.py b/tests/test_ui_layer.py index 3227781b1..d6b46e638 100644 --- a/tests/test_ui_layer.py +++ b/tests/test_ui_layer.py @@ -113,25 +113,6 @@ def test_can_read_gpu1(yaml_gpu_pipeline1): assert pipline_stage_config[7]["module_path"] == "httomolib.misc.images" -@pytest.mark.parametrize("extension", ["yaml", "yml", "YaML", "YAML"]) -def test_uilayer_calls_correct_loader_yaml(mocker: MockerFixture, extension: str): - comm = MPI.COMM_NULL - loader = mocker.patch("httomo.ui_layer.yaml_loader") - file = Path(f"test_pipeline.{extension}") - UiLayer(file, Path("doesnt_matter"), comm=comm) - - loader.assert_called_once_with(file) - - -def test_uilayer_fails_with_unsupported_extension(mocker: MockerFixture): - comm = MPI.COMM_NULL - file = Path(f"test_pipeline.dummy") - with pytest.raises(ValueError) as e: - UiLayer(file, Path("doesnt_matter"), comm=comm) - - assert "extension .dummy" in str(e) - - @pytest.mark.parametrize("file", ["does_not_exist.yaml"]) def test_uilayer_fails_with_nonexistant_file(file: str): comm = MPI.COMM_NULL