ATLAS Offline Software
Functions | Variables
UploadDQAMITag Namespace Reference

Functions

def get_current_config (amiclient)
 
def get_next_tag (latestTag)
 
def update_dict_for_configs_afs (updict, indir)
 
def update_dict_for_configs_cvmfs (updict, indir)
 
def update_dict_for_release (updict, release)
 
def upload_new_config (amiclient, nextTag, updict)
 

Variables

string AMI_TAG_PREFIX = 'h'
 
 parser
 
 certificate
 
 dest
 
 help
 
 action
 
 options
 
 args
 
 amiclient = pyAMI.client.Client('atlas')
 
 cfgdict
 
 latestTag
 
def nextTag = get_next_tag(latestTag)
 
string s = "Invalid directory given. hcfg files should exist in cvmfs or the atlasdqm afs space"
 

Function Documentation

◆ get_current_config()

def UploadDQAMITag.get_current_config (   amiclient)

Definition at line 22 of file UploadDQAMITag.py.

22 def get_current_config(amiclient):
23 
24  #amicommand = ['ListElement', '-entity=h_config', '-processingStep=Atlas_Production', '-project=Atlas_Production', '-select=tag']
25  amicommand = ['SearchQuery', '''-sql="SELECT V_AMITags.tagType, V_AMITags.tagNumber FROM V_AMITags WHERE V_AMITags.tagType = 'h' ORDER BY V_AMITags.tagNumber DESC"'''
26  '-project="AMITags"', '-processingStep=production']
27 
28  print (amicommand)
29 
30  result = amiclient.execute(amicommand, format='dict_object')
31  resultlist = result.get_rows('Element_Info')
32  latestTag = 'h' + resultlist[0]['tagNumber']
33  #try:
34  # latestTag = 'h' + `max(int(_['tag'][1:]) for _ in resultlist)`
35  #except:
36  # latestTag = 'h0'
37 
38  nextTag = latestTag[0] + str(int(latestTag[1:])+1)
39 
40  print ('Latest AMI tag is', latestTag)
41  print ('Will create AMI tag', nextTag)
42  #latestTag='h7'
43 
44  amicommand = ['AMIGetAMITagInfo', '-amiTag='+latestTag]
45 
46  result = amiclient.execute(amicommand, format='dict_object')
47  print ('----------')
48  #print (result)
49  #print (result.get_rowset_types())
50  #print (result.get_rows('amiTagInfo'))
51  rv = result.get_rows('amiTagInfo')[0]
52 
53  print ()
54  print ('-------------------------------------')
55  print ('Info of current AMI tag ...')
56  for key, val in rv.items():
57  print (' %s:' % key, val)
58  rv1 = {}
59  for k, v in rv.items():
60  rv1[k] = v.__str__()
61 
62  #del rv1['readStatus']
63  #del rv1['writeStatus']
64  for k in ('tag', 'createdBy', 'modifiedBy', 'tagStatus', 'tagNumber', 'tagType',
65  'locked', 'updates', 'created', 'lastModified', 'processingStep',
66  'transformationName', 'baseRelease', 'modified', 'phconfig'):
67  try:
68  del rv1[k]
69  except KeyError:
70  pass
71  for k in ('inputs','outputs', 'moreInfo', 'trfsetupcmd',
72  'description'):
73  rv1[k] = '"%s"' % str(rv1[k].__str__())
74 
75  #rv1['phconfig'] = str(rv1['phconfig'].__str__())
76  return rv1, latestTag
77 

◆ get_next_tag()

def UploadDQAMITag.get_next_tag (   latestTag)

Definition at line 78 of file UploadDQAMITag.py.

78 def get_next_tag(latestTag):
79  nextTag = latestTag[0] + str(int(latestTag[1:])+1)
80  #nextTag='h8'
81  return nextTag
82 
83 #if reading from afs, use the old system, looking for the most current hcfg files and setting the symlink as phconfig

◆ update_dict_for_configs_afs()

def UploadDQAMITag.update_dict_for_configs_afs (   updict,
  indir 
)

Definition at line 84 of file UploadDQAMITag.py.

