CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes | Static Private 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
 

Static Private Attributes

string __default_db_file_name = "mps.db"
 

Detailed Description

Definition at line 48 of file Mpslibclass.py.

Member Function Documentation

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

Definition at line 241 of file Mpslibclass.py.

References print().

242  def get_class(self, argument=''):
243  CLASSES = self.classInf.split(':')
244  if len(CLASSES)<1 or len(CLASSES)>2:
245  print('\nget_class():\n class must be of the form \'class\' or \'classMille:classPede\', but is \'%s\'!\n\n', classInf)
246  sys.exit(1)
247  elif argument == 'mille':
248  return CLASSES[0]
249  elif argument == 'pede':
250  if len(CLASSES) == 1:
251  return CLASSES[0]
252  elif len(CLASSES) == 2:
253  return CLASSES[1]
254  else:
255  print('\nget_class():\n Know class only for \'mille\' or \'pede\', not %s!\n\n' %argument)
256  sys.exit(1)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
def Mpslibclass.jobdatabase.print_memdb (   self)

Definition at line 130 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, print(), sistrip::SpyUtilities.range(), and Mpslibclass.jobdatabase.updateTimeHuman.

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

Definition at line 61 of file Mpslibclass.py.

References print().

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

Definition at line 195 of file Mpslibclass.py.

References Mpslibclass.jobdatabase.header.

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

Member Data Documentation

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

Definition at line 60 of file Mpslibclass.py.

Mpslibclass.jobdatabase.addFiles

Definition at line 82 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.batchScript

Definition at line 78 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.cfgTemplate

Definition at line 79 of file Mpslibclass.py.

Referenced by genericValidation.GenericValidationData.createConfiguration(), and Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.classInf

Definition at line 81 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.currentTime

Definition at line 197 of file Mpslibclass.py.

Mpslibclass.jobdatabase.driver

Definition at line 83 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.elapsedTime

Definition at line 88 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.header

Definition at line 77 of file Mpslibclass.py.

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

Mpslibclass.jobdatabase.infiList

Definition at line 80 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.mergeScript

Definition at line 84 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.mssDir

Definition at line 85 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.mssDirPool

Definition at line 89 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.nJobs

Definition at line 96 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb(), and crabFunctions.CrabTask.update().

Mpslibclass.jobdatabase.pedeMem

Definition at line 90 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

Mpslibclass.jobdatabase.spare1

Definition at line 91 of file Mpslibclass.py.

Mpslibclass.jobdatabase.spare2

Definition at line 92 of file Mpslibclass.py.

Mpslibclass.jobdatabase.spare3

Definition at line 93 of file Mpslibclass.py.

Mpslibclass.jobdatabase.updateTime

Definition at line 86 of file Mpslibclass.py.

Mpslibclass.jobdatabase.updateTimeHuman

Definition at line 87 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().