Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix --overwrite for ApplyModel tool #2311

Merged
merged 1 commit into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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``.