Changeset 32354 for trunk/ippToPsps
- Timestamp:
- Sep 6, 2011, 1:37:06 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/metrics.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/metrics.py
r32294 r32354 4 4 import sys 5 5 import os 6 import datetime 6 7 7 8 from xml.etree.ElementTree import ElementTree, Element, tostring … … 39 40 40 41 ''' 41 Prepares a string of the format: 42 43 n-processed(n-pending) 44 42 Formats an int to a string 45 43 ''' 46 def prepareStr(masterList, prevList, thisList, FILE, name): 47 48 unsuccessful = list(set(prevList) - set(thisList)) 49 50 countTotal = len(masterList) 51 countSuccessful = len(thisList) 52 countUnsuccessful = len(unsuccessful) 53 54 str = "%d" % countSuccessful 55 if countUnsuccessful: str = str + "(%d)" % countUnsuccessful 56 57 print >> FILE, name, countSuccessful, countUnsuccessful, (countTotal - countSuccessful - countUnsuccessful) 58 #;sys.stdout.softspace=0; 59 return str 44 def getIntAsString(value): 45 if value == 0: return "" 46 return str(value) 60 47 61 48 ''' 62 49 Prints (to the log) one row of data (one row being one batch-type) 63 50 ''' 64 def printTableRow( batchType):51 def printTableRow(stages, batchType): 65 52 53 # get a master list of IDs in DVO for this batch type 66 54 allIDs = gpc1Db.getIDsInThisDVODbForThisStage(DVOLABEL, batchType) 67 processedIDs = ippToPspsDb.getProcessedIDs(batchType, EPOCH, DVOLABEL) 68 datastoreIDs = ippToPspsDb.getloadedToDatastoreIDs(batchType, EPOCH, DVOLABEL) 69 loadedToODMIDs = ippToPspsDb.getLoadedToODMIDs(batchType, EPOCH, DVOLABEL) 70 mergeWorthyIDs = ippToPspsDb.getMergeWorthyIDs(batchType, EPOCH, DVOLABEL) 71 mergedIDs = ippToPspsDb.getMergedIDs(batchType, EPOCH, DVOLABEL) 55 prevList = allIDs 56 numEverything = len(allIDs) 57 58 sys.stdout.write("| %2s |%6d " % (batchType, numEverything)) 72 59 73 60 tempFilename = batchType + '.dat' 74 61 DATFILE = open(tempFilename,'w') 75 prepareStr(allIDs, allIDs, allIDs, DATFILE, "inDVO"), 62 print >> DATFILE, "DVO", numEverything, 0, 0 63 for stage in stages: 76 64 77 logger.info("| %2s | %-12d | %-12s | %-12s | %-12s | %-12s | %-12s | %-12s | %-19s |" % ( 78 batchType, 79 len(allIDs), 80 prepareStr(allIDs, allIDs, processedIDs, DATFILE, "processed"), 81 prepareStr(allIDs, processedIDs, datastoreIDs, DATFILE, "onDatastore"), 82 prepareStr(allIDs, datastoreIDs, loadedToODMIDs, DATFILE, "loadedToODM"), 83 prepareStr(allIDs, loadedToODMIDs, mergeWorthyIDs, DATFILE, "MergeWorthy"), 84 prepareStr(allIDs, mergeWorthyIDs, mergedIDs, DATFILE, "Merged"), 85 len(list(set(allIDs) - set(mergedIDs))), 86 ippToPspsDb.getTimeOfLastBatchPublished(batchType, EPOCH, DVOLABEL))) 65 # get lists. Use unions with prev list to make sure the right stuff is included 66 success = list(set(ippToPspsDb.getStageIDs(batchType, EPOCH, DVOLABEL, stage, 1)) & set(prevList)) 67 fail = list(set(ippToPspsDb.getStageIDs(batchType, EPOCH, DVOLABEL, stage, -1)) & set(prevList) - set(success)) 68 pending = list(set(prevList) - set(success) - set(fail)) 87 69 70 # count stuff 71 numSuccess = len(success) 72 numFail = len(fail) 73 numPending = len(pending) 74 75 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)) 76 sys.stdout.write("|%-19s" % str) 77 78 prevList = success 79 print >> DATFILE, stage, numSuccess, numFail, numPending 80 81 sys.stdout.write("|\n") 88 82 plotMe(batchType, tempFilename) 89 83 DATFILE.close() 90 #os.remove(tempFilename)91 84 92 unprocessedIDs = list(set(allIDs) - set(processedIDs)) 93 if len(unprocessedIDs) > 0: 94 UNPROCESSEDFILE = open("unprocessed" + DVOLABEL + "_" + batchType,'w') 95 for id in unprocessedIDs: print >> UNPROCESSEDFILE, id 96 UNPROCESSEDFILE.close() 85 ''' 86 Writes table separator 87 ''' 88 def writetableSeparator(colCount): 89 90 sys.stdout.write("+----+-------") 91 for i in range(0, colCount): sys.stdout.write("+-------------------") 92 sys.stdout.write("+\n") 97 93 98 94 ''' … … 103 99 print "** Usage: " + sys.argv[0] + " <configPath>" 104 100 sys.exit(1) 101 102 now = datetime.datetime.now() 105 103 106 104 # open config file … … 118 116 119 117 logger.infoTitle("ippToPsps loading summary") 118 logger.infoPair("Time now", now.strftime("%Y-%m-%d %H:%M:%S")) 120 119 logger.infoPair("Loading epoch", EPOCH) 121 120 logger.infoPair("DVO label", DVOLABEL) 121 logger.infoPair("P2 batches per hour", "%.1f" % ippToPspsDb.getBatchesPerHour("P2", EPOCH, DVOLABEL, 2)) 122 logger.infoPair("ST batches per hour", "%.1f" % ippToPspsDb.getBatchesPerHour("ST", EPOCH, DVOLABEL, 2)) 123 logger.infoPair("Last P2 batch published", ippToPspsDb.getTimeOfLastBatchPublished("P2", EPOCH, DVOLABEL)) 124 logger.infoPair("Last ST batch published", ippToPspsDb.getTimeOfLastBatchPublished("ST", EPOCH, DVOLABEL)) 122 125 logger.info("") 123 logger.info("+------+----------------+----------------+----------------+----------------+----------------+----------------+----------------+----------------------+")124 logger.info("| Type | Total in DVO | Processed | On datastore | Loaded to ODM | Merge-worthy | Merged | Total missing | Last published |")125 logger.info("+------+----------------+----------------+----------------+----------------+----------------+----------------+----------------+----------------------+")126 printTableRow("P2")127 printTableRow("ST")128 logger.info("+------+----------------+----------------+----------------+----------------+----------------+----------------+----------------+----------------------+")129 126 127 stages = ippToPspsDb.getStages() 128 colCount = len(stages) 129 writetableSeparator(colCount) 130 sys.stdout.write("|Type| DVO ") 131 for stage in stages: sys.stdout.write("|%19s" % stage) 132 sys.stdout.write("|\n") 133 sys.stdout.write("| | ") 134 for stage in stages: sys.stdout.write("| Pend Succ Fail ") 135 sys.stdout.write("|\n") 136 writetableSeparator(colCount) 137 printTableRow(stages, "P2") 138 printTableRow(stages, "ST") 139 writetableSeparator(colCount) 130 140 131
Note:
See TracChangeset
for help on using the changeset viewer.
