Changeset 32777
- Timestamp:
- Nov 23, 2011, 8:49:00 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/metrics.py (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/metrics.py
r32587 r32777 1 1 import math 2 import time 2 3 import logging 3 4 import smtplib … … 10 11 from pslogger import PSLogger 11 12 from ipptopspsdb import IppToPspsDb 13 from czardb import CzarDb 12 14 from gpc1db import Gpc1Db 13 15 … … 76 78 numPending = len(pending) 77 79 78 #if stage == ' merge_worthy' and batchType == "P2":79 # for n in pending: print n80 #if stage == 'loaded_to_datastore' and batchType == "P2": 81 # for n in fail: print n 80 82 81 83 str = "\033[1;34m%5s\033[1;m \033[1;32m%5s\033[1;m \033[1;31m%5s\033[1;m " % (getIntAsString(numPending), getIntAsString(numSuccess), getIntAsString(numFail)) … … 84 86 prevList = success 85 87 print >> DATFILE, stage, numSuccess, numFail, numPending 88 89 czarDb.insertStats(stage, DVOLABEL, batchType, numPending, numSuccess, numFail) 86 90 87 91 if stage == 'processed': numPendingProcessed = numPending … … 124 128 if len(sys.argv) > 1: CONFIG = sys.argv[1] 125 129 else: 126 print "** Usage: " + sys.argv[0] + " <configPath> "130 print "** Usage: " + sys.argv[0] + " <configPath> [hours]" 127 131 sys.exit(1) 128 132 129 now = datetime.datetime.now() 133 if len(sys.argv) > 2: 134 HOURS = float(sys.argv[2]) 135 SECONDS = HOURS * 60.0 * 60.0 136 else: 137 SECONDS = None 138 139 130 140 131 141 # open config file … … 136 146 logger.setup(configDoc, "metrics") 137 147 148 # create database objects 138 149 ippToPspsDb = IppToPspsDb(logger, configDoc) 150 czarDb = CzarDb(logger, configDoc) 139 151 gpc1Db = Gpc1Db(logger, configDoc) 140 141 MINRA = None142 MAXRA = None143 MINDEC = None144 MAXDEC = None145 152 146 153 DVOLABEL = configDoc.find("dvo/gpc1Label").text 147 154 EPOCH = configDoc.find("options/epoch").text 148 155 149 logger.infoTitle("ippToPsps loading summary") 150 logger.infoPair("Time now", now.strftime("%Y-%m-%d %H:%M:%S")) 151 logger.infoPair("Loading epoch", EPOCH) 152 logger.infoPair("DVO label", DVOLABEL) 153 154 try: 155 MINRA = float(configDoc.find("dvo/minRA").text) 156 MAXRA = float(configDoc.find("dvo/maxRA").text) 157 MINDEC = float(configDoc.find("dvo/minDec").text) 158 MAXDEC = float(configDoc.find("dvo/maxDec").text) 159 logger.infoPair("Coordinates", "%.1f to %.1f RA, %.1f to %.1f Dec" % (MINRA, MAXRA, MINDEC, MAXDEC)) 160 except: 161 pass 156 while True: 157 158 logger.infoTitle("ippToPsps loading summary") 159 now = datetime.datetime.now() 160 logger.infoPair("Time now", now.strftime("%Y-%m-%d %H:%M:%S")) 161 logger.infoPair("Loading epoch", EPOCH) 162 logger.infoPair("DVO label", DVOLABEL) 163 164 # get equatorial coord constraints, if any 165 MINRA = None 166 MAXRA = None 167 MINDEC = None 168 MAXDEC = None 169 170 try: 171 MINRA = float(configDoc.find("dvo/minRA").text) 172 MAXRA = float(configDoc.find("dvo/maxRA").text) 173 MINDEC = float(configDoc.find("dvo/minDec").text) 174 MAXDEC = float(configDoc.find("dvo/maxDec").text) 175 logger.infoPair("Coordinates", "%.1f to %.1f RA, %.1f to %.1f Dec" % (MINRA, MAXRA, MINDEC, MAXDEC)) 176 except: 177 pass 162 178 163 179 164 logger.info("+----+------------------+---------------+-------------------+------------------+----------------+") 165 logger.info("|Type| batches per hour | last 24 hours | per day this week | total detections | last published |") 166 logger.info("+----+------------------+---------------+-------------------+------------------+----------------+") 167 rateP2 = printStats("P2") 168 rateST = printStats("ST") 169 logger.info("+----+------------------+---------------+-------------------+------------------+----------------+") 170 171 logger.info("") 172 173 stages = ippToPspsDb.getStages() 174 colCount = len(stages) 175 writetableSeparator(colCount) 176 sys.stdout.write("|Type| DVO ") 177 for stage in stages: sys.stdout.write("|%19s" % stage) 178 sys.stdout.write("|\n") 179 sys.stdout.write("| | ") 180 for stage in stages: sys.stdout.write("| Pend Succ Fail ") 181 sys.stdout.write("|\n") 182 writetableSeparator(colCount) 183 pendP2Processed = printTableRow(stages, "P2") 184 pendSTProcessed = printTableRow(stages, "ST") 185 writetableSeparator(colCount) 186 187 logger.info("") 188 try: logger.infoPair("Estimated time for P2s", "%.1f hours" % (pendP2Processed / rateP2)) 189 except: pass 190 try: logger.infoPair("Estimated time for STs", "%.1f hours" % (pendSTProcessed / rateST)) 191 except: pass 180 logger.info("+----+------------------+---------------+-------------------+------------------+----------------+") 181 logger.info("|Type| batches per hour | last 24 hours | per day this week | total detections | last published |") 182 logger.info("+----+------------------+---------------+-------------------+------------------+----------------+") 183 rateP2 = printStats("P2") 184 rateST = printStats("ST") 185 logger.info("+----+------------------+---------------+-------------------+------------------+----------------+") 186 187 logger.info("") 188 189 stages = ippToPspsDb.getStages() 190 colCount = len(stages) 191 writetableSeparator(colCount) 192 sys.stdout.write("|Type| DVO ") 193 194 for stage in stages: sys.stdout.write("|%19s" % stage) 195 sys.stdout.write("|\n") 196 sys.stdout.write("| | ") 197 for stage in stages: sys.stdout.write("| Pend Succ Fail ") 198 sys.stdout.write("|\n") 199 writetableSeparator(colCount) 200 pendP2Processed = printTableRow(stages, "P2") 201 pendSTProcessed = printTableRow(stages, "ST") 202 writetableSeparator(colCount) 203 204 logger.info("") 205 try: logger.infoPair("Estimated time for P2s", "%.1f hours" % (pendP2Processed / rateP2)) 206 except: pass 207 try: logger.infoPair("Estimated time for STs", "%.1f hours" % (pendSTProcessed / rateST)) 208 except: pass 209 210 if SECONDS: 211 logger.infoPair("Waiting for", "%f hours" % HOURS) 212 time.sleep(SECONDS) 213 else: break 214 215
Note:
See TracChangeset
for help on using the changeset viewer.
