IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33673


Ignore:
Timestamp:
Apr 3, 2012, 4:25:23 PM (14 years ago)
Author:
rhenders
Message:

removed unnecessary config args to ippToPspsDb methods; all metrics data now taken from IppToPsps database rather than gpc1

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps/jython/metrics.py

    r33494 r33673  
    99from ipptopsps import IppToPsps
    1010from czardb import CzarDb
    11 from gpc1db import Gpc1Db
    1211from plot import Plot
    1312
     
    2524        if len(sys.argv) > 2: self.parsePollTimeArg(sys.argv[2])
    2625   
    27         # create database objects
    2826        self.czarDb = CzarDb(self.logger, self.config)
    29         self.gpc1Db = Gpc1Db(self.logger, self.config)
    3027        self.plot = Plot(self.logger, self.config, self.ippToPspsDb)
    3128   
     
    4946            rateP2 = self.printStats("P2")
    5047            rateST = self.printStats("ST")
     48            rateOB = self.printStats("OB")
    5149            self.logger.info("+----+------------------+---------------+-------------------+------------------+----------------+")
    5250       
     
    5654            colCount = len(stages)
    5755            self.writeTableSeparator(colCount)
    58             sys.stdout.write("|Type|  DVO  ")
     56            sys.stdout.write("|Type")
    5957       
    6058            for stage in stages: sys.stdout.write("|%19s" % stage)
    6159            sys.stdout.write("|\n")
    62             sys.stdout.write("|    |       ")
     60            sys.stdout.write("|    ")
    6361            for stage in stages: sys.stdout.write("| Pend  Succ  Fail  ")
    6462            sys.stdout.write("|\n")
     
    6664            pendP2Processed = self.printTableRow(stages, "P2")
    6765            pendSTProcessed = self.printTableRow(stages, "ST")
     66            pendOBProcessed = self.printTableRow(stages, "OB")
    6867            self.writeTableSeparator(colCount)
    6968
     
    7372            try: self.logger.infoPair("Estimated time for STs", "%.1f hours" % (pendSTProcessed / rateST))
    7473            except: pass
     74            try: self.logger.infoPair("Estimated time for OBs", "%.1f hours" % (pendOBProcessed / rateOB))
     75            except: pass
    7576       
    7677            self.checkClientStatus()
     
    7980            self.plot.createDensityPlot("P2", True)
    8081            self.plot.createDensityPlot("ST", True)
     82            self.plot.createDensityPlot("OB", True)
    8183
     84            # some clean-up before going to sleep
     85            self.ippToPspsDb.purgeDeadClients()
    8286            if not self.waitForPollTime(): break
    8387
     
    9599    def printTableRow(self, stages, batchType):
    96100   
    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)
    104102
    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
    119106        for stage in stages:
    120107   
    121108           # 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))
    125116   
    126117           # count stuff
     
    140131           prevList = success
    141132   
    142            self.czarDb.insertStats(stage, self.config.dvoLabel, batchType, numPending, numSuccess, numFail)
     133           self.czarDb.insertStats(stage, self.config.name, batchType, numPending, numSuccess, numFail)
    143134   
    144135           if stage == 'processed': numPendingProcessed = numPending
    145136   
     137           firstStage = False
     138
    146139        sys.stdout.write("|\n")
    147140   
     
    153146    def writeTableSeparator(self, colCount):
    154147   
    155         sys.stdout.write("+----+-------")
     148        sys.stdout.write("+----")
    156149        for i in range(0, colCount): sys.stdout.write("+-------------------")
    157150        sys.stdout.write("+\n")
     
    169162    def printStats(self, batchType):
    170163   
    171         rate = self.ippToPspsDb.countBatches(batchType, self.config.epoch, self.config.dvoLabel, "1 HOUR") / 1.0
     164        rate = self.ippToPspsDb.countBatches(batchType, "1 HOUR") / 1.0
    172165   
    173166
    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")
    176169
    177170        self.logger.info("| %2s | %16.1f | %13d | %17.1f | %16d | %14s |" %
     
    179172                 rate,
    180173                 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,
    182175                 self.divide(detectionsInLast24Hours, batchesInLast24Hours),
    183                  self.ippToPspsDb.getTimeOfLastBatchPublished(batchType, self.config.epoch, self.config.dvoLabel)))
     176                 self.ippToPspsDb.getTimeOfLastBatchPublished(batchType)))
    184177   
    185178        return rate
Note: See TracChangeset for help on using the changeset viewer.