ATLAS Offline Software
testIfMatch.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 
5 import re,sys,os
6 import six
7 
8 from future import standard_library
9 standard_library.install_aliases()
10 import subprocess
11 
12 
14  try:
15  from pyAMI.pyAMI import AMI
16  amires = AMI().execute(["ListConfigurationTag","-configTag=%s" % tag])
17  d = amires.getDict()['rowset_%s'%tag][tag]
18  outDict = eval(d.get('outputs','None'))
19  except Exception as e:
20  print ("Failed to get OutputDict from AMI")
21  print (e)
22  return None
23  return outDict
24 
25 
27  #cdirs=("/castor/cern.ch/grid/atlas/tzero/prod1/perm/data11_7TeV","/castor/cern.ch/grid/atlas/tzero/prod1/perm/data11_cos")
28  cdirs=("/castor/cern.ch/grid/atlas/tzero/prod1/perm/data11_hi","/castor/cern.ch/grid/atlas/tzero/prod1/perm/data11_7TeV")
29 
30  tasknames=set()
31  for d in cdirs:
32  proj=d.split("/")[-1]
33  cmd="nsls "+d
34  (stat,out)=subprocess.getstatusoutput(cmd)
35  if stat!=0:
36  print ("ERROR, could not get list of streams from castor directory",d)
37  print (out)
38  return None
39  for stream in out.split(os.linesep):
40  tasknames.add(proj+".00000000."+stream+".merge.RAW")
41  return tasknames
42 
43 
44 
45 if __name__=='__main__':
46  if len(sys.argv)!=2:
47  print ("Syntax:")
48  print (sys.argv[0],"<ami-tag>")
49  sys.exit(-1)
50 
51  tag=sys.argv[1]
52  print ("ifmatch matrix for AMI configuration tag",tag)
53 
54  outDict=getOutputDictFromAMI(tag)
55  if outDict is None:
56  sys.exit(-1)
57 
58  #print (outDict)
59 
61  if taskNames is None:
62  sys.exit(-1)
63 
64  #print (streamList)
65 
66  matrix=dict()
67  for taskname in taskNames:
68  matrix[taskname]=dict()
69 
70  for name,outDef in six.iteritems (outDict):
71  if 'ifMatch' in outDef:
72  print ("\n"+name+" ["+ outDef['ifMatch'] +"]")
73  for taskname in taskNames:
74  if re.match(outDef['ifMatch'],taskname):
75  print ("\t",taskname," MATCH")
76  matrix[taskname][name]=True
77  else:
78  matrix[taskname][name]=False
79 
80 
81 
82  print ("Inverse Matrix:")
83  for tn,ops in six.iteritems (matrix):
84  print (tn[:-9]+": ", end='')
85  #print (" %30s :" % tn[:-9], end='')
86  for nm,s in six.iteritems (ops):
87  if s:
88  print (nm[6:-4]+" ", end='')
89  #print ("%8s " % nm[6:-4], end='')
90  #else:
91  # print (" ", end='')
92  print ("")
93 
python.testIfMatch.getTaskNamesFromCastor
def getTaskNamesFromCastor()
Definition: testIfMatch.py:26
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:224
python.testIfMatch.getOutputDictFromAMI
def getOutputDictFromAMI(tag)
Definition: testIfMatch.py:13