IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 12, 2015, 12:24:24 PM (12 years ago)
Author:
eugene
Message:

various updates merged from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-pv3-20140717-merge/ippToPsps/jython/loader.py

    r36709 r37820  
    2424from objectbatch import ObjectBatch
    2525
     26from diffbatch import DiffBatch
     27from diffobjectbatch import DiffObjectBatch
     28
     29#from forcedwarpbatch import ForcedWarpBatch
     30#from forcedobjectbatch import ForcedObjectBatch
     31#
     32#
    2633'''
    2734Loader class
     
    7885           self.onePassOnly = 1
    7986
    80         # set a poll time of about 1 minute
    81         self.parsePollTimeArg("0.0166")
     87        if self.config.loopBatch:
     88            self.parsePollTimeArg("0.0166")
     89        else:
     90            self.parsePollTimeArg("0.0")
    8291
    8392        self.skychunk.printAll()
     
    160169                    self.logger.infoPair(batchType + " items found in this box", "%d" % len(ids))
    161170
    162                     useFullTables = 0
    163171                    if batchType != "OB":
    164 
    165                         if (self.dvoDetections.useStilts):
    166                             # look in DVO for this box (with extra border)
    167                             self.logger.infoPair("Querying DVO for this sky area", "")
    168 
    169                             # XXXX EAM : This code should not be used anymore
    170                             boxSize = 0.0
    171                             self.dvoDetections.setSkyAreaAsBox(boxDim['RA'], boxDim['DEC'], boxSize)
    172                             #self.dvoDetections.setSkyArea()
    173                             sizeToBeIngested = self.dvoDetections.getDiskSizeOfRegionsToBeIngested()
    174                             if sizeToBeIngested == 0.0: smfsPerGB = 999999999
    175                             else: smfsPerGB = len(ids)/sizeToBeIngested
    176                             self.logger.infoPair("DVO to be ingested", "%7.1e GB" % sizeToBeIngested)
    177                             self.logger.infoPair("smfs-per-GB", "%.1f" % smfsPerGB)
    178 
    179                             # should do we pre-ingest stuff from DVO?
    180                             # NOTE EAM : this skychunk loads the dvo detections into the mysql db
    181                             # XXXX EAM : this should happen for both P2 and Stack detection
    182                             # XXXX EAM : in parallel model, this should happen for all P2 & Stack batches
    183                             #
    184                             if (batchType == 'P2' or batchType == 'ST' or batchType == 'DF' or batchType == 'FW') and smfsPerGB > 30:
    185                                 if not self.dvoDetections.sync():
    186                                     self.logger.errorPair("Could not sync DVO with MySQL", "skipping")
    187                                     continue
    188                                
    189                                 useFullTables = 1
    190                         else:
    191                             # XXX EAM : this is not currently optional
    192                             # (it is the only path). either remove the
    193                             # non-native ingest code or make it an
    194                             # option if we are using the native
    195                             # loader, always use it need to work out a
    196                             # good boundary / region strategy in
    197                             # coordination with impact of mysql
    198                             # insertion
    199                             if not self.ippToPspsDb.isBoxIngested(boxId, self.scratchDb.dbHost):
    200                                 if not self.dvoDetections.nativeIngestDetections(boxId, boxDim):
    201                                     self.logger.error("Unable to ingest detections with nativeIngest")
    202                                     return False
    203 
    204                             useFullTables = 1
    205                
    206                     ## else:
    207                     ##     # if we are using the native loader, always use it
    208                     ##     # need to work out a good boundary / region strategy in coordination with
    209                     ##     # impact of mysql insertion
    210                     ##     self.dvoObjects.nativeIngestObjects(boxDim['RA'], boxDim['DEC'], boxSizeSansBorder)
    211                     ##     useFullTables = 1
     172                        if self.config.resetDvo or not self.ippToPspsDb.isBoxIngested(boxId, self.scratchDb.dbHost):
     173                            if not self.dvoDetections.nativeIngestDetections(boxId, boxDim):
     174                                self.logger.error("Unable to ingest detections with nativeIngest")
     175                                return False
    212176
    213177                    '''
    214178                    NOTE EAM : "TheseItems" refers to each of the stack CMFs, camera SMFs, or object batches
    215179                    '''
    216                     self.logger.infoBool("Using pre-ingested DVO data?", useFullTables)
    217                     if not self.processTheseItems(batchType, ids, useFullTables):
     180                    if not self.processTheseItems(batchType, ids):
    218181                        abort = True
    219182                        break
    220183                    self.logger.infoPair("processed","ok")
    221184
     185            self.logger.infoPair("done with processing boxes, numAttempts: ", str(numAttempts))
    222186            if abort or not self.checkClientStatus(): abort = True
    223187            elif numAttempts > 1 and not self.waitForPollTime():  break
     
    228192    Actually loops through items and processes them
    229193    '''
    230     def processTheseItems(self, batchType, ids, useFullTables):
     194    def processTheseItems(self, batchType, ids):
    231195   
    232196        self.logger.infoPair("%s items queued" % batchType, "%d" % len(ids))
     
    234198        # loop round IDs of all items to be processed
    235199        self.ippToPspsDb.lockBatchTable()
    236         #self.logger.infoPair("heather:","lockbatchtable")
     200        self.logger.infoPair("heather:","lockbatchtable")
    237201        unattemptedCount = 0
    238202        for id in ids:
    239             #self.logger.infoPair("heather:","in ids")
     203            self.logger.infoPair("heather:","in ids")
    240204            #self.logger.infoPair("heather:id",str(id))
    241205            batchID = self.ippToPspsDb.createNewBatch(batchType, id)
     
    245209                unattemptedCount += 1
    246210                continue
    247             #self.logger.infoPair("heather:","passed logic")
     211            self.logger.infoPair("heather:","passed logic")
     212
    248213            self.ippToPspsDb.unlockTables()
    249214            #self.logger.infoPair("heather:","unlock table")
     215
    250216            self.ippToPspsDb.deletePendingItem(batchType, id)
    251217            #self.logger.infoPair("heather:","deleted pending item")
     
    262228                            self.scratchDb,
    263229                            id,
    264                             batchID,
    265                             useFullTables)
     230                            batchID)
    266231                elif batchType == "ST":
    267232                    self.logger.infoPair("defining ST batch for sky_id:",id)
     
    273238                            self.scratchDb,
    274239                            id,
    275                             batchID,
    276                             useFullTables)
     240                            batchID)
    277241   
    278242                elif batchType == "OB":
     
    284248                            self.scratchDb,
    285249                            id,
    286                             batchID,
    287                             useFullTables)
     250                            batchID)
    288251   
    289252                elif batchType == "DF":
     253                    self.logger.infoPair("wegothere!","we are awesome")
    290254                    batch = DiffBatch(self.logger,
    291255                            self.config,
     
    295259                            self.scratchDb,
    296260                            id,
    297                             batchID,
    298                             useFullTables)
     261                            batchID)
    299262   
    300263                elif batchType == "DO":
     
    306269                            self.scratchDb,
    307270                            id,
    308                             batchID,
    309                             useFullTables)
     271                            batchID)
    310272   
    311273                elif batchType == "FW":
     
    317279                            self.scratchDb,
    318280                            id,
    319                             batchID,
    320                             useFullTables)
     281                            batchID)
    321282   
    322283                elif batchType == "FO":
     
    328289                            self.scratchDb,
    329290                            id,
    330                             batchID,
    331                             useFullTables)
     291                            batchID)
    332292                   
    333293                batch.run()
     
    337297                self.logger.error("EXCEPTION: " + str(e))
    338298                self.logger.errorPair("Problem with this %s batch (%d)" % (batchType, id), "skipping")
     299                sys.exit(1)
    339300                pass
    340301
Note: See TracChangeset for help on using the changeset viewer.