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

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

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

128  def print_memdb(self):
129  #print metainfo
130  print "\n=== mps database printout ===\n"
131  print self.header
132  print 'Script:\t\t', self.batchScript
133  print 'cfg:\t\t', self.cfgTemplate
134  print 'files:\t\t', self.infiList
135  print 'class:\t\t', self.classInf
136  print 'name:\t\t', self.addFiles
137  print 'driver:\t\t', self.driver
138  print 'mergeScript:\t', self.mergeScript
139  print 'mssDir:\t\t', self.mssDir
140  print 'updateTime:\t', self.updateTimeHuman
141  print 'elapsed:\t', self.elapsedTime
142  print 'mssDirPool:\t', self.mssDirPool
143  print 'pedeMem:\t', self.pedeMem, '\n'
144 
145  #print interesting Job-level lists ---- to add: t/evt, fix remarks
146  print '### dir jobid stat try rtime nevt remark weight name'
147  print "------------------------------------------------------------------------------"
148  for i in xrange(self.nJobs):
149  print '%03d %6s %9s %6s %3d %5d %8d %8s %5s %s' % (
150  self.JOBNUMBER[i],
151  self.JOBDIR[i],
152  self.JOBID[i],
153  self.JOBSTATUS[i],
154  self.JOBNTRY[i],
155  self.JOBRUNTIME[i],
156  self.JOBNEVT[i],
157  self.JOBHOST[i],
158  self.JOBSP2[i],
159  self.JOBSP3[i])
160 
161  #print merge Jobs if merge mode
162  if self.driver == 'merge':
163  for i in xrange(self.nJobs,len(self.JOBDIR)):
164  print '%s %6s %9s %6s %3d %5d %8d %8s %5s %s' % (
165  'MMM',
166  self.JOBDIR[i],
167  self.JOBID[i],
168  self.JOBSTATUS[i],
169  self.JOBNTRY[i],
170  self.JOBRUNTIME[i],
171  self.JOBNEVT[i],
172  self.JOBHOST[i],
173  self.JOBSP2[i],
174  self.JOBSP3[i])
175 
176  #print summed info
177  totalEvents = sum(self.JOBNEVT[:self.nJobs])
178  totalCpu = sum(self.JOBRUNTIME[:self.nJobs])
179  meanCpuPerEvent = 0.
180  if totalEvents > 0:
181  meanCpuPerEvent = float(totalCpu)/totalEvents
182  print "------------------------------------------------------------------------------"
183  print "\t\t\t\t\tEvent total:\t", totalEvents
184  print "\t\t\t\t\tCPU total:\t", totalCpu, 's'
185  print "\t\t\t\t\tMean CPU/event:\t",meanCpuPerEvent,'s'
186 
187 
188 
189 
190 
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  if line.strip() == "": continue # ignore empty lines
100  line = line.rstrip('\n') # removes the pesky \n from line
101  parts = line.split(":") # read each line and split into parts list
102  self.JOBNUMBER.append(int(parts[0]))
103  self.JOBDIR.append(parts[1].strip())
104  self.JOBID.append(parts[2])
105  self.JOBSTATUS.append(parts[3].strip())
106  self.JOBNTRY.append(int(parts[4]))
107  self.JOBRUNTIME.append(int(parts[5])) #int float?
108  self.JOBNEVT.append(int(parts[6]))
109  self.JOBHOST.append(parts[7].strip())
110  self.JOBINCR.append(int(parts[8]))
111  self.JOBREMARK.append(parts[9].strip())
112  self.JOBSP1.append(parts[10].strip())
113  self.JOBSP2.append(parts[11].strip())
114  self.JOBSP3.append(parts[12].strip())
115 
116  #count number of jobs
117  if not self.JOBDIR[self.nJobs].startswith("jobm"):
118  milleJobs += 1
119  self.nJobs += 1
120  self.nJobs = milleJobs
121 
122  DBFILE.close()
123 
124 
125 
def read_db(self, db_file_name=__default_db_file_name)
Definition: Mpslibclass.py:59
def Mpslibclass.jobdatabase.write_db (   self)

Definition at line 193 of file Mpslibclass.py.

References Mpslibclass.jobdatabase.header.

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

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 195 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
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().