Skip to content

Commit

Permalink
Merge branch 'main' into paganinsweep
Browse files Browse the repository at this point in the history
  • Loading branch information
dkazanc authored Nov 18, 2024
2 parents 8fde01d + 03073d2 commit 38ad1f0
Show file tree
Hide file tree
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
Expand Up @@ -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:
Expand Down
11 changes: 2 additions & 9 deletions httomo/ui_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
19 changes: 0 additions & 19 deletions tests/test_ui_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 38ad1f0

Please sign in to comment.