diff --git a/ctapipe/tools/apply_models.py b/ctapipe/tools/apply_models.py index 6881c6562aa..0a6285dcbab 100644 --- a/ctapipe/tools/apply_models.py +++ b/ctapipe/tools/apply_models.py @@ -113,7 +113,7 @@ class ApplyModels(Tool): ), "overwrite": ( { - "H5Merger": {"overwrite": True}, + "HDF5Merger": {"overwrite": True}, "ApplyModels": {"overwrite": True}, }, "Overwrite output file if it exists", diff --git a/ctapipe/tools/tests/test_apply_models.py b/ctapipe/tools/tests/test_apply_models.py index ccaf741f7c6..13f8edb805a 100644 --- a/ctapipe/tools/tests/test_apply_models.py +++ b/ctapipe/tools/tests/test_apply_models.py @@ -1,4 +1,5 @@ import numpy as np +import pytest from ctapipe.containers import ( EventIndexContainer, @@ -7,6 +8,7 @@ ReconstructedGeometryContainer, ) from ctapipe.core import run_tool +from ctapipe.core.tool import ToolConfigurationError from ctapipe.instrument import SubarrayDescription from ctapipe.io import TableLoader, read_table from ctapipe.io.tests.test_table_loader import check_equal_array_event_order @@ -73,6 +75,29 @@ def test_apply_energy_regressor( check_equal_array_event_order(trigger, energy) + # test "overwrite" works + with pytest.raises(ToolConfigurationError, match="exists, but overwrite=False"): + run_tool( + ApplyModels(), + argv=[ + f"--input={input_path}", + f"--output={output_path}", + f"--reconstructor={energy_regressor_path}", + ], + raises=True, + ) + + run_tool( + ApplyModels(), + argv=[ + f"--input={input_path}", + f"--output={output_path}", + f"--reconstructor={energy_regressor_path}", + "--overwrite", + ], + raises=True, + ) + def test_apply_all( energy_regressor_path, diff --git a/docs/changes/2311.bugfix.rst b/docs/changes/2311.bugfix.rst new file mode 100644 index 00000000000..109c27bfeb4 --- /dev/null +++ b/docs/changes/2311.bugfix.rst @@ -0,0 +1 @@ +Fix ``ApplyModels.overwrite``.