CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Static Public Attributes | Static Private Attributes
Mpslibclass.jobdatabase Class Reference

Public Member Functions

def get_class (self, argument='')
 
def print_memdb (self)
 
def read_db (self, db_file_name=__default_db_file_name)
 
def write_db (self)
 

Public Attributes

 addFiles
 
 batchScript
 
 cfgTemplate
 
 classInf
 
 currentTime
 
 driver
 
 header
 
 infiList
 
 mergeScript
 

Static Public Attributes

 elapsedTime
 
 JOBREMARK
 
 JOBSP1
 
 JOBSP2
 
 JOBSP3
 
 mssDir
 
 mssDirPool
 
 nJobs
 
 pedeMem
 
 spare1
 
 spare2
 
 spare3
 
 updateTime
 
 updateTimeHuman
 

Static Private Attributes

string __default_db_file_name = "mps.db"
 

Detailed Description

Definition at line 46 of file Mpslibclass.py.

Member Function Documentation

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

Definition at line 238 of file Mpslibclass.py.

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

Definition at line 127 of file Mpslibclass.py.

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

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

Definition at line 59 of file Mpslibclass.py.

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

Definition at line 192 of file Mpslibclass.py.

References Mpslibclass.jobdatabase.header.

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

Member Data Documentation

string Mpslibclass.jobdatabase.__default_db_file_name = "mps.db"
staticprivate

Definition at line 58 of file Mpslibclass.py.

Mpslibclass.jobdatabase.addFiles

Definition at line 80 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.batchScript

Definition at line 76 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.cfgTemplate
Mpslibclass.jobdatabase.classInf

Definition at line 79 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.currentTime

Definition at line 194 of file Mpslibclass.py.

Mpslibclass.jobdatabase.driver

Definition at line 81 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.elapsedTime
static

Definition at line 54 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.header
Mpslibclass.jobdatabase.infiList

Definition at line 78 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.JOBREMARK
static

Definition at line 49 of file Mpslibclass.py.

Mpslibclass.jobdatabase.JOBSP1
static

Definition at line 49 of file Mpslibclass.py.

Mpslibclass.jobdatabase.JOBSP2
static

Definition at line 49 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.JOBSP3
static

Definition at line 49 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.mergeScript

Definition at line 82 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.mssDir
static

Definition at line 52 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.mssDirPool
static

Definition at line 52 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.nJobs
static

Definition at line 54 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.pedeMem
static

Definition at line 54 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.spare1
static

Definition at line 52 of file Mpslibclass.py.

Mpslibclass.jobdatabase.spare2
static

Definition at line 52 of file Mpslibclass.py.

Mpslibclass.jobdatabase.spare3
static

Definition at line 52 of file Mpslibclass.py.

Mpslibclass.jobdatabase.updateTime
static

Definition at line 54 of file Mpslibclass.py.

Mpslibclass.jobdatabase.updateTimeHuman
static

Definition at line 52 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().