IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 19, 2013, 4:35:54 PM (13 years ago)
Author:
eugene
Message:

use MEMORY engine for dvoDetectionFull; add error handline for dvopsps; check mysql version; remove some test verbosity; check for image existence in dvoImages; skip bad batches but do not exit; fix precision issues; add -realgpc option (part of -test mode); log times in milliseconds

Location:
trunk/ippToPsps
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippToPsps

  • trunk/ippToPsps/jython/scratchdb.py

    r35226 r35417  
    2929            dbType = "localdatabase"
    3030
    31         print "trying to connect: ", dbType
     31        # print "trying to connect: ", dbType
    3232
    3333        dbName = config.getDbName(dbType)
     
    3838        self.dvoSkyTable = "dvoSkyTable"
    3939        self.dvoPhotcodesTable = "dvoPhotcodes"
     40        self.memoryTableSize = config.getDbMemory(dbType)
    4041
    4142    '''
     
    368369
    369370    '''
     371    Checks whether the given chipID is in the DVO Image table
     372    '''
     373    def haveThisChip(self, imageID, sourceID):
     374
     375        sql = "SELECT EXTERN_ID FROM " \
     376            + self.dvoImagesTable + \
     377            " WHERE EXTERN_ID = " + str(imageID) + \
     378            " AND SOURCE_ID = " + str(sourceID)
     379
     380        try:
     381            rs = self.executeQuery(sql)
     382           
     383            if not rs:
     384                print "missing result set for imageID query"
     385                raise
     386
     387            # if no returned rows, return an error
     388            if not rs.next():
     389                print "DVO lacks imageID ", imageID
     390                print "sql: ", sql
     391                return False
     392
     393            if rs.getInt(1) == int(imageID):
     394                # print "DVO has imageID ", imageID
     395                return True
     396
     397            else:
     398                print "DVO has wrong imageID? ", imageID
     399                print "result was ", rs.getInt(1)
     400                print "sql: ", sql
     401                raise
     402
     403        except:
     404            print "DVO imageID query failed ", imageID
     405            print "sql: ", sql
     406            raise
     407
     408        # how can I reach this?
     409        return True
     410
     411    '''
    370412    Creates a table for for ID matching
    371413    '''
     
    409451               objID BIGINT, \
    410452               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, \
     453               zp FLOAT, \
     454               zpErr FLOAT, \
     455               airMass FLOAT, \
     456               expTime FLOAT, \
     457               ra DOUBLE, \
     458               dec_ DOUBLE, \
     459               raErr FLOAT, \
     460               decErr FLOAT, \
    419461               PRIMARY KEY (imageID, ippDetectID), \
    420462               KEY (objID, detectID) \
     
    463505    Drops and recreates tables necessary for dvoToMySQL program. Be very careful before using this...
    464506    '''
     507    def resetDvoDetectionTable(self):
     508
     509       self.logger.infoPair("Dropping table", self.dvoDetectionTable)
     510       self.dropTable(self.dvoDetectionTable)
     511
     512       # we need a big enough memory table for the incoming detections
     513       print "requested memory in gigs: ", self.memoryTableSize
     514       tableSize = int(self.memoryTableSize) * 1024 * 1024 * 1024
     515       sql = "set @@max_heap_table_size = " + str(tableSize)
     516       print "setting max heap size: ", sql
     517       try: self.execute(sql)
     518       except:
     519           self.logger.errorPair("Unable to set max MEMORY table size for ", self.dvoDetectionTable)
     520           return False
     521
     522       # create detections table
     523       self.logger.infoPair("Creating table", self.dvoDetectionTable)
     524       sql = "CREATE TABLE " + self.dvoDetectionTable + " LIKE dvoDetection"
     525       try: self.execute(sql)
     526       except:
     527           self.logger.errorPair("Unable to create table", self.dvoDetectionTable)
     528           return False
     529
     530       # XXX changing the dvoDetectionFull table to MEMORY
     531       # self.changeEngineToInnoDB(self.dvoDetectionTable)
     532
     533       # set engine to memory
     534       sql = "ALTER TABLE " + self.dvoDetectionTable + " ENGINE = MEMORY"
     535       try: self.execute(sql)
     536       except:
     537           self.logger.errorPair("Unable to set engine to MEMORY for ", self.dvoDetectionTable)
     538           return False
     539
     540       return True
     541
     542    '''
     543    Drops and recreates tables necessary for dvoToMySQL program. Be very careful before using this...
     544    '''
    465545    def resetAllDvoTables(self):
    466546
     
    485565       self.changeEngineToInnoDB(self.dvoDoneTable)
    486566
    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)
     567       # blow away existing dvoDetection table & re-crate
     568       if not self.resetDvoDetectionTable():
     569           self.logger.errorPair("Unable to reset scratch table", "DvoDetectionFull")
    493570           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
    518571
    519572       return True
Note: See TracChangeset for help on using the changeset viewer.