From c3d7c0b604b9432365b426c4755e88d9469e9c61 Mon Sep 17 00:00:00 2001 From: Yousef Moazzam Date: Tue, 13 Jan 2026 11:06:22 +0000 Subject: [PATCH] Allow omitting image key path loader param in YAML checker HTTomo allows omitting the `image_key_path` loader parameter from the pipeline, for which the value `None` is assumed. This change enables the YAML checker also to allow pipelines which omit this loader parameter, assuming a `None` value. --- httomo/yaml_checker.py | 2 ++ .../testing/loader_omitted_image_key_path.yaml | 5 +++++ tests/test_yaml_checker.py | 8 ++++++++ 3 files changed, 15 insertions(+) create mode 100644 tests/samples/pipeline_template_examples/testing/loader_omitted_image_key_path.yaml diff --git a/httomo/yaml_checker.py b/httomo/yaml_checker.py index e50f4e592..a0a773534 100644 --- a/httomo/yaml_checker.py +++ b/httomo/yaml_checker.py @@ -139,6 +139,8 @@ def check_hdf5_paths_against_loader(conf: PipelineConfig, in_file_path: str) -> colour=Colour.GREEN, ) params = conf[0]["parameters"] + if "image_key_path" not in params: + params["image_key_path"] = None POSSIBLE_AUTO_PARAMS = ["data_path", "image_key_path", "rotation_angles"] possible_auto_param_pairs = {name: params[name] for name in POSSIBLE_AUTO_PARAMS} auto_pairs = {k: v for k, v in possible_auto_param_pairs.items() if v == "auto"} diff --git a/tests/samples/pipeline_template_examples/testing/loader_omitted_image_key_path.yaml b/tests/samples/pipeline_template_examples/testing/loader_omitted_image_key_path.yaml new file mode 100644 index 000000000..318154672 --- /dev/null +++ b/tests/samples/pipeline_template_examples/testing/loader_omitted_image_key_path.yaml @@ -0,0 +1,5 @@ +- method: standard_tomo + module_path: httomo.data.hdf.loaders + parameters: + data_path: auto + rotation_angles: auto diff --git a/tests/test_yaml_checker.py b/tests/test_yaml_checker.py index f98a2dfe9..20543a1f5 100644 --- a/tests/test_yaml_checker.py +++ b/tests/test_yaml_checker.py @@ -87,6 +87,14 @@ def test_hdf5_paths_invalid_non_auto_value_caught_if_null_image_key_path( assert not check_hdf5_paths_against_loader(conf, standard_data) +def test_hdf5_paths_accepts_omitted_image_key_path( + standard_data: str, sample_pipelines: str, load_yaml: Callable +): + filepath = sample_pipelines + "testing/loader_omitted_image_key_path.yaml" + conf = load_yaml(filepath) + assert check_hdf5_paths_against_loader(conf, standard_data) + + def test_check_methods_exist_in_templates(sample_pipelines: str, load_yaml: Callable): incorrect_method_pipeline = sample_pipelines + "testing/incorrect_method.yaml" conf = load_yaml(incorrect_method_pipeline)