ATLAS Offline Software
rerun_display.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 
3 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 
5 # This aim of this script is to wrap execution of the web display transform when
6 # the input file doesn't need to be merged or postprocessed
7 # Need to set up AMI ("lsetup pyami") before use
8 
9 from argparse import ArgumentParser
10 from pyAMI.atlas import api as ami
11 from pyAMI.client import Client
12 import json
13 import os
14 import glob
15 import sys
16 import subprocess
17 import shutil
18 
19 PTAG = 'data22_13p6TeV'
20 EOS_TOP = f'/eos/atlas/atlastier0/rucio/{PTAG}/'
21 CODEDIR = '/afs/cern.ch/user/a/atlasdqm/dqmdisk1/20221117_rescue_displays'
22 
23 parser = ArgumentParser()
24 parser.add_argument('run')
25 parser.add_argument('stream')
26 parser.add_argument('reco_tag')
27 parser.add_argument('htag')
28 
29 opts = parser.parse_args()
30 
31 client = Client('atlas')
32 # client.config.read()
33 # ami.init()
34 amiinfo = ami.get_ami_tag(client, opts.htag)
35 
36 argdict = { 'skipMerge': 'True',
37  'allowCOOLUpload': 'True',
38  'doWebDisplay': 'True',
39  'incrementalMode': 'False',
40  'postProcessing': 'False',
41  }
42 # print(eval(amiinfo[1]['phconfig']))
43 argdict.update(eval(amiinfo[1]['phconfig']))
44 print('argdict', argdict)
45 
46 script = amiinfo[1]['trfsetupcmd'].split()[0]
47 preExec = ' '.join([os.path.join(CODEDIR, os.path.basename(script))] + amiinfo[1]['trfsetupcmd'].split()[1:])
48 print('preExec', preExec)
49 
50 inpath = os.path.join(EOS_TOP, opts.stream, f'*{opts.run}',
51  f'{PTAG}.*{opts.run}.{opts.stream}.merge.HIST.{opts.reco_tag}_{opts.htag}/*')
52 flist = glob.glob(inpath)
53 if len(flist) != 1:
54  print(f'Unable to locate unique file in {inpath}')
55  sys.exit(1)
56 
57 # os.symlink(flist[0], os.path.basename(flist[0]))
58 shutil.copy(flist[0], '.')
59 
60 pfx, lfn = os.path.split(flist[0])
61 _, dsn = os.path.split(pfx)
62 argdict['inputHistFiles'] = [{'dsn': dsn, 'dstype': 'HIST', 'events': 0, 'lfn': lfn}]
63 
64 with open('argdict.json', 'w') as outf:
65  json.dump(argdict, outf)
66 
67 cmd = f"source {preExec}; python3 -u {CODEDIR}/DQM_Tier0Wrapper_tf.py --argJSON=argdict.json"
68 print(f'To execute {cmd}')
69 chk=subprocess.run(cmd, shell=True)
70 
71 os.unlink(os.path.basename(flist[0]))
72 chk.check_returncode()
FakeBkgTools::Client
Client
Definition: FakeBkgInternals.h:141
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
Trk::open
@ open
Definition: BinningType.h:40
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
Trk::split
@ split
Definition: LayerMaterialProperties.h:38