Skip to content

Commit

Permalink
Check for uniqueness of input files in merge tool
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnoe committed Sep 4, 2024
1 parent df6f812 commit 7f239d6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/ctapipe/tools/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import sys
from argparse import ArgumentParser
from collections import Counter
from pathlib import Path

from tqdm.auto import tqdm
Expand Down Expand Up @@ -161,6 +162,13 @@ def setup(self):
)
sys.exit(1)

counts = Counter(self.input_files)
duplicated = [p for p, c in counts.items() if c > 1]
if len(duplicated) > 0:
raise ToolConfigurationError(
f"Same file given multiple times. Duplicated files are: {duplicated}"
)

self.merger = self.enter_context(HDF5Merger(parent=self))
if self.merger.output_path in self.input_files:
raise ToolConfigurationError(
Expand Down

0 comments on commit 7f239d6

Please sign in to comment.