ATLAS Offline Software
Loading...
Searching...
No Matches
UploadDQAMITag Namespace Reference

Functions

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

Variables

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

Function Documentation

◆ get_current_config()

UploadDQAMITag.get_current_config ( amiclient)

Definition at line 21 of file UploadDQAMITag.py.

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

◆ get_next_tag()

UploadDQAMITag.get_next_tag ( latestTag)

Definition at line 77 of file UploadDQAMITag.py.

77def get_next_tag(latestTag):
78 nextTag = latestTag[0] + str(int(latestTag[1:])+1)
79 #nextTag='h8'
80 return nextTag
81
82#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()

UploadDQAMITag.update_dict_for_configs_afs ( updict,
indir )

Definition at line 83 of file UploadDQAMITag.py.

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

◆ update_dict_for_configs_cvmfs()

UploadDQAMITag.update_dict_for_configs_cvmfs ( updict,
indir )

Definition at line 145 of file UploadDQAMITag.py.

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

◆ update_dict_for_release()

UploadDQAMITag.update_dict_for_release ( updict,
release )

Definition at line 199 of file UploadDQAMITag.py.

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

◆ upload_new_config()

UploadDQAMITag.upload_new_config ( amiclient,
nextTag,
updict )

Definition at line 242 of file UploadDQAMITag.py.

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

Variable Documentation

◆ action

UploadDQAMITag.action

Definition at line 272 of file UploadDQAMITag.py.

◆ AMI_TAG_PREFIX

str UploadDQAMITag.AMI_TAG_PREFIX = 'h'

Definition at line 19 of file UploadDQAMITag.py.

◆ amiclient

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

Definition at line 301 of file UploadDQAMITag.py.

◆ args

UploadDQAMITag.args

Definition at line 275 of file UploadDQAMITag.py.

◆ certificate

UploadDQAMITag.certificate

Definition at line 268 of file UploadDQAMITag.py.

◆ cfgdict

UploadDQAMITag.cfgdict

Definition at line 304 of file UploadDQAMITag.py.

◆ dest

UploadDQAMITag.dest

Definition at line 269 of file UploadDQAMITag.py.

◆ help

UploadDQAMITag.help

Definition at line 269 of file UploadDQAMITag.py.

◆ latestTag

UploadDQAMITag.latestTag

Definition at line 304 of file UploadDQAMITag.py.

◆ nextTag

UploadDQAMITag.nextTag = get_next_tag(latestTag)

Definition at line 305 of file UploadDQAMITag.py.

◆ options

UploadDQAMITag.options

Definition at line 275 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 262 of file UploadDQAMITag.py.

◆ s

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

Definition at line 313 of file UploadDQAMITag.py.