Changeset 35417
- Timestamp:
- Apr 19, 2013, 4:35:54 PM (13 years ago)
- Location:
- trunk/ippToPsps
- Files:
-
- 21 edited
-
. (modified) (1 prop)
-
config/settings.xml (modified) (10 diffs)
-
jython/batch.py (modified) (8 diffs)
-
jython/config.py (modified) (5 diffs)
-
jython/datastore.py (modified) (1 diff)
-
jython/detectionbatch.py (modified) (10 diffs)
-
jython/dvo.py (modified) (5 diffs)
-
jython/dvoobjects.py (modified) (2 diffs)
-
jython/fits.py (modified) (2 diffs)
-
jython/gpc1db.py (modified) (3 diffs)
-
jython/ipptopsps.py (modified) (3 diffs)
-
jython/loader.py (modified) (2 diffs)
-
jython/mysql.py (modified) (1 diff)
-
jython/objectbatch.py (modified) (1 diff)
-
jython/pslogger.py (modified) (1 diff)
-
jython/queue.py (modified) (2 diffs)
-
jython/scratchdb.py (modified) (6 diffs)
-
jython/skychunk.py (modified) (1 diff)
-
jython/stackbatch.py (modified) (2 diffs)
-
test/fulltest.sh (modified) (11 diffs)
-
test/mkgpc1data.dvo (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippToPsps
- Property svn:mergeinfo changed
/branches/eam_branches/ipp-20130307/ippToPsps (added) merged: 35350,35352,35369,35402-35404,35413
- Property svn:mergeinfo changed
-
trunk/ippToPsps/config/settings.xml
r35217 r35417 15 15 <user>dvo</user> 16 16 <password>dvo</password> 17 <memory>16</memory> 17 18 </loader> 18 19 <loader mach="ipp007"> … … 21 22 <user>dvo</user> 22 23 <password>dvo</password> 24 <memory>16</memory> 23 25 </loader> 24 26 <loader mach="ipp008"> … … 27 29 <user>dvo</user> 28 30 <password>dvo</password> 31 <memory>16</memory> 29 32 </loader> 30 33 <loader mach="ipp009"> … … 33 36 <user>dvo</user> 34 37 <password>dvo</password> 38 <memory>16</memory> 35 39 </loader> 36 40 <loader mach="ipp010"> … … 39 43 <user>dvo</user> 40 44 <password>dvo</password> 45 <memory>16</memory> 46 </loader> 47 <loader mach="ipp064"> 48 <name>ipptopsps_scratch</name> 49 <host>ipp064</host> 50 <user>dvo</user> 51 <password>dvo</password> 52 <memory>32</memory> 41 53 </loader> 42 54 <loader mach="generic"> … … 45 57 <user>dvo</user> 46 58 <password>dvo</password> 59 <memory>16</memory> 47 60 </loader> 48 61 </localdatabase> 49 62 50 63 <!-- GPC1 Db section (REAL version) --> 64 <!-- this db is used for real processing, or in a test if -realgpc 65 is supplied on the cmd line --> 51 66 <gpc1database> 52 67 <name>gpc1</name> … … 71 86 <user>dvo</user> 72 87 <password>dvo</password> 88 <memory>16</memory> 89 </loader> 90 <loader mach="ipp064"> 91 <name>ipptopsps_test_scratch</name> 92 <host>ipp064</host> 93 <user>dvo</user> 94 <password>dvo</password> 95 <memory>32</memory> 73 96 </loader> 74 97 <loader mach="pikake"> … … 77 100 <user>dvo</user> 78 101 <password>dvo</password> 102 <memory>2</memory> 79 103 </loader> 80 104 <loader mach="generic"> … … 83 107 <user>dvo</user> 84 108 <password>dvo</password> 109 <memory>2</memory> 85 110 </loader> 86 111 </localdatabase_test> 87 112 88 <!-- GPC1 Db section (REAL VERSION) --> 89 <gpc1database_test> 90 <name>gpc1</name> 91 <host>ippdb01</host> 92 <user>ipp</user> 93 <password>ipp</password> 94 </gpc1database_test> 95 96 <!-- GPC1 Db section (TEST VERSION) 113 <!-- GPC1 Db section (TEST VERSION)--> 114 <!-- this db is used for test processing UNLESS -realgpc is supplied 115 on the cmd line --> 97 116 <gpc1database_test> 98 117 <name>gpc1test</name> … … 100 119 <user>dvo</user> 101 120 <password>dvo</password> 102 </gpc1database_test> -->121 </gpc1database_test> 103 122 104 123 <!-- ippToPsps Db section (TEST VERSION) --> -
trunk/ippToPsps/jython/batch.py
r35174 r35417 276 276 p = Popen(cmd, shell=True, stdout=PIPE) 277 277 p.wait() 278 if p.returncode != 0: 279 self.logger.errorPair("error running xmllint for ", tmpPath) 280 raise 278 281 except: 279 282 self.logger.errorPair("Popen failed", cmd) … … 301 304 p = Popen(cmd, shell=True, stdout=PIPE) 302 305 p.wait() 303 304 306 if p.returncode != 0: 305 307 self.logger.errorPair("tar command", "failed") … … 311 313 p = Popen(cmd, shell=True, stdout=PIPE) 312 314 p.wait() 313 314 315 if p.returncode != 0: 315 316 self.logger.errorPair("gzip command", "failed") … … 415 416 416 417 # drop any previous tables before import 417 #self.scratchDb.dropTable(table.name)418 self.scratchDb.dropTable(table.name) 418 419 419 420 # IPP FITS files are littered with infinities, so remove these … … 426 427 try: 427 428 table.write(self.scratchDb.url + '#' + table.name) 428 # print "wrote to mysql ", table429 self.scratchDb.killLastConnectionID()429 # XXX this one is not needed 430 # self.scratchDb.killLastConnectionID() 430 431 count = count + 1 431 432 except: … … 454 455 # get everything from table 455 456 try: 457 print "reading table from mysql ", table 456 458 _table = stilts.tread(self.scratchDb.url + '#SELECT * FROM ' + table) 457 459 self.scratchDb.killLastConnectionID() … … 518 520 p = Popen(cmd, shell=True, stdout=PIPE) 519 521 p.wait() 522 if p.returncode != 0: 523 self.logger.errorPair("dvograbber command", "failed") 524 return False 520 525 521 526 rowCount = self.scratchDb.getRowCount("dvoDetection") … … 554 559 555 560 if not self.populatePspsTables(): 561 if self.skipBatch: 562 self.ippToPspsDb.updateProcessed(self.batchID, -1) 563 return True 564 556 565 self.logger.errorPair("Aborting this batch", "unable to populate PSPS tables") 557 566 self.ippToPspsDb.updateProcessed(self.batchID, -1) -
trunk/ippToPsps/jython/config.py
r35217 r35417 28 28 if arg == "-t": 29 29 self.test = True 30 sys.argv.remove(arg) 31 32 self.gpc1test = self.test 33 for arg in sys.argv: 34 if arg == "-realgpc": 35 self.gpc1test = False 30 36 sys.argv.remove(arg) 31 37 … … 60 66 self.czarPlotsPath = self.settingsDoc.find("czarPlotsPath").text 61 67 62 63 64 print "config.programName: ", self.programName 65 print "config.configDir: ", self.configDir 66 print "config.settingsPath: ", self.settingsPath 67 print "config.logPath: ", self.logPath 68 print "config.test: ", self.test 69 print "config.czarPlotsPath: ", self.czarPlotsPath 68 # print "config.programName: ", self.programName 69 # print "config.configDir: ", self.configDir 70 # print "config.settingsPath: ", self.settingsPath 71 # print "config.logPath: ", self.logPath 72 # print "config.test: ", self.test 73 # print "config.czarPlotsPath: ", self.czarPlotsPath 70 74 71 75 root = self.settingsDoc.getroot() … … 119 123 return self.settingsDoc.find(dbType +"/password").text 120 124 125 def getDbMemory(self, dbType): 126 if dbType == 'localdatabase' or dbType == 'localdatabase_test': 127 return self.scratchDbLeaf.find('memory').text 128 else: 129 print "memory is not a valid option for non-scratch databases..." 130 raise 131 121 132 def setScratchDbLeaf(self, myhost): 122 133 root = self.settingsDoc.getroot() … … 128 139 for loaderhost in localdb.findall('loader'): 129 140 name = loaderhost.get('mach') 130 print "name, myhost: ", name, myhost141 # print "name, myhost: ", name, myhost 131 142 if name == myhost: 132 143 self.scratchDbLeaf = loaderhost … … 135 146 for loaderhost in localdb.findall('loader'): 136 147 name = loaderhost.get('mach') 137 print "name, myhost: ", name, myhost148 # print "name, myhost: ", name, myhost 138 149 if name == 'generic': 139 150 self.scratchDbLeaf = loaderhost -
trunk/ippToPsps/jython/datastore.py
r35097 r35417 47 47 --list " + tempFile.name 48 48 49 print "dsreg cmd: ", command 49 50 p = Popen(command, shell=True, stdout=PIPE) 50 51 p.wait() -
trunk/ippToPsps/jython/detectionbatch.py
r35171 r35417 212 212 )" 213 213 214 print "frame meta sql: ", sql214 # print "frame meta sql: ", sql 215 215 216 216 self.scratchDb.execute(sql) … … 607 607 WHERE b.imageID = " + str(imageID) + \ 608 608 " INTO OUTFILE '" + dumpFile + "'" 609 print "sql: ", sql 610 self.scratchDb.execute(sql) 609 610 try: self.scratchDb.execute(sql) 611 except: 612 self.logger.info("failed to select data for detectionCalib") 613 self.logger.infoPair("sql: ", sql) 614 raise 611 615 612 616 sql = "LOAD DATA INFILE '" + dumpFile + "' INTO TABLE " + tableName 613 print "sql: ", sql 614 self.scratchDb.execute(sql) 617 try: self.scratchDb.execute(sql) 618 except: 619 self.logger.info("failed to load data from infile for detectionCalib") 620 self.logger.infoPair("sql: ", sql) 621 raise 615 622 616 623 ''' … … 655 662 656 663 # load corresponding header into memory 657 header = self.fits.findAndReadHeader(extname )664 header = self.fits.findAndReadHeader(extname, self.config.test) 658 665 if not header: 659 self.logger.errorPair("No header found for chip", chipname) 666 # XXX There is no way to check if we SHOULD find a given 667 # chip. We have to accept the absence of the header as 668 # information that the chip is not available. This 669 # message is too verbose, only print in test mode 670 if self.config.test: self.logger.errorPair("No header found for chip", chipname) 660 671 return False 661 672 … … 670 681 # store these for later 671 682 self.imageIDs[chipname] = header['IMAGEID'] 683 self.sourceIDs[chipname] = header['SOURCEID'] 672 684 673 685 # populate ImageMeta … … 691 703 # dictionary objects to hold imageIDs for later 692 704 self.imageIDs = {} 705 self.sourceIDs = {} 693 706 694 707 # loop through all OTAs and populate ImageMeta extensions … … 773 786 # this is a bit crude: if the chip is not present, this test will fail and the chip 774 787 # will be (correctly) skipped. would be better to carry that information explicitly ("chip is missing") 775 if not self.scratchDb.astrometricSolutionOK(chipname): 776 self.logger.info("| %5s | ------------- Bad astrometric solution : rejecting ------------ |" % chipname) 788 789 # XXX keep this in or not? 790 # if not self.scratchDb.astrometricSolutionOK(chipname): 791 # self.logger.info("| %5s | ------------- Bad astrometric solution : rejecting ------------ |" % chipname) 792 # return False 793 794 # does this chip exist in the DVO image table (if NOT, then skip it) 795 if not self.scratchDb.haveThisChip(self.imageIDs[chipname], self.sourceIDs[chipname]): 796 self.logger.info("| %5s | ------------- Chip not in DVO : rejecting ------------ |" % chipname) 777 797 return False 798 778 799 self.logger.info("populate stuff "); 779 800 # populate remainder of tables … … 803 824 self.totalNullObjID = self.totalNullObjID + results['NULLOBJID'] 804 825 self.totalDetections = self.totalDetections + rowCount 826 827 fractionKept = float(rowCount) / float(results['ORIGINALTOTAL']) 828 # print "kept ", str(fractionKept), " detections from ", chipname 829 830 if fractionKept < 0.8: 831 # print "Too many rejected detections (", str(fractionKept), ", fail on exposure for", chipname 832 self.logger.infoPair("Too many rejected detections, fail on exposure for", chipname) 833 self.skipBatch = True 834 return False; 835 805 836 #self.logger.info("updated totals") 806 837 # check we have something in this Detection table TODO add this to table above 807 838 if rowCount < 1: 808 self.logger.infoPair("Skipping empty table for chipname", chipname) 839 self.logger.infoPair("Empty table for chip, fail on exposure", chipname) 840 self.skipBatch = True 809 841 return False; 810 842 … … 849 881 850 882 # loop through all OTAs again to update with DVO IDs 883 self.skipBatch = False 851 884 self.validChips = [] 852 885 self.tablesToExport = [] … … 872 905 873 906 if self.populatePspsTablesChip(ota, x, y, results, tables): otaCount = otaCount + 1 874 875 if self.populatePspsTablesChip("Chip", 0, 0, results, tables): otaCount = otaCount + 1 907 if self.skipBatch: 908 self.logger.error("fatal problem for exposure, skipping") 909 return False 910 911 if "Chip" in self.imageIDs: 912 if self.populatePspsTablesChip("Chip", 0, 0, results, tables): otaCount = otaCount + 1 913 if self.skipBatch: 914 self.logger.error("fatal problem for exposure, skipping") 915 return False 876 916 877 917 # print totals … … 886 926 self.logger.info("+-------+---------------+---------------+---------------+---------------+---------------+---------------+") 887 927 888 # if we only have one table export, i.e. FrameMeta, then get out of here 928 # if we only have one table export, i.e. FrameMeta, then get out of here (skip batch, but do not abort) 889 929 if len(self.tablesToExport) == 1: 890 930 self.skipBatch = True 891 931 self.logger.error("No tables to export") 892 932 return False -
trunk/ippToPsps/jython/dvo.py
r35223 r35417 193 193 p = Popen(cmd, shell=True, stdout=PIPE) 194 194 p.wait() 195 if p.returncode != 0: 196 self.logger.errorPair("dvopsps failed on SkyTable.fits for ", self.skychunk.dvoLocation) 197 raise 195 198 196 199 self.logger.infoPair("Adding index to", self.scratchDb.dvoSkyTable) … … 591 594 def nativeIngestDetections(self, boxId, boxDim): 592 595 593 # XXX put the chunk below in a separate method594 # blow away existing dvoDetection table595 596 596 # clear the 'ingested' field for all boxes owned by this host 597 597 self.ippToPspsDb.clearIngestedBoxes(self.scratchDb.dbHost) … … 607 607 ## raise 608 608 609 # drop detections table 610 self.logger.infoPair("Dropping table", self.scratchDb.dvoDetectionTable) 611 self.scratchDb.dropTable(self.scratchDb.dvoDetectionTable) 612 613 # create detections table 614 self.logger.infoPair("Creating table", self.scratchDb.dvoDetectionTable) 615 sql = "CREATE TABLE " + self.scratchDb.dvoDetectionTable + " LIKE dvoDetection" 616 try: self.scratchDb.execute(sql) 617 except: 618 self.logger.errorPair("Unable to create table", self.scratchDb.dvoDetectionTable) 609 # blow away existing dvoDetection table & re-crate 610 if not self.scratchDb.resetDvoDetectionTable(): 611 self.logger.errorPair("Unable to reset scratch table", "DvoDetectionFull") 619 612 return False 620 self.scratchDb.changeEngineToInnoDB(self.scratchDb.dvoDetectionTable)621 622 # add fileID column623 sql = "ALTER TABLE " + self.scratchDb.dvoDetectionTable + " ADD fileID INT NOT NULL"624 try: self.scratchDb.execute(sql)625 except:626 self.logger.errorPair("Unable to add fileID column to ", self.scratchDb.dvoDetectionTable)627 return False628 629 # add an index to the fileID column630 self.scratchDb.createIndex(self.scratchDb.dvoDetectionTable, "fileID")631 613 632 614 # make sure we have an up-to-date Images table … … 665 647 p = Popen(cmd, shell=True, stdout=PIPE) 666 648 p.wait() 649 if p.returncode != 0: 650 self.logger.errorPair("dvopsps failed on ", self.scratchDb.dvoDetectionTable) 651 raise 667 652 668 653 ## dvopsps can take a very long time. try 2 or 3 times to re-establish communication with the db before proceeding? … … 670 655 self.ippToPspsDb.setIngestedBox(boxId, self.scratchDb.dbHost) 671 656 672 # add fileID column657 # run 'ANALYZE' to get indexes up-to-snuff 673 658 sql = "ANALYZE TABLE " + self.scratchDb.dvoDetectionTable 674 659 try: self.scratchDb.execute(sql) -
trunk/ippToPsps/jython/dvoobjects.py
r35223 r35417 67 67 68 68 if self.skychunk.parallel: 69 if self.scratchDb.dbHost == "localhost": 70 self.logger.info("dvopsps objects -parallel is incompatible with localhost for scratchdb") 71 raise 72 69 73 cmd += " -parallel" 70 74 … … 72 76 p = Popen(cmd, shell=True, stdout=PIPE) 73 77 p.wait() 78 if p.returncode != 0: 79 self.logger.errorPair("dvopsps failed on ", region) 80 raise 74 81 75 82 # update lists after attempted sync -
trunk/ippToPsps/jython/fits.py
r35097 r35417 87 87 88 88 2880 is the magic number that the FITS format uses to break up data: extensions always begin on multiples of 2880 bytes 89 90 Note that we may not be able to distinguish the case where a header is expected from one where the absence of a header 91 just tells us that the header is not available. In some cases, we may not want to emit the error message ("not found") 92 93 XXX WOW! this block is reading the entire file to get the header. 94 major inefficiency... I thought the FITS interactions all went 95 through STILTS 89 96 ''' 90 def findAndReadHeader(self, name ):97 def findAndReadHeader(self, name, VERBOSE): 91 98 92 99 found = False … … 114 121 115 122 self.file.seek(origIndex, 0) 116 self.logger.errorPair("Could not read header", name)123 if VERBOSE: self.logger.errorPair("Could not read header", name) 117 124 return 118 125 else: -
trunk/ippToPsps/jython/gpc1db.py
r35185 r35417 22 22 def __init__(self, logger, config): 23 23 # define database type 24 if (config. test):24 if (config.gpc1test): 25 25 dbType = "gpc1database_test" 26 26 else: … … 104 104 try: 105 105 # XXX EAM : test output 106 self.logger.infoPair("sql for dvo items:", sql)107 106 rs = self.executeQuery(sql) 108 107 while (rs.next()): … … 111 110 except: 112 111 self.logger.exception("Can't query for ids in DVO") 112 self.logger.infoPair("failed sql:", sql) 113 113 return rows 114 114 -
trunk/ippToPsps/jython/ipptopsps.py
r35177 r35417 55 55 raise 56 56 57 print "check client status" 57 58 self.checkClientStatus() 58 59 … … 142 143 def checkClientStatus(self): 143 144 145 print "update client" 144 146 self.ippToPspsDb.updateClient(self.config.programName, self.HOST, self.PID) 145 147 148 print "check killed" 146 149 if self.ippToPspsDb.isKilled(self.HOST, self.PID): 147 150 self.exitProgram("killed via Db") … … 149 152 # this loop pauses the process if we have no skychunk or we have set it to pause 150 153 firstTimeIn = True 154 print "refresh skychunk" 151 155 while not self.refreshSkychunk() or self.ippToPspsDb.isPaused(self.HOST, self.PID): 152 156 -
trunk/ippToPsps/jython/loader.py
r35226 r35417 36 36 37 37 if self.skychunk.parallel: 38 print "PARALLEL dvo"38 self.logger.info("using PARALLEL DVO") 39 39 else: 40 print "SERIAL dvo"40 self.logger.info("using SERIAL DVO") 41 41 42 42 # connect to the gpc1 database … … 198 198 # insertion 199 199 if not self.ippToPspsDb.isBoxIngested(boxId, self.scratchDb.dbHost): 200 self.dvoDetections.nativeIngestDetections(boxId, boxDim) 200 if not self.dvoDetections.nativeIngestDetections(boxId, boxDim): 201 self.logger.error("Unable to ingest detections with nativeIngest") 202 return False 201 203 202 204 useFullTables = 1 -
trunk/ippToPsps/jython/mysql.py
r35222 r35417 46 46 self.logger.errorPair("Unable to connect to", connectionStr) 47 47 self.connected = False 48 raise 49 50 # determine the mysql major version number: 51 sql = "SELECT @@version" 52 53 try: 54 rs = self.executeQuery(sql) 55 rs.first() 56 fullVersion = rs.getString(1) 57 majVersion = fullVersion[0:3] 58 self.version = float(majVersion) 59 60 except: 61 print "failed to get version number" 48 62 raise 49 63 -
trunk/ippToPsps/jython/objectbatch.py
r35223 r35417 372 372 self.logger.infoPair("Forcing uniqueness on", "objID in Object table") 373 373 rowCountBefore = self.scratchDb.getRowCount("Object") 374 375 # XXX EAM : note that in mysql versions later than 5.1, this fails 376 # unless the following is called first: 377 # set session old_alter_table=1 378 # follow the command with 379 # set session old_alter_table=0 380 # OF COURSE, this fails for mysql version < 5.5... 381 if self.scratchDb.version > 5.1: 382 self.scratchDb.execute("set session old_alter_table=1") 383 374 384 self.scratchDb.execute("ALTER IGNORE TABLE Object ADD UNIQUE INDEX(objID)") 385 if self.scratchDb.version > 5.1: 386 self.scratchDb.execute("set session old_alter_table=0") 387 375 388 rowCountAfter = self.scratchDb.getRowCount("Object") 376 389 self.logger.infoPair("Number of duplicated objIDs removed", "%d out of %d" % ((rowCountBefore - rowCountAfter), rowCountBefore)) -
trunk/ippToPsps/jython/pslogger.py
r35097 r35417 13 13 def setup(self, programName, basePath, skychunkName, host, pid, stdout=1, sendToFile=0): 14 14 15 formatter = logging.Formatter('%(asctime)s | %(levelname)7s | %(message)s', '%Y-%m-%d %H:%M:%S')15 formatter = logging.Formatter('%(asctime)s.%(msecs)03d | %(levelname)7s | %(message)s', '%Y-%m-%d %H:%M:%S') 16 16 self.setLevel(logging.INFO) 17 17 -
trunk/ippToPsps/jython/queue.py
r35226 r35417 29 29 super(Queue, self).__init__(argv) 30 30 31 print "inited ipptopsps"31 # print "inited ipptopsps" 32 32 33 33 # create various objects 34 34 self.gpc1Db = Gpc1Db(self.logger, self.config) 35 print "connect to gpc1"35 # print "connect to gpc1" 36 36 37 37 self.datastore = Datastore(self.logger, self.skychunk, self.ippToPspsDb) 38 38 39 print "made datastore"39 # print "made datastore" 40 40 41 41 # connect to scratch database 42 42 self.scratchDb = ScratchDb(self.logger, self.config) 43 43 44 print "connect to scratchdb"44 # print "connect to scratchdb" 45 45 46 46 try: … … 50 50 raise 51 51 52 print "got objects"52 # print "got objects" 53 53 54 54 self.skychunk.printAll() -
trunk/ippToPsps/jython/scratchdb.py
r35226 r35417 29 29 dbType = "localdatabase" 30 30 31 print "trying to connect: ", dbType31 # print "trying to connect: ", dbType 32 32 33 33 dbName = config.getDbName(dbType) … … 38 38 self.dvoSkyTable = "dvoSkyTable" 39 39 self.dvoPhotcodesTable = "dvoPhotcodes" 40 self.memoryTableSize = config.getDbMemory(dbType) 40 41 41 42 ''' … … 368 369 369 370 ''' 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 ''' 370 412 Creates a table for for ID matching 371 413 ''' … … 409 451 objID BIGINT, \ 410 452 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, \ 419 461 PRIMARY KEY (imageID, ippDetectID), \ 420 462 KEY (objID, detectID) \ … … 463 505 Drops and recreates tables necessary for dvoToMySQL program. Be very careful before using this... 464 506 ''' 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 ''' 465 545 def resetAllDvoTables(self): 466 546 … … 485 565 self.changeEngineToInnoDB(self.dvoDoneTable) 486 566 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") 493 570 return False 494 self.changeEngineToInnoDB(self.dvoDetectionTable)495 496 # add fileID column497 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 False502 503 # add an index to the fileID column504 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 fileID509 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 False518 571 519 572 return True -
trunk/ippToPsps/jython/skychunk.py
r35179 r35417 28 28 if self.name == "all": self.rotateSkychunks = True 29 29 30 print "name: ", self.name31 print "new: ", self.createNewSkychunk32 print "all: ", self.rotateSkychunks30 # print "name: ", self.name 31 # print "new: ", self.createNewSkychunk 32 # print "all: ", self.rotateSkychunks 33 33 34 34 self.logger = logger -
trunk/ippToPsps/jython/stackbatch.py
r35222 r35417 543 543 # response = raw_input("updated dvo ") 544 544 545 # XXX EAM : note that in mysql versions later than 5.1, this fails 546 # unless the following is called first: 547 # set session old_alter_table=1 548 # follow the command with 549 # set session old_alter_table=0 550 # OF COURSE, this fails for mysql version < 5.5... 551 if self.scratchDb.version > 5.1: 552 self.scratchDb.execute("set session old_alter_table=1") 553 545 554 sql = "ALTER IGNORE TABLE StackDetection ADD PRIMARY KEY (objID)" 546 555 556 if self.scratchDb.version > 5.1: 557 self.scratchDb.execute("set session old_alter_table=0") 558 547 559 self.scratchDb.execute(sql) 548 560 # response = raw_input("add primary key? ") … … 806 818 ON (a.stackDetectID = b.detectID) where b.imageID = " + str(imageID) + \ 807 819 " INTO OUTFILE '" + dumpFile + "'" 808 print "sql: ", sql 809 self.scratchDb.execute(sql) 820 821 try: self.scratchDb.execute(sql) 822 except: 823 self.logger.info("failed to select data for stackDetectionCalib") 824 self.logger.infoPair("sql: ", sql) 825 raise 810 826 811 827 sql = "LOAD DATA INFILE '" + dumpFile + "' INTO TABLE " + tableName 812 print "sql: ", sql 813 self.scratchDb.execute(sql) 828 try: self.scratchDb.execute(sql) 829 except: 830 self.logger.info("failed to load data from infile for stackDetectionCalib") 831 self.logger.infoPair("sql: ", sql) 832 raise 814 833 815 834 ## XXX write this with the select/insert -
trunk/ippToPsps/test/fulltest.sh
r35225 r35417 1 1 #!/bin/csh -f 2 3 set stackqueuename = 04 if ($#argv > 0) then5 set stackqueuename = $16 echo "stackqueue: $stackqueuename"7 endif8 9 set objectqueuename = 010 if ($#argv > 0) then11 set stackqueuename = $112 echo "stackqueue: $stackqueuename"13 endif14 2 15 3 # a bit crude : get the datadir path by interpollation of the PATH element for psconfig … … 24 12 # before running this test, you must have a mysql user: 25 13 # mkgpc1.sh user localhost eam eam 26 27 14 set mkgpc1 = 1 28 15 set initdb = 1 29 16 set initscratch = 1 17 set initbatch = 1 30 18 set camqueue = 1 31 set initbatch = 132 19 set cambatch = 1 33 20 set stackqueue = 1 … … 36 23 set objectbatch = 1 37 24 25 set args = "" 26 27 while ("$1" != "") 28 switch ("$1") 29 case -mkgpc1 30 set mkgpc1 = 0 31 breaksw; 32 case -initdb 33 set initdb = 0 34 breaksw; 35 case -initscratch 36 set initscratch = 0 37 breaksw; 38 case -initbatch 39 set initbatch = 0 40 breaksw; 41 case -camera 42 set camqueue = 0 43 set cambatch = 0 44 breaksw; 45 case -stack 46 set stackqueue = 0 47 set stackbatch = 0 48 breaksw; 49 case -object 50 set objectqueue = 0 51 set objectbatch = 0 52 breaksw; 53 default: 54 set args=($args $1); 55 breaksw; 56 endsw 57 shift 58 end 59 60 set stackqueuename = 0 61 set objectqueuename = 0 62 38 63 set OUTDIR = "testdata" 39 64 set queuename = "test" 40 65 41 66 if ($mkgpc1) then 67 echo "" 68 echo " ---- mkgpc1data.dvo : creating the dvo & gpc1 database entries ----" 42 69 mkgpc1data.dvo 43 70 endif … … 45 72 # create the ipptopsps database 46 73 if ($initdb) then 74 echo "" 75 echo " ---- init ipptopsps_test ----" 47 76 48 77 # does the database already exist? … … 55 84 # re-create the ipptopsps database 56 85 if ($initscratch) then 86 echo "" 87 echo " ---- init ipptopsps_test_scratch ----" 57 88 58 89 # create the database (ignore failure if it already exists) … … 62 93 endif 63 94 95 # `name` 96 # `datastore_product` 97 # `datastore_type` 98 # `datastore_publish` 99 # `dvo_label` 100 # `dvo_location` 101 # `min_ra` 102 # `max_ra` 103 # `min_dec` 104 # `max_dec` 105 # `box_size` 106 # `base_path` 107 # `data_release` 108 # `delete_local` 109 # `delete_datastore` 110 # `delete_dxlayer` 111 # `epoch` 112 # `survey` 113 # `psps_survey` 114 # `queue_P2` 115 # `queue_ST` 116 # `queue_OB` 117 # `active` 118 # `parallel` 119 120 # this is poor : we need to queue something in order to generate an init batch 121 # this is because a skychunk carries the info about the datastore used to publish 122 # the batch 123 if ($initbatch) then 124 echo "" 125 echo " ---- make skychunk for IN batches ----" 126 127 ippjython queue.py -test edit <<EOF 128 initbatch 129 test_ds 130 IPP_PSPS 131 0 132 none 133 none 134 0 135 0 136 0 137 0 138 2 139 none 140 0 141 0 142 1 143 1 144 2012-12-10 00:00:00.0 145 3PI 146 3PI 147 0 148 0 149 0 150 1 151 0 152 y 153 y 154 EOF 155 156 echo "" 157 echo " ---- create init batch ----" 158 159 rm -rf $OUTDIR/IN 160 ippjython loader.py -test initbatch init 161 endif 162 64 163 # this code is sensitive to a previously existing database? 65 164 if ($camqueue) then 165 echo "" 166 echo " ---- queue P2 batches ----" 167 66 168 ippjython queue.py -test edit <<EOF 67 169 $queuename … … 94 196 endif 95 197 96 if ($initbatch) then97 rm -rf $OUTDIR/IN98 ippjython loader.py -test $queuename init99 endif100 101 198 if ($cambatch) then 199 echo "" 200 echo " ---- load P2 batches ----" 201 102 202 rm -rf $OUTDIR/P2 103 203 ippjython loader.py -test $queuename once … … 106 206 # this code is sensitive to a previously existing database? 107 207 if ($stackqueue) then 208 echo "" 209 echo " ---- queue ST batches ----" 210 108 211 if ($stackqueuename == 0) then 109 212 set stackqueuename = $queuename\_stk … … 140 243 141 244 if ($stackbatch) then 245 echo "" 246 echo " ---- load ST batches ----" 247 142 248 if ($stackqueuename == 0) then 143 249 set stackqueuename = $queuename\_stk … … 149 255 # this code is sensitive to a previously existing database? 150 256 if ($objectqueue) then 257 echo "" 258 echo " ---- queue OB batches ----" 259 151 260 if ($objectqueuename == 0) then 152 261 set objectqueuename = $queuename\_obj … … 183 292 184 293 if ($objectbatch) then 294 echo "" 295 echo " ---- load OB batches ----" 296 185 297 if ($objectqueuename == 0) then 186 298 set objectqueuename = $queuename\_obj -
trunk/ippToPsps/test/mkgpc1data.dvo
r35188 r35417 196 196 # PCA2X0Y2 197 197 198 if ($i == 3) 199 echo "NOTE: not adding image $i to DVO : this simulates images with poor astrometry" 200 continue 201 end 202 198 203 echo addstar -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass 199 204 exec addstar -D CATDIR $catdir -D CAMERA simtest $cmffile -D CATFORMAT $2 -quick-airmass
Note:
See TracChangeset
for help on using the changeset viewer.
