Skip to content

Commit b8d737f

Browse files
committed
adding suppport for multiple files
1 parent ae69520 commit b8d737f

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

servicex_analysis_utils/file_peeking.py

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,21 +144,36 @@ def print_structure_from_str(deliver_dict, filter_branch="", save_to_txt=False )
144144
print(f" │ ├── {branch_line[8:]}")
145145

146146

147-
def get_structure(dataset_dict, **kwargs):
147+
def get_structure(dataset, **kwargs):
148148
"""
149149
Utility function.
150-
Creates and sends the ServiceX request from user input.
150+
Creates and sends the ServiceX request from user inputed datasets to retrieve file stucture.
151151
Calls print_structure_from_str()
152152
153153
Parameters:
154-
dataset_dict (dict): The datasets to print the structures from, with the associated sample name for readability
155-
note - should add default sample names and option to add just did or list of dids
154+
dataset_dict (dict,str,[str]): The datasets from which to print the file structures.
155+
A custom sample name per dataset can be given in a dict form: {'sample_name':'dataset_id'}
156156
kwargs : Arguments to be propagated to print_structure_from_str
157157
"""
158158
#Servicex query using the PythonFunction backend
159159
query_PythonFunction = servicex.query.PythonFunction().with_uproot_function(run_query)
160-
sample_list=[]
161160

161+
#Create a dict with sample name for ServiceX query & datasetID
162+
dataset_dict={}
163+
user_in=type(dataset)
164+
if user_in == str:
165+
dataset_dict.update({"Sample":dataset})
166+
elif user_in == list and type(dataset[0]) is str:
167+
for i in range(len(dataset)):
168+
name="Sample"+str(i+1) #write for humans
169+
dataset_dict.update({name:dataset[i]})
170+
elif user_in == dict:
171+
dataset_dict=dataset
172+
else:
173+
raise ValueError(f"Unsupported dataset input type: {user_in}.\nInput must be dict ('sample_name':'dataset_id'), str or list of str")
174+
175+
sample_list=[]
176+
162177
for name, did in dataset_dict.items():
163178
tmp_dict={
164179
"NFiles":1,

0 commit comments

Comments
 (0)