@@ -144,21 +144,36 @@ def print_structure_from_str(deliver_dict, filter_branch="", save_to_txt=False )
144
144
print (f" │ ├── { branch_line [8 :]} " )
145
145
146
146
147
- def get_structure (dataset_dict , ** kwargs ):
147
+ def get_structure (dataset , ** kwargs ):
148
148
"""
149
149
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 .
151
151
Calls print_structure_from_str()
152
152
153
153
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'}
156
156
kwargs : Arguments to be propagated to print_structure_from_str
157
157
"""
158
158
#Servicex query using the PythonFunction backend
159
159
query_PythonFunction = servicex .query .PythonFunction ().with_uproot_function (run_query )
160
- sample_list = []
161
160
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 } .\n Input must be dict ('sample_name':'dataset_id'), str or list of str" )
174
+
175
+ sample_list = []
176
+
162
177
for name , did in dataset_dict .items ():
163
178
tmp_dict = {
164
179
"NFiles" :1 ,
0 commit comments