@@ -142,35 +142,24 @@ def print_structure_from_str(deliver_dict, filter_branch="", save_to_txt=False,
142
142
else :
143
143
return result_str
144
144
145
-
146
- def get_structure (dataset , ** kwargs ):
147
- """
148
- Utility function.
149
- Creates and sends the ServiceX request from user inputed datasets to retrieve file stucture.
150
- Calls print_structure_from_str()
151
-
152
- Parameters:
153
- dataset_dict (dict,str,[str]): The datasets from which to print the file structures.
154
- A custom sample name per dataset can be given in a dict form: {'sample_name':'dataset_id'}
155
- kwargs : Arguments to be propagated to print_structure_from_str
156
- """
145
+ def build_deliver_spec (dataset ):
157
146
#Servicex query using the PythonFunction backend
158
147
query_PythonFunction = servicex .query .PythonFunction ().with_uproot_function (run_query )
159
148
160
149
#Create a dict with sample name for ServiceX query & datasetID
161
150
dataset_dict = {}
162
151
user_in = type (dataset )
152
+
163
153
if user_in == str :
164
154
dataset_dict .update ({"Sample" :dataset })
165
155
elif user_in == list and type (dataset [0 ]) is str :
166
156
for i in range (len (dataset )):
167
- name = "Sample" + str (i + 1 ) #write for humans
157
+ name = "Sample" + str (i + 1 ) #write number for humans
168
158
dataset_dict .update ({name :dataset [i ]})
169
159
elif user_in == dict :
170
160
dataset_dict = dataset
171
161
else :
172
162
raise ValueError (f"Unsupported dataset input type: { user_in } .\n Input must be dict ('sample_name':'dataset_id'), str or list of str" )
173
- return 0
174
163
175
164
sample_list = [
176
165
{
@@ -181,10 +170,24 @@ def get_structure(dataset, **kwargs):
181
170
}
182
171
for name , did in dataset_dict .items ()
183
172
]
184
-
185
173
spec_python = {"Sample" : sample_list }
186
174
175
+ return spec_python
176
+
177
+
178
+ def get_structure (dataset , ** kwargs ):
179
+ """
180
+ Utility function.
181
+ Creates and sends the ServiceX request from user inputed datasets to retrieve file stucture.
182
+ Calls print_structure_from_str()
183
+
184
+ Parameters:
185
+ dataset (dict,str,[str]): The datasets from which to print the file structures.
186
+ A custom sample name per dataset can be given in a dict form: {'sample_name':'dataset_id'}
187
+ kwargs : Arguments to be propagated to print_structure_from_str
188
+ """
189
+ spec_python = build_deliver_spec (dataset )
190
+
187
191
output = servicex .deliver (spec_python )
188
192
189
- return print_structure_from_str (output , ** kwargs )
190
-
193
+ return print_structure_from_str (output , ** kwargs )
0 commit comments