test
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 46 of file Mpslibclass.py.

Member Function Documentation

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

Definition at line 234 of file Mpslibclass.py.

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

Definition at line 123 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.

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

Definition at line 58 of file Mpslibclass.py.

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

Definition at line 188 of file Mpslibclass.py.

References Mpslibclass.jobdatabase.header.

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

Member Data Documentation

Mpslibclass.jobdatabase.addFiles

Definition at line 76 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.batchScript

Definition at line 72 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.cfgTemplate

Definition at line 73 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.classInf

Definition at line 75 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.currentTime

Definition at line 190 of file Mpslibclass.py.

Mpslibclass.jobdatabase.driver

Definition at line 77 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.elapsedTime

Definition at line 82 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.header

Definition at line 71 of file Mpslibclass.py.

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

Mpslibclass.jobdatabase.infiList

Definition at line 74 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.mergeScript

Definition at line 78 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.mssDir

Definition at line 79 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.mssDirPool

Definition at line 83 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.nJobs

Definition at line 90 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.pedeMem

Definition at line 84 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.spare1

Definition at line 85 of file Mpslibclass.py.

Mpslibclass.jobdatabase.spare2

Definition at line 86 of file Mpslibclass.py.

Mpslibclass.jobdatabase.spare3

Definition at line 87 of file Mpslibclass.py.

Mpslibclass.jobdatabase.updateTime

Definition at line 80 of file Mpslibclass.py.

Mpslibclass.jobdatabase.updateTimeHuman

Definition at line 81 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().