Skip to content

Commit

Permalink
Fix --overwrite for ApplyModel tool
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Apr 20, 2023
1 parent e4fe1e7 commit 7680492
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ctapipe/tools/apply_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ApplyModels(Tool):
),
"overwrite": (
{
"H5Merger": {"overwrite": True},
"HDF5Merger": {"overwrite": True},
"ApplyModels": {"overwrite": True},
},
"Overwrite output file if it exists",
Expand Down
25 changes: 25 additions & 0 deletions ctapipe/tools/tests/test_apply_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np
import pytest

from ctapipe.containers import (
EventIndexContainer,
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions docs/changes/2311.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix ``ApplyModels.overwrite``.

0 comments on commit 7680492

Please sign in to comment.