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