@@ -179,13 +179,14 @@ def test_funcadl_query(transformed_result):
179
179
spec = ServiceXSpec .model_validate ({
180
180
"General" : {
181
181
"ServiceX" : "testing4" ,
182
- "Codegen" : "uproot-raw " ,
182
+ "Codegen" : "uproot" ,
183
183
},
184
184
"Sample" : [
185
185
{
186
186
"Name" : "sampleA" ,
187
187
"RucioDID" : "user.ivukotic:user.ivukotic.single_top_tW__nominal" ,
188
- "Query" : FuncADLQuery ().Select (lambda e : {"lep_pt" : e ["lep_pt" ]})
188
+ "Query" : FuncADLQuery ().Select (lambda e : {"lep_pt" : e ["lep_pt" ]}),
189
+ "Tree" : "nominal"
189
190
}
190
191
]
191
192
})
@@ -217,3 +218,30 @@ def run_query(input_filenames=None):
217
218
with patch ('servicex.dataset_group.DatasetGroup.as_files' ,
218
219
return_value = [transformed_result ]):
219
220
deliver (spec , config_path = 'tests/example_config.yaml' )
221
+
222
+
223
+ def test_generic_query ():
224
+ from servicex .servicex_client import ServiceXClient
225
+ spec = ServiceXSpec .model_validate ({
226
+ "General" : {
227
+ "ServiceX" : "testing4" ,
228
+ "Codegen" : "uproot-raw" ,
229
+ },
230
+ "Sample" : [
231
+ {
232
+ "Name" : "sampleA" ,
233
+ "RucioDID" : "user.ivukotic:user.ivukotic.single_top_tW__nominal" ,
234
+ "Query" : "[{'treename': 'nominal'}]"
235
+ }
236
+ ]
237
+ })
238
+ sx = ServiceXClient (backend = spec .General .ServiceX , config_path = 'tests/example_config.yaml' )
239
+ query = sx .generic_query (dataset_identifier = spec .Sample [0 ].RucioDID ,
240
+ codegen = spec .General .Codegen , query = spec .Sample [0 ].Query )
241
+ assert query .generate_selection_string () == "[{'treename': 'nominal'}]"
242
+ with pytest .raises (ValueError ):
243
+ query = sx .generic_query (dataset_identifier = spec .Sample [0 ].RucioDID ,
244
+ codegen = spec .General .Codegen , query = 5 )
245
+ with pytest .raises (NameError ):
246
+ query = sx .generic_query (dataset_identifier = spec .Sample [0 ].RucioDID ,
247
+ codegen = 'nonsense' , query = spec .Sample [0 ].Query )
0 commit comments