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

Member Function Documentation

◆ get_class()

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

Definition at line 241 of file Mpslibclass.py.

References Mpslibclass.jobdatabase.classInf, print(), and submitPVValidationJobs.split().

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

◆ print_memdb()

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, dqmMemoryStats.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, print(), FastTimerService_cff.range, and Mpslibclass.jobdatabase.updateTimeHuman.

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

◆ read_db()

def Mpslibclass.jobdatabase.read_db (   self,
  db_file_name = __default_db_file_name 
)

Definition at line 61 of file Mpslibclass.py.

References print().

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

◆ write_db()

def Mpslibclass.jobdatabase.write_db (   self)

Definition at line 195 of file Mpslibclass.py.

References Mpslibclass.jobdatabase.header.

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

Member Data Documentation

◆ __default_db_file_name

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

Definition at line 60 of file Mpslibclass.py.

◆ addFiles

Mpslibclass.jobdatabase.addFiles

Definition at line 82 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

◆ batchScript

Mpslibclass.jobdatabase.batchScript

Definition at line 78 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

◆ cfgTemplate

Mpslibclass.jobdatabase.cfgTemplate

◆ classInf

Mpslibclass.jobdatabase.classInf

◆ currentTime

Mpslibclass.jobdatabase.currentTime

Definition at line 197 of file Mpslibclass.py.

◆ driver

Mpslibclass.jobdatabase.driver

Definition at line 83 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

◆ elapsedTime

Mpslibclass.jobdatabase.elapsedTime
static

Definition at line 56 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

◆ header

Mpslibclass.jobdatabase.header

◆ infiList

Mpslibclass.jobdatabase.infiList

Definition at line 80 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

◆ JOBREMARK

Mpslibclass.jobdatabase.JOBREMARK
static

Definition at line 51 of file Mpslibclass.py.

◆ JOBSP1

Mpslibclass.jobdatabase.JOBSP1
static

Definition at line 51 of file Mpslibclass.py.

◆ JOBSP2

Mpslibclass.jobdatabase.JOBSP2
static

Definition at line 51 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

◆ JOBSP3

Mpslibclass.jobdatabase.JOBSP3
static

Definition at line 51 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

◆ mergeScript

Mpslibclass.jobdatabase.mergeScript

Definition at line 84 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

◆ mssDir

Mpslibclass.jobdatabase.mssDir
static

Definition at line 54 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

◆ mssDirPool

Mpslibclass.jobdatabase.mssDirPool
static

Definition at line 54 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

◆ nJobs

Mpslibclass.jobdatabase.nJobs
static

◆ pedeMem

Mpslibclass.jobdatabase.pedeMem
static

Definition at line 56 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().

◆ spare1

Mpslibclass.jobdatabase.spare1
static

Definition at line 54 of file Mpslibclass.py.

◆ spare2

Mpslibclass.jobdatabase.spare2
static

Definition at line 54 of file Mpslibclass.py.

◆ spare3

Mpslibclass.jobdatabase.spare3
static

Definition at line 54 of file Mpslibclass.py.

◆ updateTime

Mpslibclass.jobdatabase.updateTime
static

Definition at line 56 of file Mpslibclass.py.

◆ updateTimeHuman

Mpslibclass.jobdatabase.updateTimeHuman
static

Definition at line 54 of file Mpslibclass.py.

Referenced by Mpslibclass.jobdatabase.print_memdb().