CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
Mpslibclass.jobdatabase Class Reference

Public Member Functions

def get_class
 
def print_memdb
 
def read_db
 
def write_db
 

Public Attributes

 addFiles
 
 batchScript
 
 cfgTemplate
 
 classInf
 
 currentTime
 
 driver
 
 elapsedTime
 
 header
 
 infiList
 
 mergeScript
 
 mssDir
 
 mssDirPool
 
 nJobs
 
 pedeMem
 
 spare1
 
 spare2
 
 spare3
 
 updateTime
 
 updateTimeHuman
 

Detailed Description

Definition at line 45 of file Mpslibclass.py.

Member Function Documentation

def Mpslibclass.jobdatabase.get_class (   self,
  argument = '' 
)

Definition at line 224 of file Mpslibclass.py.

References cmsRelvalreport.exit.

225  def get_class(self, argument=''):
226  CLASSES = self.classInf.split(':')
227  if len(CLASSES)<1 or len(CLASSES)>2:
228  print '\nget_class():\n class must be of the form \'class\' or \'classMille:classPede\', but is \'%s\'!\n\n', classInf
229  exit()
230  return ''
231  elif argument == 'mille':
232  return CLASSES[0]
233  elif argument == 'pede':
234  if len(CLASSES) == 1:
235  return CLASSES[0]
236  elif len(CLASSES) == 2:
237  return CLASSES[1]
238  else:
239  print '\nget_class():\n Know class only for \'mille\' or \'pede\', not %s!\n\n' %argument
240  exit() #???????????????
241  return ''
242 
243 
244 
245 
246 
247 
248 
249 
250 
def Mpslibclass.jobdatabase.print_memdb (   self)

Definition at line 113 of file Mpslibclass.py.

References Mpslibclass.jobdatabase.addFiles, Mpslibclass.jobdatabase.batchScript, Mpslibclass.jobdatabase.cfgTemplate, Mpslibclass.jobdatabase.classInf, Mpslibclass.jobdatabase.driver, Mpslibclass.jobdatabase.elapsedTime, Mpslibclass.jobdatabase.header, Mpslibclass.jobdatabase.infiList, Mpslibclass.jobdatabase.mergeScript, Mpslibclass.jobdatabase.mssDir, Mpslibclass.jobdatabase.mssDirPool, Mpslibclass.jobdatabase.nJobs, Mpslibclass.jobdatabase.pedeMem, and Mpslibclass.jobdatabase.updateTimeHuman.

114  def print_memdb(self):
115  #print metainfo
116  print "\n=== mps database printout ===\n"
117  print self.header
118  print 'Script:\t\t', self.batchScript
119  print 'cfg:\t\t', self.cfgTemplate
120  print 'files:\t\t', self.infiList
121  print 'class:\t\t', self.classInf
122  print 'name:\t\t', self.addFiles
123  print 'driver:\t\t', self.driver
124  print 'mergeScript:\t', self.mergeScript
125  print 'mssDir:\t\t', self.mssDir
126  print 'updateTime:\t', self.updateTimeHuman
127  print 'elapsed:\t', self.elapsedTime
128  print 'mssDirPool:\t', self.mssDirPool
129  print 'pedeMem:\t', self.pedeMem, '\n'
130 
131  #print interesting Job-level lists ---- to add: t/evt, fix remarks
132  print '### dir jobid stat try rtime nevt remark weight name'
133  print "------------------------------------------------------------------------------"
134  for i in xrange(self.nJobs):
135  print '%03d %6s %9d %6s %3d %5d %8d %8s %5s %s' % (
136  self.JOBNUMBER[i],
137  self.JOBDIR[i],
138  self.JOBID[i],
139  self.JOBSTATUS[i],
140  self.JOBNTRY[i],
141  self.JOBRUNTIME[i],
142  self.JOBNEVT[i],
143  self.JOBHOST[i],
144  self.JOBSP2[i],
145  self.JOBSP3[i])
146 
147  #print merge Jobs if merge mode
148  if self.driver == 'merge':
149  for i in xrange(self.nJobs,len(self.JOBDIR)):
150  print '%s %6s %9d %6s %3d %5d %8d %8s %5s %s' % (
151  'MMM',
152  self.JOBDIR[i],
153  self.JOBID[i],
154  self.JOBSTATUS[i],
155  self.JOBNTRY[i],
156  self.JOBRUNTIME[i],
157  self.JOBNEVT[i],
158  self.JOBHOST[i],
159  self.JOBSP2[i],
160  self.JOBSP3[i])
161 
162  #print summed info
163  totalEvents = sum(self.JOBNEVT[:self.nJobs])
164  totalCpu = sum(self.JOBRUNTIME[:self.nJobs])
165  meanCpuPerEvent = 0.
166  if totalEvents > 0:
167  meanCpuPerEvent = float(totalCpu)/totalEvents
168  print "------------------------------------------------------------------------------"
169  print "\t\t\t\t\tEvent total:\t", totalEvents
170  print "\t\t\t\t\tCPU total:\t", totalCpu, 's'
171  print "\t\t\t\t\tMean CPU/event:\t",meanCpuPerEvent,'s'
172 
173 
174 
175 
def Mpslibclass.jobdatabase.read_db (   self)

Definition at line 57 of file Mpslibclass.py.

