3535from servicex .dataset_identifier import DataSetIdentifier
3636
3737
38- def run_query (input_filenames ):
38+ def run_query (
39+ input_filenames ,
40+ ):
3941 import uproot
4042 import awkward as ak
4143 import json
@@ -59,6 +61,13 @@ def is_tree(obj):
5961 tree_dict = {}
6062
6163 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+
6271 for tree_name in file .keys ():
6372 tree_name_clean = tree_name .rstrip (";1" )
6473 tree = file [tree_name ]
@@ -174,9 +183,6 @@ def print_structure_from_str(
174183 import json
175184
176185 output_lines = []
177- output_lines .append (
178- f"\n File structure of all samples with branch filter '{ filter_branch } ':"
179- )
180186
181187 for sample_name , path in deliver_dict .items ():
182188 structure_str = open_delivered_file (sample_name , path )
@@ -191,6 +197,19 @@ def print_structure_from_str(
191197 f"---------------------------"
192198 )
193199
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+
194213 for tree_name , branches in structure_dict .items ():
195214 output_lines .append (f"\n \U0001f333 Tree: { tree_name } " )
196215 output_lines .append (" ├── Branches:" )
0 commit comments