Skip to content

Commit 87e85f2

Browse files
committed
update script to do integrated testing
This si more extensive - starting adding options to test other thing!
1 parent 5f474dc commit 87e85f2

File tree

1 file changed

+37
-12
lines changed

1 file changed

+37
-12
lines changed

scripts/run_test.py

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,53 @@
33
# do that sort of testing.
44
# An example endpoint (pass as arg to this script):
55
# http://localhost:5000
6-
import sys
6+
import argparse
7+
from typing import Optional
8+
import asyncio
9+
710
from servicex import ServiceXDataset
811
from servicex.servicex_adaptor import ServiceXAdaptor
9-
from typing import Optional
1012

1113

12-
def run_query(endpoint: Optional[ServiceXAdaptor]) -> None:
14+
async def run_query(endpoint: Optional[ServiceXAdaptor], dest:str) -> None:
1315
ds = ServiceXDataset(
1416
"mc16_13TeV:mc16_13TeV.361106.PowhegPythia8EvtGen_AZNLOCTEQ6L1_Zee.deriv.DAOD_STDM3.e3601_e5984_s3126_r10201_r10210_p3975_tid20425969_00", # NOQA
1517
backend_type='xaod',
1618
max_workers=100,
1719
servicex_adaptor=endpoint)
1820

19-
r = ds.get_data_rootfiles("(call ResultTTree (call Select (call SelectMany (call EventDataset (list 'localds:bogus')) (lambda (list e) (call (attr e 'Jets') 'AntiKt4EMTopoJets'))) (lambda (list j) (/ (call (attr j 'pt')) 1000.0))) (list 'JetPt') 'analysis' 'junk.root')") # NOQA
20-
print(r)
21+
request = "(call ResultTTree (call Select (call SelectMany (call EventDataset (list 'localds:bogus')) (lambda (list e) (call (attr e 'Jets') 'AntiKt4EMTopoJets'))) (lambda (list j) (/ (call (attr j 'pt')) 1000.0))) (list 'JetPt') 'analysis' 'junk.root')"
22+
if dest == 'rootfiles':
23+
r = ds.get_data_rootfiles(request) # NOQA
24+
print(r)
25+
elif dest == 'rootfiles-minio':
26+
r = ds.get_data_rootfiles_minio_async(request)
27+
async for f in r:
28+
print(f)
2129

2230

2331
if __name__ == '__main__':
24-
# import logging
25-
# ch = logging.StreamHandler()
26-
# ch.setLevel(logging.DEBUG)
27-
# logging.getLogger('servicex').setLevel(logging.DEBUG)
28-
# logging.getLogger('servicex').addHandler(ch)
29-
servicex_adaptor = ServiceXAdaptor(sys.argv[1]) if len(sys.argv) >= 2 else None
30-
run_query(servicex_adaptor)
32+
# Setup the arguments we can deal with here.
33+
parser = argparse.ArgumentParser(description='test servicex frontend.')
34+
parser.add_argument('--log', dest='logging', action='store_const',
35+
const=True, default=False,
36+
help='Turn on the logging')
37+
parser.add_argument('--output', dest='output',
38+
default=['rootfiles'], nargs=1,
39+
choices=['rootfiles', 'rootfiles-minio'],
40+
help='What output format should be returned')
41+
args = parser.parse_args()
42+
43+
if args.logging:
44+
import logging
45+
ch = logging.StreamHandler()
46+
ch.setLevel(logging.DEBUG)
47+
logging.getLogger('servicex').setLevel(logging.DEBUG)
48+
logging.getLogger('servicex').addHandler(ch)
49+
50+
# servicex_adaptor = ServiceXAdaptor(sys.argv[1]) if len(sys.argv) >= 2 else None
51+
loop = asyncio.get_event_loop()
52+
try:
53+
loop.run_until_complete(run_query(None, args.output[0]))
54+
finally:
55+
loop.close()

0 commit comments

Comments
 (0)