Skip to content

Commit

Permalink
Remove pipeline file extension check
Browse files Browse the repository at this point in the history
yousefmoazzam committed Nov 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 41e7d64 commit 03073d2
Showing 3 changed files with 2 additions and 39 deletions.
11 changes: 0 additions & 11 deletions httomo/cli_utils.py
Original file line number Diff line number Diff line change
@@ -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:
11 changes: 2 additions & 9 deletions httomo/ui_layer.py
Original file line number Diff line number Diff line change
@@ -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()
19 changes: 0 additions & 19 deletions tests/test_ui_layer.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 03073d2

Please sign in to comment.