IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 3, 2013, 12:52:33 PM (13 years ago)
Author:
eugene
Message:

changed dvoDetectionFull mysql engine to 'MEMORY' to improve ingest speed

handle errrors in calls to dvopsps (only in detectionbatch.py)

removed a lot of excess verbosity used for debugging / testing

determine the mysql major version number via mysql query

added test option -realgpc to use test ipptopsps databases with a real gpc1 dataset

add version-dependent call to 'set session old_alter_table' to allow
the ALTER IGNORE statements to work on mysql v5.5 machines (like our
desktops).

raise an exception in case the load infile operations fail

remove unneeded 'killLastConnectionID'

extend logging time to milliseconds

allow an exposure to be skipped without aborting loader

check that a P2 image exists in the dvoImage table (otherwise skip the chip)

change the mysql floating point types for the dvoDetection table to use FLOAT/DOUBLE instead of REAL/FLOAT

remove the old test for valid astrometry of a chip (NASTRO >= 50)

this test was crude and not really the right test. it was also used
to verify that an image should / should not be included. now we check
against dvoImages to see if the chip should be loaded or not (DVO
rejects input images for bad astrometry)

skip an exposure if too many detections have been rejected. this is a sign of a problem and should require more attention

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130307/ippToPsps/jython/scratchdb.py

    r35226 r35352  
    2929            dbType = "localdatabase"
    3030
    31         print "trying to connect: ", dbType
     31        # print "trying to connect: ", dbType
    3232
    3333        dbName = config.getDbName(dbType)
     
    368368
    369369    '''
     370    Checks whether the given chipID is in the DVO Image table
     371    '''
     372    def haveThisChip(self, imageID):
     373
     374        sql = "SELECT IMAGE_ID FROM " + self.dvoImagesTable + " WHERE IMAGE_ID = " + str(imageID)
     375
     376        try:
     377            rs = self.executeQuery(sql)
     378            rs.first()
     379            if rs.getInt(1) == int(imageID):
     380                # print "DVO has imageID ", imageID
     381                return True
     382            else:
     383                print "DVO lacks imageID ", imageID
     384                print "result was ", rs.getInt(1)
     385                print "sql: ", sql
     386                return False
     387        except:
     388            print "DVO imageID query failed ", imageID
     389            print "sql: ", sql
     390            return False
     391
     392        return True
     393
     394    '''
    370395    Creates a table for for ID matching
    371396    '''
     
    409434               objID BIGINT, \
    410435               flags INT, \
    411                zp REAL, \
    412                zpErr REAL, \
    413                airMass REAL, \
    414                expTime REAL, \
    415                ra FLOAT, \
    416                dec_ FLOAT, \
    417                raErr REAL, \
    418                decErr REAL, \
     436               zp FLOAT, \
     437               zpErr FLOAT, \
     438               airMass FLOAT, \
     439               expTime FLOAT, \
     440               ra DOUBLE, \
     441               dec_ DOUBLE, \
     442               raErr FLOAT, \
     443               decErr FLOAT, \
    419444               PRIMARY KEY (imageID, ippDetectID), \
    420445               KEY (objID, detectID) \
     
    463488    Drops and recreates tables necessary for dvoToMySQL program. Be very careful before using this...
    464489    '''
     490    def resetDvoDetectionTable(self):
     491
     492       self.logger.infoPair("Dropping table", self.dvoDetectionTable)
     493       self.dropTable(self.dvoDetectionTable)
     494
     495       # create detections table
     496       self.logger.infoPair("Creating table", self.dvoDetectionTable)
     497       sql = "CREATE TABLE " + self.dvoDetectionTable + " LIKE dvoDetection"
     498       try: self.execute(sql)
     499       except:
     500           self.logger.errorPair("Unable to create table", self.dvoDetectionTable)
     501           return False
     502
     503       # XXX changing the dvoDetectionFull table to MEMORY
     504       # self.changeEngineToInnoDB(self.dvoDetectionTable)
     505
     506       # set engine to memory
     507       sql = "ALTER TABLE " + self.dvoDetectionTable + " ENGINE = MEMORY"
     508       try: self.execute(sql)
     509       except:
     510           self.logger.errorPair("Unable to set engine to MEMORY for ", self.dvoDetectionTable)
     511           return False
     512
     513       return True
     514
     515    '''
     516    Drops and recreates tables necessary for dvoToMySQL program. Be very careful before using this...
     517    '''
    465518    def resetAllDvoTables(self):
    466519
     
    485538       self.changeEngineToInnoDB(self.dvoDoneTable)
    486539
    487        # create detections table
    488        self.logger.infoPair("Creating table", self.dvoDetectionTable)
    489        sql = "CREATE TABLE " + self.dvoDetectionTable + " LIKE dvoDetection"
    490        try: self.execute(sql)
    491        except:
    492            self.logger.errorPair("Unable to create table", self.dvoDetectionTable)
     540       # blow away existing dvoDetection table & re-crate
     541       if not self.resetDvoDetectionTable():
     542           self.logger.errorPair("Unable to reset scratch table", "DvoDetectionFull")
    493543           return False
    494        self.changeEngineToInnoDB(self.dvoDetectionTable)
    495 
    496        # add fileID column
    497        sql = "ALTER TABLE " + self.dvoDetectionTable + " ADD fileID INT NOT NULL"
    498        try: self.execute(sql)
    499        except:
    500            self.logger.errorPair("Unable to add fileID column to ", self.dvoDetectionTable)
    501            return False
    502 
    503        # add an index to the fileID column
    504        self.createIndex(self.dvoDetectionTable, "fileID")
    505 
    506        # XXX : this should be based on choice of useStilts (which is set in dvo.py and must be moved)
    507        if (False):
    508            # now add a delete cascading foreign key constraint on fileID
    509            sql = "ALTER TABLE dvoDetectionFull \
    510               ADD CONSTRAINT fk_fileID \
    511               FOREIGN KEY (fileID) \
    512               REFERENCES dvoDone(id) \
    513               ON DELETE CASCADE"
    514            try: self.execute(sql)
    515            except:
    516                self.logger.errorPair("Unable to create foreign key on", self.dvoDoneTable)
    517                return False
    518544
    519545       return True
Note: See TracChangeset for help on using the changeset viewer.