57 
58  def read_db(self):
59  DBFILE = open('mps.db','r')
60 
61  #read infolines at the top, used rstrip to delete the '\n'
62  self.header = DBFILE.readline().strip()
63  self.batchScript = DBFILE.readline().rstrip('\n')
64  self.cfgTemplate = DBFILE.readline().rstrip('\n')
65  self.infiList = DBFILE.readline().rstrip('\n')
66  self.classInf = DBFILE.readline().rstrip('\n') #formerly named 'class' ->conflict
67  self.addFiles = DBFILE.readline().rstrip('\n')
68  self.driver = DBFILE.readline().rstrip('\n')
69  self.mergeScript = DBFILE.readline().rstrip('\n')
70  self.mssDir = DBFILE.readline().rstrip('\n')
71  self.updateTime = int(DBFILE.readline())
72  self.updateTimeHuman = DBFILE.readline().rstrip('\n')
73  self.elapsedTime = int(DBFILE.readline())
74  self.mssDirPool = DBFILE.readline().rstrip('\n')
75  self.pedeMem = int(DBFILE.readline())
76  self.spare1 = DBFILE.readline().rstrip('\n')
77  self.spare2 = DBFILE.readline().rstrip('\n')
78  self.spare3 = DBFILE.readline().rstrip('\n')
79 
80  #read actual jobinfo into arrays
81  self.nJobs = 0
82  milleJobs = 0
83 
84 
85  for line in DBFILE:
86  line = line.rstrip('\n') #removes the pesky \n from line
87  parts = line.split(":") #read each line and split into parts list
88  self.JOBNUMBER.append(int(parts[0]))
89  self.JOBDIR.append(parts[1])
90  self.JOBID.append(int(parts[2]))
91  self.JOBSTATUS.append(parts[3])
92  self.JOBNTRY.append(int(parts[4]))
93  self.JOBRUNTIME.append(int(parts[5])) #int float?
94  self.JOBNEVT.append(int(parts[6]))
95  self.JOBHOST.append(parts[7])
96  self.JOBINCR.append(int(parts[8]))
97  self.JOBREMARK.append(parts[9])
98  self.JOBSP1.append(parts[10])
99  self.JOBSP2.append(parts[11])
100  self.JOBSP3.append(parts[12])
101 
102  #count number of jobs
103  if 'jobm' not in self.JOBDIR[self.nJobs]:
104  milleJobs += 1
105  self.nJobs += 1
106  self.nJobs = milleJobs
107 
108  DBFILE.close()
109 
110 
def Mpslibclass.jobdatabase.write_db (   self)

Definition at line 178 of file Mpslibclass.py.

References Mpslibclass.jobdatabase.header.

179  def write_db(self):
180  self.header = "mps database schema 3.2"
181  self.currentTime = int(time.time())
182  self.elapsedTime = 0;
183  if self.updateTime != 0:
184  self.elapsedTime = self.currentTime - self.updateTime
185  self.updateTime = self.currentTime
186  self.updateTimeHuman = str(datetime.datetime.today()) #no timezone :(
187  self.spare1 = "-- unused --"
188  self.spare2 = "-- unused --"
189  self.spare3 = "-- unused --"
190 
191  #if mps.db already exists, backup as mps.db~ (in case of interupt during write)
192  os.system('[[ -a mps.db ]] && cp -p mps.db mps.db~')
193 
194  #write mps.db header
195  DBFILE = open ("mps.db", "w")
196  headData = [ self.header, self.batchScript, self.cfgTemplate, self.infiList,
197  self.classInf, self.addFiles, self.driver, self.mergeScript,
198  self.mssDir, self.updateTime, self.updateTimeHuman,
199  self.elapsedTime, self.mssDirPool, self.pedeMem,
200  self.spare1, self.spare2, self.spare3 ]
201  for item in headData:
202  DBFILE.write("%s\n" % item)
203 
204  #write mps.db jobinfo
205  for i in xrange(len(self.JOBID)):
206  DBFILE.write('%03d:%s:%05d:%s:%s:%s:%s:%s:%s:%s:%s:%s:%s\n' %
207  (i+1,
208  self.JOBDIR[i],
209  self.JOBID[i],
210  self.JOBSTATUS[i],
211  self.JOBNTRY[i],
212  self.JOBRUNTIME[i],
213  self.JOBNEVT[i],
214  self.JOBHOST[i],
215  self.JOBINCR[i],
216  self.JOBREMARK[i],
217  self.JOBSP1[i],
218  self.JOBSP2[i],
219  self.JOBSP3[i]))
220  DBFILE.close()

Member Data Documentation

Mpslibclass.jobdatabase.addFiles

Definition at line 66 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.batchScript

Definition at line 62 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.cfgTemplate

Definition at line 63 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.classInf

Definition at line 65 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.currentTime

Definition at line 180 of file Mpslibclass.py.

Mpslibclass.jobdatabase.driver

Definition at line 67 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.elapsedTime

Definition at line 72 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.header

Definition at line 61 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb(), and Mpslibclass.jobdatabase.write_db().

Mpslibclass.jobdatabase.infiList

Definition at line 64 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.mergeScript

Definition at line 68 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.mssDir

Definition at line 69 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.mssDirPool

Definition at line 73 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.nJobs

Definition at line 80 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.pedeMem

Definition at line 74 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.spare1

Definition at line 75 of file Mpslibclass.py.

Mpslibclass.jobdatabase.spare2

Definition at line 76 of file Mpslibclass.py.

Mpslibclass.jobdatabase.spare3

Definition at line 77 of file Mpslibclass.py.

Mpslibclass.jobdatabase.updateTime

Definition at line 70 of file Mpslibclass.py.

Mpslibclass.jobdatabase.updateTimeHuman

Definition at line 71 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().