Skip to content

Commit b04877f

Browse files
benedikt-voelkelBenedikt Volkel
authored andcommitted
Allow passing list of files via another file
Possible to use o2dpg_release_validation.py rel-val -i @list.txt -j <file1> <file2> ... where list.txt contains a list of files paths for the first batch. Can be used independently for both -i and -j.
1 parent ec26db2 commit b04877f

1 file changed

Lines changed: 31 additions & 5 deletions

File tree

RelVal/o2dpg_release_validation.py

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,43 @@ def rel_val_root(files1, files2, include_root_dirs, add_to_previous, metrics_ena
189189
in case of success, return the path to the JSON with computed metrics
190190
None otherwise
191191
"""
192-
print("==> Process and compare 2 sets of files <==")
192+
def get_files_from_list(list_filename):
193+
"""
194+
Quick helper
193195
194-
# prepare the output directory
195-
if not exists(output_dir):
196-
makedirs(output_dir)
197-
log_file_rel_val = join(abspath(output_dir), "rel_val.log")
196+
Extract filenames from what is listed in a given file
197+
"""
198+
collect_files = []
199+
with open(list_filename, "r") as f:
200+
for line in f:
201+
line = line.strip()
202+
if not line:
203+
continue
204+
collect_files.append(line)
205+
return collect_files
206+
207+
print("==> Process and compare 2 sets of files <==")
198208

199209
# flat ROOT files to extract to and read from during RelVal; make absolute paths so we don't confuse ourselves when running e.g. ROOT macros in different directories
200210
file_1 = abspath(join(output_dir, "extracted_objects_1.root"))
201211
file_2 = abspath(join(output_dir, "extracted_objects_2.root"))
202212

213+
if len(files1) == 1 and files1[0][0] == "@":
214+
files1 = get_files_from_list(files1[0])
215+
if not files1:
216+
print(f"ERROR: Apparently {files1[0][1:]} contains no files to be extracted.")
217+
return None
218+
if len(files2) == 1 and files2[0][0] == "@":
219+
files2 = get_files_from_list(files2[0])
220+
if not files2:
221+
print(f"ERROR: Apparently {files2[0][1:]} contains no files to be extracted.")
222+
return None
223+
224+
# prepare the output directory
225+
if not exists(output_dir):
226+
makedirs(output_dir)
227+
log_file_rel_val = join(abspath(output_dir), "rel_val.log")
228+
203229
if no_extract:
204230
# in this case we expect the input files to be what we would otherwise extract first
205231
if len(files1) != 1 or len(files2) != 1:

0 commit comments

Comments
 (0)