84 def update_dict_for_configs_afs(updict, indir):
85 
86  basedir = os.path.abspath(indir)
87 
88  print ('Looking for configurations in subdirectories of', indir)
89 
90  types = ['minutes10', 'minutes30', 'run']
91  searchparams = [('Cosmics', 'cosmics'), ('Collisions', 'collisions'),
92  ('HeavyIons', 'heavyions')]
93 
94  filepathdict = {}
95  filelist = []
96 
97  for dir1, fn in searchparams:
98  print (dir1)
99  filepathdict[dir1] = {}
100  for t in types:
101  print (' ', t, '...',)
102  fname = os.path.join(basedir, dir1,
103  '%s_%s.current.hcfg' % (fn, t))
104  if os.access(fname, os.R_OK):
105  print ('found,',)
106  if os.path.islink(fname) and os.path.isfile(fname):
107  realname = os.readlink(fname)
108  if not os.path.isabs(realname):
109  realname = os.path.join(os.path.dirname(fname), realname)
110  print ('is symlink to', realname)
111  filepathdict[dir1][t] = realname
112  filelist.append(realname)
113  else:
114  print ('but is not valid symlink')
115  else:
116  print ('not found')
117  if filepathdict[dir1] == {}:
118  del filepathdict[dir1]
119 
120  commonpart = os.path.dirname(os.path.commonprefix(filelist)) + os.sep
121 
122  filepathdict['basename'] = commonpart
123 
124  # clean up common part
125  for dir1, fn in searchparams:
126  for t in types:
127  try:
128  filepathdict[dir1][t] = filepathdict[dir1][t].replace(commonpart, '')
129  except KeyError:
130  pass
131 
132  print ()
133  print ('-------------------------------------')
134  print ('File path dictionary to upload:')
135  print (filepathdict)
136  print ('-------------------------------------')
137  print ()
138 
139  val = updict.get('phconfig', {})
140  if isinstance(val, str):
141  val = {}
142  val['filepaths'] = filepathdict
143  updict['phconfig'] = '"%s"' % val
144 
145 #if reading hcfgs from a cvmfs directory, only one set of files should be present. Use those for phconfig

◆ update_dict_for_configs_cvmfs()

def UploadDQAMITag.update_dict_for_configs_cvmfs (   updict,
  indir 
)

Definition at line 146 of file UploadDQAMITag.py.

146 def update_dict_for_configs_cvmfs(updict, indir):
147 
148  basedir = os.path.abspath(indir)
149 
150  print ('Looking for configurations in subdirectories of', indir)
151 
152  types = ['minutes10', 'run']
153  searchparams = [('Cosmics', 'cosmics'), ('Collisions', 'collisions'),
154  ('HeavyIons', 'heavyions')]
155 
156  filepathdict = {}
157  filelist = []
158 
159  for dir1, fn in searchparams:
160  print (dir1)
161  filepathdict[dir1] = {}
162  for t in types:
163  print (' ', t, '...',)
164  fname = os.path.join(basedir, '%s_%s.hcfg' % (fn, t))
165  if os.access(fname, os.R_OK):
166  print ('found %s' % (dir1))
167  if os.path.isfile(fname):
168  filepathdict[dir1][t] = fname
169  filelist.append(fname)
170  else:
171  print ('not found')
172  if filepathdict[dir1] == {}:
173  del filepathdict[dir1]
174 
175  commonpart = os.path.dirname(os.path.commonprefix(filelist)) + os.sep
176 
177  filepathdict['basename'] = commonpart
178 
179  # clean up common part
180  for dir1, fn in searchparams:
181  for t in types:
182  try:
183  filepathdict[dir1][t] = filepathdict[dir1][t].replace(commonpart, '')
184  except KeyError:
185  pass
186 
187  print ()
188  print ('-------------------------------------')
189  print ('File path dictionary to upload:')
190  print (filepathdict)
191  print ('-------------------------------------')
192  print ()
193 
194  val = updict.get('phconfig', {})
195  if isinstance(val, str):
196  val = {}
197  val['filepaths'] = filepathdict
198  updict['phconfig'] = '"%s"' % val
199 

◆ update_dict_for_release()

def UploadDQAMITag.update_dict_for_release (   updict,
  release 
)

Definition at line 200 of file UploadDQAMITag.py.

