IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 5, 2013, 2:23:09 PM (13 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20130207/ippToPsps
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130207/ippToPsps

  • branches/eam_branches/ipp-20130207/ippToPsps/jython/loader.py

    r35097 r35235  
    88import sys
    99import os
     10import math
    1011import traceback
    1112import logging.config
     
    4344
    4445        # connect to scratch database
    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)
    50                 self.scratchDb.disconnect()
    51                 continue
    52             break
    53 
    54         if not self.scratchDb.connected:
     46        self.scratchDb = ScratchDb(self.logger, self.config)
     47        if not self.config.test and self.scratchDb.anyOtherConnections():
     48            self.logger.errorPair("This scratch Db is already in use", self.scratchDb.dbName)
     49            self.scratchDb.disconnect()
    5550            self.exitProgram("Cannot connect to a scratch database")
    5651            raise
     
    9792        except: return ret
    9893           
    99         self.dvoDetections = DvoDetections(self.logger, self.config, self.skychunk, self.ippToPspsDb, self.scratchDb.dbName)
     94        self.dvoDetections = DvoDetections(self.logger, self.config, self.skychunk, self.ippToPspsDb, self.scratchDb)
    10095
    10196        return ret
     
    123118
    124119        numAttempts = 0
     120        abort = False
    125121        while True:
    126122
    127             abort = False
    128             for batchType in self.skychunk.batchTypes:
    129 
    130                 # get a stripe's worth of box IDs
    131                 boxIds = self.ippToPspsDb.getStripeBoxIds(self.HOST, self.PID, batchType)
    132 
    133                 numAttempts += 1
    134 
    135                 self.logger.infoPair("Boxes with unprocessed data", "%d" % len(boxIds))
    136                 self.logger.infoPair("numAttempts", str(numAttempts))
    137                 if len(boxIds) > 0: numAttempts = 0
    138 
    139                 for boxId in boxIds:
     123            # get a stripe's worth of box IDs
     124            boxIds = self.ippToPspsDb.getStripeBoxIdsAnyBatch(self.HOST, self.PID)
     125            self.logger.infoPair("Boxes with unprocessed data", "%d" % len(boxIds))
     126            self.logger.infoPair("numAttempts", str(numAttempts))
     127
     128            if len(boxIds) > 0: numAttempts = 0
     129            numAttempts += 1
     130
     131            for boxId in boxIds:
     132
     133                # get box info. if boxes have changed, break and start again
     134                try:
     135                    boxDim = self.ippToPspsDb.getBoxDimensions(boxId)
     136                except:
     137                    self.logger.infoPair("Can't get details for this box", "%d" % boxId)
     138                    break
     139                self.logger.infoPair("client status", "ok")
     140
     141                for batchType in self.skychunk.batchTypes:
     142
    140143                    self.logger.infoPair("Check","client status")
    141144                    if not self.checkClientStatus():
     
    143146                        break
    144147                    self.logger.infoPair("client status", "ok")
    145                     # get box info. if boxes have changed, break and start again
    146                     try:
    147                         boxDim = self.ippToPspsDb.getBoxDimensions(boxId)
    148                     except:
    149                         self.logger.infoPair("Can't get details for this box", "%d" % boxId)
    150                         break
    151                     self.logger.infoPair("client status", "ok")
     148
    152149                    ids = self.ippToPspsDb.getPendingIdsForThisBox(boxId, batchType)
    153                 
     150               
    154151                    # ids are the stage_ids for items to be processed (eg, stack_id for a stack CMF, cam_id for P2 smf)
    155152
     
    160157                    self.logger.infoSeparator()
    161158                    self.logger.infoTitle("New box")
    162                     self.logger.infoPair("Box dimensions", "%.1f / %.1f / %.1f" % (boxDim['RA'], boxDim['DEC'], boxDim['SIDE']))
     159                    self.logger.infoPair("Box dimensions: ", "ra / dec / size : %.1f / %.1f / %.1f   --   sky bounds : (%.2f - %2.f, %2.f - %2.f)" % (boxDim['RA'], boxDim['DEC'], boxDim['SIDE'], boxDim['minRA'], boxDim['maxRA'], boxDim['minDEC'], boxDim['maxDEC']))
    163160                    self.logger.infoPair(batchType + " items found in this box", "%d" % len(ids))
    164                     boxSizeWithBorder = boxDim['SIDE'] + (self.skychunk.BORDER * 2)
    165                     boxSizeSansBorder = boxDim['SIDE']
    166                     self.logger.infoPair("got here", "ok")
     161
    167162                    useFullTables = 0
    168163                    if batchType != "OB":
     
    171166                            # look in DVO for this box (with extra border)
    172167                            self.logger.infoPair("Querying DVO for this sky area", "")
    173                             self.dvoDetections.setSkyAreaAsBox(boxDim['RA'], boxDim['DEC'], boxSizeWithBorder)
     168
     169                            # XXXX EAM : This code should not be used anymore
     170                            boxSize = 0.0
     171                            self.dvoDetections.setSkyAreaAsBox(boxDim['RA'], boxDim['DEC'], boxSize)
    174172                            #self.dvoDetections.setSkyArea()
    175173                            sizeToBeIngested = self.dvoDetections.getDiskSizeOfRegionsToBeIngested()
     
    191189                                useFullTables = 1
    192190                        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)
     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                                self.dvoDetections.nativeIngestDetections(boxId, boxDim)
    201201
    202202                            useFullTables = 1
Note: See TracChangeset for help on using the changeset viewer.