Changeset 35097 for trunk/ippToPsps/jython/loader.py
- Timestamp:
- Feb 6, 2013, 3:16:35 PM (13 years ago)
- Location:
- trunk/ippToPsps
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps
- Property svn:mergeinfo changed
-
trunk/ippToPsps/jython
- Property svn:ignore
-
old new 1 1 *.class 2 Makefile 3 Makefile.in
-
- Property svn:ignore
-
trunk/ippToPsps/jython/loader.py
r34661 r35097 34 34 super(Loader, self).__init__(argv, 1, 1) 35 35 36 # create gpc1 database objects 36 if self.skychunk.parallel: 37 print "PARALLEL dvo" 38 else: 39 print "SERIAL dvo" 40 41 # connect to the gpc1 database 37 42 self.gpc1Db = Gpc1Db(self.logger, self.config) 38 43 39 44 # connect to scratch database 40 scratchDbs = [' ipptopsps_scratch', 'ipptopsps_scratch2', 'ipptopsps_scratch3']41 for db Namein scratchDbs:42 self.scratchDb = ScratchDb(self.logger, self.config, db Name)43 if self.scratchDb.anyOtherConnections():44 self.logger.errorPair("This scratch Db is already in use", dbName)45 scratchDbs = ['1', '2', '3'] 46 for dbVersion in scratchDbs: 47 self.scratchDb = ScratchDb(self.logger, self.config, dbVersion) 48 if not self.config.test and self.scratchDb.anyOtherConnections(): 49 self.logger.errorPair("This scratch Db is already in use", self.scratchDb.dbName) 45 50 self.scratchDb.disconnect() 46 51 continue … … 52 57 53 58 # create Datastore objects 54 self.datastore = Datastore(self.logger, self. config, self.ippToPspsDb)59 self.datastore = Datastore(self.logger, self.skychunk, self.ippToPspsDb) 55 60 56 61 # if an IN batch is requested, create and quit … … 60 65 batch = InitBatch(self.logger, 61 66 self.config, 67 self.skychunk, 62 68 self.gpc1Db, 63 69 self.ippToPspsDb, … … 72 78 73 79 80 # if the 'once' option is passed, we do not loop multiple times in 'run' 81 self.onePassOnly = 0 82 if len(sys.argv) > 2 and sys.argv[2] == "once": 83 self.onePassOnly = 1 84 74 85 # set a poll time of about 1 minute 75 86 self.parsePollTimeArg("0.0166") 76 87 77 self. config.printAll()88 self.skychunk.printAll() 78 89 79 90 ''' 80 91 Overrides base-class version so we can ensure our scratch Db is using the right DVO Db 81 92 ''' 82 def refresh Config(self):83 84 ret = super(Loader, self).refresh Config()93 def refreshSkychunk(self): 94 95 ret = super(Loader, self).refreshSkychunk() 85 96 try: self.scratchDb 86 97 except: return ret 87 98 88 self.dvoDetections = DvoDetections(self.logger, self.config, self.s cratchDb.dbName)99 self.dvoDetections = DvoDetections(self.logger, self.config, self.skychunk, self.ippToPspsDb, self.scratchDb.dbName) 89 100 90 101 return ret 91 102 92 103 ''' 93 Overrides base_class version so we can break out of processing loops if the configchanges104 Overrides base_class version so we can break out of processing loops if the skychunk changes 94 105 ''' 95 106 def checkClientStatus(self): 96 107 97 old ConfigName = self.config.name108 oldSkychunkName = self.skychunk.name 98 109 super(Loader, self).checkClientStatus() 99 if old ConfigName != self.config.name:100 self.logger.infoPair(" Config changed", "from '" + oldConfigName + "' to '" + self.config.name + "'")101 self. config.printAll()110 if oldSkychunkName != self.skychunk.name: 111 self.logger.infoPair("Skychunk changed", "from '" + oldSkychunkName + "' to '" + self.skychunk.name + "'") 112 self.skychunk.printAll() 102 113 return False 103 114 … … 115 126 116 127 abort = False 117 for batchType in self. config.batchTypes:128 for batchType in self.skychunk.batchTypes: 118 129 119 130 # get a stripe's worth of box IDs … … 141 152 ids = self.ippToPspsDb.getPendingIdsForThisBox(boxId, batchType) 142 153 154 # ids are the stage_ids for items to be processed (eg, stack_id for a stack CMF, cam_id for P2 smf) 155 143 156 if len(ids) < 1: 144 157 self.logger.debugPair("No " + batchType + " items found in this box", "skipping") … … 149 162 self.logger.infoPair("Box dimensions", "%.1f / %.1f / %.1f" % (boxDim['RA'], boxDim['DEC'], boxDim['SIDE'])) 150 163 self.logger.infoPair(batchType + " items found in this box", "%d" % len(ids)) 151 boxSizeWithBorder = boxDim['SIDE'] + (self.config.BORDER * 2) 164 boxSizeWithBorder = boxDim['SIDE'] + (self.skychunk.BORDER * 2) 165 boxSizeSansBorder = boxDim['SIDE'] 152 166 self.logger.infoPair("got here", "ok") 153 167 useFullTables = 0 154 168 if batchType != "OB": 155 # look in DVO for this box (with extra border) 156 self.logger.infoPair("Querying DVO for this sky area", "") 157 self.dvoDetections.setSkyAreaAsBox(boxDim['RA'], boxDim['DEC'], boxSizeWithBorder) 158 #self.dvoDetections.setSkyArea() 159 sizeToBeIngested = self.dvoDetections.getDiskSizeOfRegionsToBeIngested() 160 if sizeToBeIngested == 0.0: smfsPerGB = 999999999 161 else: smfsPerGB = len(ids)/sizeToBeIngested 162 self.logger.infoPair("DVO to be ingested", "%.1f GB" % sizeToBeIngested) 163 self.logger.infoPair("smfs-per-GB", "%.1f" % smfsPerGB) 164 # should do we pre-ingest stuff from DVO? 165 if batchType == 'P2' and smfsPerGB > 30: 166 if not self.dvoDetections.sync(): 167 self.logger.errorPair("Could not sync DVO with MySQL", "skipping") 168 continue 169 169 170 if (self.dvoDetections.useStilts): 171 # look in DVO for this box (with extra border) 172 self.logger.infoPair("Querying DVO for this sky area", "") 173 self.dvoDetections.setSkyAreaAsBox(boxDim['RA'], boxDim['DEC'], boxSizeWithBorder) 174 #self.dvoDetections.setSkyArea() 175 sizeToBeIngested = self.dvoDetections.getDiskSizeOfRegionsToBeIngested() 176 if sizeToBeIngested == 0.0: smfsPerGB = 999999999 177 else: smfsPerGB = len(ids)/sizeToBeIngested 178 self.logger.infoPair("DVO to be ingested", "%7.1e GB" % sizeToBeIngested) 179 self.logger.infoPair("smfs-per-GB", "%.1f" % smfsPerGB) 180 181 # should do we pre-ingest stuff from DVO? 182 # NOTE EAM : this skychunk loads the dvo detections into the mysql db 183 # XXXX EAM : this should happen for both P2 and Stack detection 184 # XXXX EAM : in parallel model, this should happen for all P2 & Stack batches 185 # 186 if (batchType == 'P2' or batchType == 'ST') and smfsPerGB > 30: 187 if not self.dvoDetections.sync(): 188 self.logger.errorPair("Could not sync DVO with MySQL", "skipping") 189 continue 190 191 useFullTables = 1 192 else: 193 # XXX EAM : this is not currently an 194 # option. either remove the non-native 195 # ingest code or make it an option 196 # if we are using the native loader, always use it 197 # need to work out a good boundary / region strategy in coordination with 198 # impact of mysql insertion 199 if not self.ippToPspsDb.isBoxIngested(boxId): 200 self.dvoDetections.nativeIngestDetections(boxId, boxDim['RA'], boxDim['DEC'], boxSizeSansBorder) 201 170 202 useFullTables = 1 171 203 204 ## else: 205 ## # if we are using the native loader, always use it 206 ## # need to work out a good boundary / region strategy in coordination with 207 ## # impact of mysql insertion 208 ## self.dvoObjects.nativeIngestObjects(boxDim['RA'], boxDim['DEC'], boxSizeSansBorder) 209 ## useFullTables = 1 210 211 ''' 212 NOTE EAM : "TheseItems" refers to each of the stack CMFs, camera SMFs, or object batches 213 ''' 172 214 self.logger.infoBool("Using pre-ingested DVO data?", useFullTables) 173 215 if not self.processTheseItems(batchType, ids, useFullTables): … … 175 217 break 176 218 self.logger.infoPair("processed","ok") 219 177 220 if abort or not self.checkClientStatus(): abort = True 178 221 elif numAttempts > 1 and not self.waitForPollTime(): break 179 222 223 if self.onePassOnly: self.exitProgram("one pass completed") 180 224 181 225 ''' … … 210 254 batch = DetectionBatch(self.logger, 211 255 self.config, 256 self.skychunk, 212 257 self.gpc1Db, 213 258 self.ippToPspsDb, … … 219 264 batch = StackBatch(self.logger, 220 265 self.config, 266 self.skychunk, 221 267 self.gpc1Db, 222 268 self.ippToPspsDb, … … 229 275 batch = ObjectBatch(self.logger, 230 276 self.config, 277 self.skychunk, 231 278 self.gpc1Db, 232 279 self.ippToPspsDb, … … 260 307 ''' 261 308 def printUsage(self): 262 super( Cleanup, self).printUsage("<[init]>")309 super(Loader, self).printUsage("<[init]>") 263 310 264 311
Note:
See TracChangeset
for help on using the changeset viewer.