200 def update_dict_for_release(updict, release):
201  # From UpdateAMITag.py
202  #Check if release exists
203  relSp=release.split("-")
204  if len(relSp)!=2:
205  s="ERROR: Expected parameter 'release' in the form Project-number, got "+release
206  raise RuntimeError(s)
207  relProj=relSp[0]
208  if ',' in relSp[1]:
209  relNbr, _=relSp[1].split(',', 1)
210  else:
211  relNbr, _=relSp[1], None
212 
213  baseRelNbr=".".join(relNbr.split(".")[:2])
214  relPath = "/cvmfs/atlas.cern.ch/repo/sw/software/%s/%s/%s" % (baseRelNbr, relProj, relNbr)
215  if not os.path.isdir(relPath):
216  s="ERROR Release directory " + relPath + " does not exist"
217  raise RuntimeError(s)
218  #Release exists if we reach this point
219 
220  extraSetup = " oracleCOOL"
221  if relProj == "AtlasProduction":
222  extraSetup += " AtlasProduction"
223  elif relProj == "Athena":
224  extraSetup += " Athena"
225  elif relProj == "AthDataQuality":
226  extraSetup += " AthDataQuality"
227  elif relProj != "AtlasOffline":
228  s="ERROR: The project specified (" + relProj +") is not Athena, AtlasOffline or AtlasProduction. Are you sure?"
229  raise RuntimeError(s)
230 
231  # update dictionary
232  tasktransinfo = {'trfpath': 'DQM_Tier0Wrapper_tf.py',
233  'trfsetupcmd': "/afs/cern.ch/atlas/tzero/software/setup/usetuptrf.sh " + relNbr + extraSetup}
234  updict['moreInfo'] = '"{\'tasktransinfo\': %s}"' % tasktransinfo.__str__()
235  updict['SWReleaseCache'] = release.replace('-', '_')
236  updict['groupName'] = relProj
237  updict['cacheName'] = relSp[1]
238  updict['description'] = "'Trf for combined DQM histogram merging and DQM webpage creation, to get periodic DQ monitoring updates. Using " + release +"'"
239  updict['trfsetupcmd'] = '"%s"' % tasktransinfo['trfsetupcmd']
240  #updict['tagNumber'] = nextTag[1:]
241  #del updict['trfsetupcmd']
242 

◆ upload_new_config()

def UploadDQAMITag.upload_new_config (   amiclient,
  nextTag,
  updict 
)

Definition at line 243 of file UploadDQAMITag.py.

243 def upload_new_config(amiclient, nextTag, updict):
244 
245  amicommand = ['AddAMITag', 'tagType="h"', ]
246 
247  for key, val in updict.items():
248  amicommand.append('%s=%s' % (key, val))
249 
250  print ('-------------------------------------')
251  print ()
252  print ('Now uploading new AMI tag')
253  print ('AMI command:', amicommand)
254 
255  result = amiclient.execute(amicommand)
256  print (result)
257  print ()
258  print ('Success!')
259 

Variable Documentation

◆ action

UploadDQAMITag.action

Definition at line 273 of file UploadDQAMITag.py.

◆ AMI_TAG_PREFIX

string UploadDQAMITag.AMI_TAG_PREFIX = 'h'

Definition at line 20 of file UploadDQAMITag.py.

◆ amiclient

UploadDQAMITag.amiclient = pyAMI.client.Client('atlas')

Definition at line 302 of file UploadDQAMITag.py.

◆ args

UploadDQAMITag.args

Definition at line 276 of file UploadDQAMITag.py.

◆ certificate

UploadDQAMITag.certificate

Definition at line 269 of file UploadDQAMITag.py.

◆ cfgdict

UploadDQAMITag.cfgdict

Definition at line 305 of file UploadDQAMITag.py.

◆ dest

UploadDQAMITag.dest

Definition at line 270 of file UploadDQAMITag.py.

◆ help

UploadDQAMITag.help

Definition at line 270 of file UploadDQAMITag.py.

◆ latestTag

UploadDQAMITag.latestTag

Definition at line 305 of file UploadDQAMITag.py.

◆ nextTag

def UploadDQAMITag.nextTag = get_next_tag(latestTag)

Definition at line 306 of file UploadDQAMITag.py.

◆ options

UploadDQAMITag.options

Definition at line 276 of file UploadDQAMITag.py.

◆ parser

UploadDQAMITag.parser
Initial value:
1 = optparse.OptionParser(usage='Usage: %prog [options] cmd arg\n'
2  ' cmd can be:\n'
3  ' configs: update only DQ configurations; args should be the config base directory\n'
4  ' release: update only the release; args should be the new release'
5  )

Definition at line 263 of file UploadDQAMITag.py.

◆ s

string UploadDQAMITag.s = "Invalid directory given. hcfg files should exist in cvmfs or the atlasdqm afs space"

Definition at line 314 of file UploadDQAMITag.py.

replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
UploadDQAMITag.update_dict_for_release
def update_dict_for_release(updict, release)
Definition: UploadDQAMITag.py:200
UploadDQAMITag.update_dict_for_configs_afs
def update_dict_for_configs_afs(updict, indir)
Definition: UploadDQAMITag.py:84
UploadDQAMITag.upload_new_config
def upload_new_config(amiclient, nextTag, updict)
Definition: UploadDQAMITag.py:243
UploadDQAMITag.update_dict_for_configs_cvmfs
def update_dict_for_configs_cvmfs(updict, indir)
Definition: UploadDQAMITag.py:146
UploadDQAMITag.get_current_config
def get_current_config(amiclient)
Definition: UploadDQAMITag.py:22
UploadDQAMITag.get_next_tag
def get_next_tag(latestTag)
Definition: UploadDQAMITag.py:78
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
str
Definition: BTagTrackIpAccessor.cxx:11
Trk::split
@ split
Definition: LayerMaterialProperties.h:38