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.

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)

References Mpslibclass.jobdatabase.classInf, edm.print(), and cms::dd.split().

◆ print_memdb()

def Mpslibclass.jobdatabase.print_memdb (   self)

Definition at line 130 of file Mpslibclass.py.

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 

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

◆ read_db()

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

Definition at line 61 of file Mpslibclass.py.

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

References edm.print().

◆ write_db()

def Mpslibclass.jobdatabase.write_db (   self)

Definition at line 195 of file Mpslibclass.py.

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 

References Mpslibclass.jobdatabase.header.

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

FastTimerService_cff.range
range
Definition: FastTimerService_cff.py:34
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
digitizers_cfi.strip
strip
Definition: digitizers_cfi.py:19
cms::dd::split
std::vector< std::string_view > split(std::string_view, const char *)
str
#define str(s)
Definition: TestProcessor.cc:48
mps_setup.append
append
Definition: mps_setup.py:85
createfilelist.int
int
Definition: createfilelist.py:10
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66