Changeset 33237 for trunk/ippToPsps/jython/load.py
- Timestamp:
- Feb 10, 2012, 1:43:48 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/ippToPsps/jython/load.py (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps/jython/load.py
r33191 r33237 17 17 from datastore import Datastore 18 18 from batch import Batch 19 from dvo import Dvo 19 20 20 21 from initbatch import InitBatch … … 40 41 41 42 ''' 42 Queues up all available stuff for this batch type 43 ''' 44 def queueItems (batchType):43 Queues up all available stuff for this batch type in a box with these dimensions 44 ''' 45 def queueItemsInBox(batchType, ra, dec, boxsize): 45 46 46 47 logger.infoTitle("Queuing " + batchType + " items") 48 logger.infoPair("Box center and size", "%f/%f/%f" %(ra, dec, boxsize)) 47 49 48 50 allIDs = [] … … 60 62 else: 61 63 62 allIDs = gpc1Db.getIDsInThisDVODbForThisStage (64 allIDs = gpc1Db.getIDsInThisDVODbForThisStageInThisBox( 63 65 DVOGPC1LABEL, 64 66 batchType, 65 MINRA, 66 MAXRA, 67 MINDEC, 68 MAXDEC) 67 ra, 68 dec, 69 boxsize) 69 70 70 71 logger.infoPair("All %s items in DVO" % batchType, "%d" % len(allIDs)) … … 81 82 logger.infoPair("Consistently failing items", "%d" % len(consistaentlyFailedIDs)) 82 83 logger.infoPair("Unprocessed items", "%d" % len(ids)) 84 85 return ids 86 87 88 ''' 89 Actually loops through items and processes them 90 ''' 91 def processTheseItems(batchType, ids, useFullTables): 83 92 84 93 logger.infoPair("%s items queued" % batchType, "%d" % len(ids)) … … 108 117 ippToPspsDb, 109 118 id, 110 batchID) 119 batchID, 120 useFullTables) 111 121 elif batchType == "ST": 112 122 batch = StackBatch(logger, … … 116 126 ippToPspsDb, 117 127 id, 118 batchID) 128 batchID, 129 useFullTables) 119 130 120 131 batch.run() … … 132 143 Start of program. 133 144 ''' 134 135 145 if len(sys.argv) > 1: CONFIG = sys.argv[1] 136 146 else: … … 156 166 157 167 # if in test mode, print log to screen, otherwise, only to file 158 logger.setup(configDoc, "ippToPsps", TEST, not TEST, HOST, PID) 159 160 # create database objects 168 #logger.setup(configDoc, "ippToPsps", TEST, not TEST, HOST, PID) TODO put back 169 logger.setup(configDoc, "ippToPsps") 170 171 # create various objects 172 dvo = Dvo(logger, configDoc) 161 173 gpc1Db = Gpc1Db(logger, configDoc) 162 174 ippToPspsDb = IppToPspsDb(logger, configDoc) … … 174 186 PUBLISH = int(configDoc.find("options/publishToDatastore").text) 175 187 BASEPATH = configDoc.find("localOutPath").text 176 QUEUE_P2 = int(configDoc.find("options/queueP2").text)177 QUEUE_ST = int(configDoc.find("options/queueST").text)178 188 SURVEY = configDoc.find("options/survey").text 179 189 190 # get batch types from config 191 batchTypes = [] 192 if int(configDoc.find("options/queueP2").text) == 1: batchTypes.append("P2") 193 if int(configDoc.find("options/queueST").text) == 1: batchTypes.append("ST") 194 180 195 # get equatorial coord limits, if any 181 try: 182 MINRA = float(configDoc.find("dvo/minRA").text) 183 MAXRA = float(configDoc.find("dvo/maxRA").text)184 MINDEC = float(configDoc.find("dvo/minDec").text) 185 MAXDEC = float(configDoc.find("dvo/maxDec").text)186 except: 187 MINRA = 0.0 188 MAXRA = 360.0189 MINDEC = -30.0 190 MAXDEC = 90.0196 try: MINRA = float(configDoc.find("dvo/minRA").text) 197 except: MINRA = 0.0 198 try: MAXRA = float(configDoc.find("dvo/maxRA").text) 199 except: MAXRA = 360.0 200 try: MINDEC = float(configDoc.find("dvo/minDec").text) 201 except: MINDEC = -30.0 202 try: MAXDEC = float(configDoc.find("dvo/maxDec").text) 203 except: MAXDEC = 90.0 204 try: BOXSIZE = float(configDoc.find("dvo/boxSize").text) 205 except: BOXSIZE = 4.0 191 206 192 207 # prompt user: FORCE and PUBLISH is a dangerous combination … … 206 221 logger.infoPair("Loading epoch", EPOCH) 207 222 logger.infoPair("DVO gpc1 label", DVOGPC1LABEL) 208 logger.infoBool("Queuing P2 batches?", QUEUE_P2) 209 logger.infoBool("Queuing ST batches?", QUEUE_ST) 223 for batchType in batchTypes: logger.infoPair("Queuing batch type", batchType) 210 224 logger.infoBool("Forcing?", FORCE) 211 225 logger.infoBool("Test mode?", TEST) 212 226 logger.infoBool("Publishing?", PUBLISH) 213 227 228 # if an IN batch is requested, create and quit 229 if QUEUE_IN: 230 batchID = ippToPspsDb.createNewBatch( 231 "IN", 232 0, 233 SURVEY, 234 EPOCH, 235 DVOGPC1LABEL, 236 datastore.product, 237 1) 238 if batchID > 0: 239 batch = InitBatch(logger, CONFIG, configDoc, gpc1Db, ippToPspsDb, batchID) 240 batch.run() 241 242 sys.exit(1) 243 214 244 ''' 215 245 Main processing loop: 216 246 217 1) creates an IN batch if requested 218 2) queues available P2 batches (if requested) 219 3) queues available ST batches (if requested) 220 4) if in test mode, quits 221 5) otherwise, waits then repeats from 2 222 223 ''' 247 1) queues available P2 batches (if requested) 248 2) queues available ST batches (if requested) 249 3) if in test mode, quits 250 4) else waits then repeats from 2 251 252 ''' 253 BORDER = 1.60 254 HALFBOX = BOXSIZE/2.0 255 BOXSIZEWITHBORDER = BOXSIZE + (BORDER * 2) 256 257 # this outer while loop simply waits a few minutes then starts queuing againas more stuff may appear in DVO over time 224 258 while True: 225 259 226 # queue all items for all batch types, sequentially 227 if QUEUE_IN: 228 batchID = ippToPspsDb.createNewBatch( 229 "IN", 230 0, 231 SURVEY, 232 EPOCH, 233 DVOGPC1LABEL, 234 datastore.product, 235 1) 236 if batchID > 0: 237 batch = InitBatch(logger, CONFIG, configDoc, gpc1Db, ippToPspsDb, batchID) 238 batch.run() 239 break; 260 # starting positions 261 ra = MINRA + HALFBOX 262 dec = MINDEC + HALFBOX 240 263 241 264 # queue up batches that are processed but not loaded to datastore 242 265 logger.infoTitle("Previous failed datastore loads") 243 publishAnyUnpublishedBatches("P2") 244 publishAnyUnpublishedBatches("ST") 245 246 if QUEUE_P2: queueItems("P2") 247 if QUEUE_ST: queueItems("ST") 248 249 # in the TEST mode, we quit after submitting one batch 250 if TEST: break 266 for batchType in batchTypes: publishAnyUnpublishedBatches(batchType) 267 268 # loop through full range of RA/Dec queueing stuff in boxes of size BOXSIZE 269 while ra <= MAXRA: 270 271 while dec <= MAXDEC: 272 273 # for each batch type 274 # - queue items in this box 275 # - check if we should pre-load DVO region 276 # - process the items 277 for batchType in batchTypes: 278 ids = queueItemsInBox(batchType, ra, dec, BOXSIZE) 279 280 if len(ids) < 1: 281 logger.infoPair("No items found in this region", "skipping") 282 continue 283 284 dvo.setSkyAreaAsBox(ra, dec, BOXSIZEWITHBORDER) 285 dvo.printSummary() 286 287 sizeToBeIngested = dvo.getDiskSizeOfRegionsToBeIngested() 288 if sizeToBeIngested == 0.0: smfsPerGB = 999999999 289 else: smfsPerGB = len(ids)/dvo.getDiskSizeOfRegionsToBeIngested() 290 logger.infoPair("smfs-per-GB", "%f" % smfsPerGB) 291 292 # do we pre-ingest stuff from DVO? 293 if smfsPerGB > 40: 294 if not dvo.sync(): 295 logger.errorPair("Could not sync DVO with MySQL", "skipping") 296 continue 297 298 useFullTables = 1 299 else: useFullTables = 0 300 301 logger.infoBool("Using pre-ingested DVO data?", useFullTables) 302 processTheseItems(batchType, ids, useFullTables) 303 304 # in the TEST mode, we quit after submitting one batch 305 if TEST: break 306 307 dec = dec + BOXSIZE 308 if TEST: break 309 310 dec = MINDEC + HALFBOX 311 ra = ra + BOXSIZE 312 if TEST: break 251 313 252 314 # wait for the POLLPERIOD before checking for new ids
Note:
See TracChangeset
for help on using the changeset viewer.
