|
3 | 3 | # do that sort of testing.
|
4 | 4 | # An example endpoint (pass as arg to this script):
|
5 | 5 | # http://localhost:5000
|
6 |
| -import sys |
| 6 | +import argparse |
| 7 | +from typing import Optional |
| 8 | +import asyncio |
| 9 | + |
7 | 10 | from servicex import ServiceXDataset
|
8 | 11 | from servicex.servicex_adaptor import ServiceXAdaptor
|
9 |
| -from typing import Optional |
10 | 12 |
|
11 | 13 |
|
12 |
| -def run_query(endpoint: Optional[ServiceXAdaptor]) -> None: |
| 14 | +async def run_query(endpoint: Optional[ServiceXAdaptor], dest:str) -> None: |
13 | 15 | ds = ServiceXDataset(
|
14 | 16 | "mc16_13TeV:mc16_13TeV.361106.PowhegPythia8EvtGen_AZNLOCTEQ6L1_Zee.deriv.DAOD_STDM3.e3601_e5984_s3126_r10201_r10210_p3975_tid20425969_00", # NOQA
|
15 | 17 | backend_type='xaod',
|
16 | 18 | max_workers=100,
|
17 | 19 | servicex_adaptor=endpoint)
|
18 | 20 |
|
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) |
21 | 29 |
|
22 | 30 |
|
23 | 31 | 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