Changeset 33673
- Timestamp:
- Apr 3, 2012, 4:25:23 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/metrics.py (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/metrics.py
r33494 r33673 9 9 from ipptopsps import IppToPsps 10 10 from czardb import CzarDb 11 from gpc1db import Gpc1Db12 11 from plot import Plot 13 12 … … 25 24 if len(sys.argv) > 2: self.parsePollTimeArg(sys.argv[2]) 26 25 27 # create database objects28 26 self.czarDb = CzarDb(self.logger, self.config) 29 self.gpc1Db = Gpc1Db(self.logger, self.config)30 27 self.plot = Plot(self.logger, self.config, self.ippToPspsDb) 31 28 … … 49 46 rateP2 = self.printStats("P2") 50 47 rateST = self.printStats("ST") 48 rateOB = self.printStats("OB") 51 49 self.logger.info("+----+------------------+---------------+-------------------+------------------+----------------+") 52 50 … … 56 54 colCount = len(stages) 57 55 self.writeTableSeparator(colCount) 58 sys.stdout.write("|Type | DVO")56 sys.stdout.write("|Type") 59 57 60 58 for stage in stages: sys.stdout.write("|%19s" % stage) 61 59 sys.stdout.write("|\n") 62 sys.stdout.write("| |")60 sys.stdout.write("| ") 63 61 for stage in stages: sys.stdout.write("| Pend Succ Fail ") 64 62 sys.stdout.write("|\n") … … 66 64 pendP2Processed = self.printTableRow(stages, "P2") 67 65 pendSTProcessed = self.printTableRow(stages, "ST") 66 pendOBProcessed = self.printTableRow(stages, "OB") 68 67 self.writeTableSeparator(colCount) 69 68 … … 73 72 try: self.logger.infoPair("Estimated time for STs", "%.1f hours" % (pendSTProcessed / rateST)) 74 73 except: pass 74 try: self.logger.infoPair("Estimated time for OBs", "%.1f hours" % (pendOBProcessed / rateOB)) 75 except: pass 75 76 76 77 self.checkClientStatus() … … 79 80 self.plot.createDensityPlot("P2", True) 80 81 self.plot.createDensityPlot("ST", True) 82 self.plot.createDensityPlot("OB", True) 81 83 84 # some clean-up before going to sleep 85 self.ippToPspsDb.purgeDeadClients() 82 86 if not self.waitForPollTime(): break 83 87 … … 95 99 def printTableRow(self, stages, batchType): 96 100 97 # get a master list of IDs in DVO for this batch type 98 rows = self.gpc1Db.getItemsInThisDVODbForThisStage(self.config.dvoLabel, 99 batchType, 100 self.config.minRa, 101 self.config.maxRa, 102 self.config.minDec, 103 self.config.maxDec) 101 pending = self.ippToPspsDb.getPendingIds(batchType) 104 102 105 # we only want to IDs 106 allIDs = [] 107 for row in rows: 108 try: allIDs.append(row[0]) 109 except: pass 110 111 #allIDs = self.ippToPspsDb.getPendingIdsForThisConfig(self.config.name) 112 113 prevList = allIDs 114 numEverything = len(allIDs) 115 116 sys.stdout.write("| %2s |%6d " % (batchType, numEverything)) 117 118 tempFilename = batchType + '.dat' 103 sys.stdout.write("| %2s " % (batchType)) 104 105 firstStage = True 119 106 for stage in stages: 120 107 121 108 # get lists. Use unions with prev list to make sure the right stuff is included 122 success = list(set(self.ippToPspsDb.getStageIDs(batchType, self.config.epoch, self.config.dvoLabel, stage, 1)) & set(prevList)) 123 fail = list(set(self.ippToPspsDb.getStageIDs(batchType, self.config.epoch, self.config.dvoLabel, stage, -1)) & set(prevList) - set(success)) 124 pending = list(set(prevList) - set(success) - set(fail)) 109 if firstStage: 110 success = self.ippToPspsDb.getStageIDs(batchType, stage, 1) 111 fail = list(set(self.ippToPspsDb.getStageIDs(batchType, stage, -1)) - set(success)) 112 else: 113 success = list(set(self.ippToPspsDb.getStageIDs(batchType, stage, 1)) & set(prevList)) 114 fail = list(set(self.ippToPspsDb.getStageIDs(batchType, stage, -1)) & set(prevList) - set(success)) 115 pending = list(set(prevList) - set(success) - set(fail)) 125 116 126 117 # count stuff … … 140 131 prevList = success 141 132 142 self.czarDb.insertStats(stage, self.config. dvoLabel, batchType, numPending, numSuccess, numFail)133 self.czarDb.insertStats(stage, self.config.name, batchType, numPending, numSuccess, numFail) 143 134 144 135 if stage == 'processed': numPendingProcessed = numPending 145 136 137 firstStage = False 138 146 139 sys.stdout.write("|\n") 147 140 … … 153 146 def writeTableSeparator(self, colCount): 154 147 155 sys.stdout.write("+---- +-------")148 sys.stdout.write("+----") 156 149 for i in range(0, colCount): sys.stdout.write("+-------------------") 157 150 sys.stdout.write("+\n") … … 169 162 def printStats(self, batchType): 170 163 171 rate = self.ippToPspsDb.countBatches(batchType, self.config.epoch, self.config.dvoLabel,"1 HOUR") / 1.0164 rate = self.ippToPspsDb.countBatches(batchType, "1 HOUR") / 1.0 172 165 173 166 174 batchesInLast24Hours = self.ippToPspsDb.countBatches(batchType, self.config.epoch, self.config.dvoLabel,"24 HOUR")175 detectionsInLast24Hours = self.ippToPspsDb.getTotalDetectionsPublished(batchType, self.config.epoch, self.config.dvoLabel,"24 HOUR")167 batchesInLast24Hours = self.ippToPspsDb.countBatches(batchType, "24 HOUR") 168 detectionsInLast24Hours = self.ippToPspsDb.getTotalDetectionsPublished(batchType, "24 HOUR") 176 169 177 170 self.logger.info("| %2s | %16.1f | %13d | %17.1f | %16d | %14s |" % … … 179 172 rate, 180 173 batchesInLast24Hours, 181 self.ippToPspsDb.countBatches(batchType, self.config.epoch, self.config.dvoLabel,"1 WEEK") / 7.0,174 self.ippToPspsDb.countBatches(batchType, "1 WEEK") / 7.0, 182 175 self.divide(detectionsInLast24Hours, batchesInLast24Hours), 183 self.ippToPspsDb.getTimeOfLastBatchPublished(batchType , self.config.epoch, self.config.dvoLabel)))176 self.ippToPspsDb.getTimeOfLastBatchPublished(batchType))) 184 177 185 178 return rate
Note:
See TracChangeset
for help on using the changeset viewer.
