35
35
from servicex .dataset_identifier import DataSetIdentifier
36
36
37
37
38
- def run_query (input_filenames ):
38
+ def run_query (
39
+ input_filenames ,
40
+ ):
39
41
import uproot
40
42
import awkward as ak
41
43
import json
@@ -59,6 +61,13 @@ def is_tree(obj):
59
61
tree_dict = {}
60
62
61
63
with uproot .open (input_filenames ) as file :
64
+
65
+ meta = file ["MetaData" ]
66
+ fm_branches = [b for b in meta .keys () if b .startswith ("FileMetaDataAuxDyn." )]
67
+ # remove the prefix in keys
68
+ meta_dict = {p [19 :]: str (meta [p ].array (library = "ak" )[0 ]) for p in fm_branches }
69
+ tree_dict ["FileMetaData" ] = meta_dict
70
+
62
71
for tree_name in file .keys ():
63
72
tree_name_clean = tree_name .rstrip (";1" )
64
73
tree = file [tree_name ]
@@ -174,9 +183,6 @@ def print_structure_from_str(
174
183
import json
175
184
176
185
output_lines = []
177
- output_lines .append (
178
- f"\n File structure of all samples with branch filter '{ filter_branch } ':"
179
- )
180
186
181
187
for sample_name , path in deliver_dict .items ():
182
188
structure_str = open_delivered_file (sample_name , path )
@@ -191,6 +197,19 @@ def print_structure_from_str(
191
197
f"---------------------------"
192
198
)
193
199
200
+ # Get the metadata first
201
+ output_lines .append (f"\n File Metadata \u2139 \ufe0f :\n " )
202
+ for key , value in structure_dict .get ("FileMetaData" , {}).items ():
203
+ output_lines .append (f"── { key } : { value } " )
204
+ output_lines .append ("\n ---------------------------" )
205
+
206
+ # drop the File metadata from the trees
207
+ structure_dict .pop ("FileMetaData" , {})
208
+
209
+ output_lines .append (
210
+ f"\n File structure with branch filter \U0001f33f '{ filter_branch } ':\n "
211
+ )
212
+
194
213
for tree_name , branches in structure_dict .items ():
195
214
output_lines .append (f"\n \U0001f333 Tree: { tree_name } " )
196
215
output_lines .append (" ├── Branches:" )
0 commit comments