Changeset 35076
- Timestamp:
- Jan 31, 2013, 4:13:09 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20121219/ippToPsps
- Files:
-
- 1 added
- 27 edited
-
config/ippToPspsDbSchema.sql (modified) (4 diffs)
-
doc/upgrade.txt (modified) (1 diff)
-
jython/Makefile.am (modified) (1 diff)
-
jython/batch.py (modified) (10 diffs)
-
jython/batchRepublisher.py (modified) (3 diffs)
-
jython/cleanup.py (modified) (5 diffs)
-
jython/config.py (modified) (6 diffs)
-
jython/console.py (modified) (3 diffs)
-
jython/datastore.py (modified) (4 diffs)
-
jython/datastoreRemover.py (modified) (1 diff)
-
jython/detectionbatch.py (modified) (9 diffs)
-
jython/dvo.py (modified) (13 diffs)
-
jython/dvodetections.py (modified) (2 diffs)
-
jython/dvoobjects.py (modified) (4 diffs)
-
jython/initbatch.py (modified) (2 diffs)
-
jython/ipptopsps.py (modified) (10 diffs)
-
jython/ipptopspsdb.py (modified) (43 diffs)
-
jython/loader.py (modified) (11 diffs)
-
jython/objectbatch.py (modified) (4 diffs)
-
jython/plot.py (modified) (3 diffs)
-
jython/plotter.py (modified) (1 diff)
-
jython/pollOdm.py (modified) (2 diffs)
-
jython/pslogger.py (modified) (2 diffs)
-
jython/queue.py (modified) (9 diffs)
-
jython/setupScratchDb.py (modified) (5 diffs)
-
jython/skychunk.py (added)
-
jython/stackbatch.py (modified) (12 diffs)
-
test/fulltest.sh (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20121219/ippToPsps/config/ippToPspsDbSchema.sql
r35063 r35076 58 58 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, 59 59 `id` bigint(20) unsigned NOT NULL auto_increment, 60 ` config` varchar(30) default NULL,60 `skychunk` varchar(30) default NULL, 61 61 `ra_center` float default NULL, 62 62 `dec_center` float default NULL, 63 63 `box_side` float default NULL, 64 64 PRIMARY KEY (`id`), 65 KEY `fk_ config` (`config`),66 CONSTRAINT `fk_ config` FOREIGN KEY (`config`) REFERENCES `config` (`name`) ON DELETE CASCADE65 KEY `fk_skychunk` (`skychunk`), 66 CONSTRAINT `fk_skychunk` FOREIGN KEY (`skychunk`) REFERENCES `skychunk` (`name`) ON DELETE CASCADE 67 67 ) ENGINE=InnoDB AUTO_INCREMENT=44588 DEFAULT CHARSET=latin1; 68 68 SET character_set_client = @saved_cs_client; … … 80 80 `pid` bigint(20) unsigned NOT NULL, 81 81 `host` varchar(20) NOT NULL, 82 ` config` varchar(30) default NULL,82 `skychunk` varchar(30) default NULL, 83 83 `paused` tinyint(1) default '0', 84 84 `killed` tinyint(1) default '0', … … 91 91 92 92 -- 93 -- Table structure for table ` config`94 -- 95 96 DROP TABLE IF EXISTS ` config`;97 SET @saved_cs_client = @@character_set_client; 98 SET character_set_client = utf8; 99 CREATE TABLE ` config` (93 -- Table structure for table `skychunk` 94 -- 95 96 DROP TABLE IF EXISTS `skychunk`; 97 SET @saved_cs_client = @@character_set_client; 98 SET character_set_client = utf8; 99 CREATE TABLE `skychunk` ( 100 100 `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP, 101 101 `name` varchar(30) NOT NULL, … … 200 200 CREATE TABLE `stripe` ( 201 201 `client_id` bigint(20) unsigned default NULL, 202 ` config` varchar(30) default NULL,202 `skychunk` varchar(30) default NULL, 203 203 `ra_center` float default NULL, 204 204 UNIQUE KEY `unique_key` (`client_id`), -
branches/eam_branches/ipp-20121219/ippToPsps/doc/upgrade.txt
r35075 r35076 18 18 encompases both the static configuration information and the 19 19 information about a processing chunk. 20 21 I propose a new split of config -- put only the global system 22 information in 'config' and define a new concept 'chunk', which 23 corresponds to the region of the sky currently being processed 20 24 21 25 * client : an instance of an ipptopsps running proccess -
branches/eam_branches/ipp-20121219/ippToPsps/jython/Makefile.am
r34969 r35076 32 32 scratchdb.py \ 33 33 setupScratchDb.py \ 34 skychunk.py \ 34 35 stackbatch.py 35 36 -
branches/eam_branches/ipp-20121219/ippToPsps/jython/batch.py
r35056 r35076 30 30 logger, 31 31 config, 32 skychunk, 32 33 gpc1Db, 33 34 ippToPspsDb, … … 46 47 self.readHeader = False 47 48 self.config = config 49 self.skychunk = skychunk 48 50 self.fits = fits 49 51 self.useFullTables = useFullTables … … 55 57 56 58 # self.testprint() 57 58 self.configDir = os.getenv("IPPTOPSPS_DATA")59 if self.configDir is not None:60 self.configDir = self.configDir + "/"61 59 62 60 # set up class variables … … 67 65 self.scratchDb = scratchDb 68 66 self.batchType = batchType; 69 self.pspsVoTableFilePath = self.config Dir + "tables." + batchType + ".vot"67 self.pspsVoTableFilePath = self.config.configDir + "tables." + batchType + ".vot" 70 68 71 69 # self.testprint() … … 85 83 self.tablesToExport = [] 86 84 87 if self. config.survey != "":88 self.surveyID = self.scratchDb.getSurveyID(self. config.survey)85 if self.skychunk.survey != "": 86 self.surveyID = self.scratchDb.getSurveyID(self.skychunk.survey) 89 87 else: 90 88 self.surveyID = -1; 91 89 92 90 # create datastore object 93 self.datastore = Datastore(self.logger, self. config, self.ippToPspsDb)94 95 # get local storage location from config91 self.datastore = Datastore(self.logger, self.skychunk, self.ippToPspsDb) 92 93 # get local storage location from skychunk 96 94 self.batchName = Batch.getNameFromID(self.batchID) 97 95 self.subDir = Batch.getSubDir( 98 self. config.basePath,96 self.skychunk.basePath, 99 97 self.batchType, 100 self. config.dvoLabel)98 self.skychunk.dvoLabel) 101 99 102 100 self.localOutPath = Batch.getOutputPath( 103 self. config.basePath,101 self.skychunk.basePath, 104 102 self.batchType, 105 self. config.dvoLabel,103 self.skychunk.dvoLabel, 106 104 self.batchID) 107 105 … … 253 251 root.attrib['type'] = self.batchType 254 252 root.attrib['timestamp'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") 255 root.attrib['survey'] = self. config.pspsSurvey253 root.attrib['survey'] = self.skychunk.pspsSurvey 256 254 257 255 # min/max object IDs … … 294 292 # set up filenams and paths 295 293 tarFile = Batch.getTarFile(self.batchID) 296 tarPath = Batch.getTarPath(self. config.basePath, self.batchType, self.config.dvoLabel, self.batchID)294 tarPath = Batch.getTarPath(self.skychunk.basePath, self.batchType, self.skychunk.dvoLabel, self.batchID) 297 295 tarballFile = Batch.getTarballFile(self.batchID) 298 tarballPath = Batch.getTarballPath(self. config.basePath, self.batchType, self.config.dvoLabel, self.batchID)296 tarballPath = Batch.getTarballPath(self.skychunk.basePath, self.batchType, self.skychunk.dvoLabel, self.batchID) 299 297 300 298 # tar directory … … 516 514 517 515 # TODO path to DVO prog hardcoded temporarily 518 cmd = "../src/dvograbber " + self.config.settingsPath + " " + self.scratchDb.dbName + " " + self. config.dvoLocation516 cmd = "../src/dvograbber " + self.config.settingsPath + " " + self.scratchDb.dbName + " " + self.skychunk.dvoLocation 519 517 self.logger.infoPair("Running DVO", cmd) 520 518 p = Popen(cmd, shell=True, stdout=PIPE) … … 532 530 ''' 533 531 Creates and publishes a batch 534 TODO all method s callbelow should throw exceptions on failure532 TODO all method calls below should throw exceptions on failure 535 533 ''' 536 534 def run(self): … … 561 559 562 560 if self.writeBatchManifest(): 563 if self. config.datastorePublishing:561 if self.skychunk.datastorePublishing: 564 562 565 563 # tar and zip ready for publication to datastore -
branches/eam_branches/ipp-20121219/ippToPsps/jython/batchRepublisher.py
r33866 r35076 30 30 self.exitProgram("incorrect args") 31 31 32 self.datastore = Datastore(self.logger, self. config, self.ippToPspsDb)32 self.datastore = Datastore(self.logger, self.skychunk, self.ippToPspsDb) 33 33 self.BATCHID = int(sys.argv[2]) 34 34 … … 40 40 batchName = Batch.getNameFromID(self.BATCHID) 41 41 batchType = self.ippToPspsDb.getBatchType(self.BATCHID) 42 subDir = Batch.getSubDir(self. config.basePath, batchType, self.config.dvoLabel)42 subDir = Batch.getSubDir(self.skychunk.basePath, batchType, self.skychunk.dvoLabel) 43 43 tarballFile = Batch.getTarballFile(self.BATCHID) 44 44 … … 50 50 self.logger.infoPair("Reseting batch in database", "%d" % self.BATCHID) 51 51 self.ippToPspsDb.resetBatch(self.BATCHID) 52 self.logger.infoPair("publishing to", self. config.datastoreProduct)52 self.logger.infoPair("publishing to", self.skychunk.datastoreProduct) 53 53 Batch.publishToDatastore(self.datastore, self.BATCHID, batchName, subDir, tarballFile) 54 54 -
branches/eam_branches/ipp-20121219/ippToPsps/jython/cleanup.py
r33818 r35076 26 26 super(Cleanup, self).__init__(argv) 27 27 28 self.datastore = Datastore(self.logger, self. config, self.ippToPspsDb)28 self.datastore = Datastore(self.logger, self.skychunk, self.ippToPspsDb) 29 29 self.dxlayer = DXLayer(self.logger) 30 30 if len(argv) > 2: self.parsePollTimeArg(sys.argv[2]) … … 40 40 41 41 self.logger.infoSeparator() 42 self.logger.infoPair(" Config", self.config.name)43 self. config.printDeletionPolicy()42 self.logger.infoPair("Skychunk", self.skychunk.name) 43 self.skychunk.printDeletionPolicy() 44 44 self.clean("IN") 45 45 self.clean("P2") … … 89 89 90 90 # delete stuff from local disk 91 if self. config.deleteLocal:91 if self.skychunk.deleteLocal: 92 92 count = 0 93 93 for id in deleteFromLocalIDs: 94 94 95 if Batch.deleteFromDisk(self.logger, self. config.basePath, batchType, self.config.dvoLabel, id):95 if Batch.deleteFromDisk(self.logger, self.skychunk.basePath, batchType, self.skychunk.dvoLabel, id): 96 96 self.ippToPspsDb.updateDeletedLocal(id, 1) 97 97 count = count + 1 … … 100 100 101 101 # remove stuff from datastore 102 if self. config.deleteDatastore:102 if self.skychunk.deleteDatastore: 103 103 count = 0 104 104 for id in deleteFromDatastoreIDs: … … 112 112 113 113 # remove stuff from DXLayer 114 if self. config.deleteDxLayer:114 if self.skychunk.deleteDxLayer: 115 115 count = 0 116 116 for id in deleteFromDxLayerIDs: -
branches/eam_branches/ipp-20121219/ippToPsps/jython/config.py
r35075 r35076 1 1 #!/usr/bin/env jython 2 2 3 import sys 4 import os 3 5 import logging 4 6 from xml.etree.ElementTree import ElementTree, Element, tostring … … 6 8 from pslogger import PSLogger 7 9 8 9 10 ''' 10 A class encapsulating a ippToPsps configuration. This information is stored in the 'config' table11 of the ipptopsps database, but there are some higher level config details in the 'settings.xml' file 11 A class encapsulating the globald ippToPsps configuration information. 12 This is stored in the 'settings.xml' file in the config directory 12 13 ''' 13 14 class Config(object): … … 18 19 Basically reads the entire config and stores values to class variables 19 20 ''' 20 def __init__(self , programName, name, configDir):21 def __init__(self): 21 22 22 self.programName = programName 23 self.name = name 24 self.configDir = configDir 23 self.test = False 24 for arg in sys.argv: 25 if arg == "-test": 26 self.test = True 27 sys.argv.remove(arg) 28 if arg == "-t": 29 self.test = True 30 sys.argv.remove(arg) 31 32 ## name of the top-level jython script 33 self.programName = os.path.basename(sys.argv[0]) 34 35 ## this is somewhat crude: ipptopsps programs are called like this: 36 ## ippjython foo.py [chunk] [other options] 37 ## the logging code (called below by getLogger) wants to include 'name' in the 38 ## output file. we blindly set name == argv[1] 39 ## programs which are called without argv[1] will use 'none' in the log file 40 if len(sys.argv) >= 2: 41 self.name = sys.argv[1] 42 43 # XXX this probably goes in 'config.py' 44 self.configDir = os.getenv("IPPTOPSPS_DATA") 45 if self.configDir is None: 46 self.configDir = "../config/" 47 else: 48 self.configDir = self.configDir + "/" 25 49 26 50 # self.configdir is set in ipptopsps.jy on init based on env(IPPTOPSPS_DATA) 27 51 # for test purposes, an uninstalled system may use the config information from 28 52 # a relative path 29 if self.configDir is None: 30 self.settingsPath = "../config/settings.xml" # TODO 31 else: 32 self.settingsPath = self.configDir + "settings.xml" 53 self.settingsPath = self.configDir + "settings.xml" 33 54 34 55 self.logger = None … … 37 58 self.logPath = self.settingsDoc.find("logPath").text 38 59 39 # XXX this is poor -- the czartool stuff is not related to 40 # ipptopsps and should be moved elsewhere 41 self.czarPlotsPath = self.settingsDoc.find("czarPlotsPath").text 42 43 # this is the border (in degrees) that we place around any loading box of 44 # PS1 pointings to ensure we pull a large enough area out of DVO 45 # XXX this is a poor place to put this information -- it is completely gpc-specific. 46 # probably should go elsewhere 47 self.BORDER = 1.65 48 self.isLoaded = False 49 50 ''' 51 Prints everything for this config 52 ''' 53 def printAll(self): 54 55 self.logger.infoTitle("Config") 56 57 try: 58 self.logger.infoSeparator() 59 self.logger.infoPair("Config name", self.name) 60 self.logger.infoPair("Survey", self.survey) 61 self.logger.infoPair("Publishing to PSPS as survey", self.pspsSurvey) 62 self.logger.infoPair("Loading epoch", self.epoch) 63 self.logger.infoPair("Data release", "%d" % self.dataRelease) 64 for batchType in self.batchTypes: self.logger.infoPair("Queuing batch type", batchType) 65 except: 66 pass 67 68 self.printDvoInfo() 69 self.printDatastoreInfo() 70 self.printBoxCoords() 71 self.printDeletionPolicy() 72 try: self.logger.infoSeparator() 73 except: pass 74 75 ''' 76 Queuing this batch type? 77 ''' 78 def queuingThisBatchType(self, batchType): 79 if batchType in self.batchTypes: return 1 80 return 0 60 print "config.programName: ", self.programName 61 print "config.configDir: ", self.configDir 62 print "config.settingsPath: ", self.settingsPath 63 print "config.logPath: ", self.logPath 64 print "config.test: ", self.test 81 65 82 66 ''' … … 85 69 def getLogger(self, host, pid, stdout=1, sendToFile=0): 86 70 71 print "get Logger: ", host, pid 87 72 logging.setLoggerClass(PSLogger) 73 print "done Logger 1" 88 74 self.logger = logging.getLogger(self.programName) 89 self.logger.setup(self.programName, self.logPath, self.name, host, pid, stdout, sendToFile) 75 print "done Logger 2" 76 if (self.name is None): 77 self.logger.setup(self.programName, self.logPath, "none", host, pid, stdout, sendToFile) 78 else: 79 self.logger.setup(self.programName, self.logPath, self.name, host, pid, stdout, sendToFile) 80 print "done Logger 3" 90 81 91 82 return self.logger 92 93 '''94 Prints the currently set DVO info95 '''96 def printDvoInfo(self):97 98 try:99 self.logger.infoPair("DVO label", self.dvoLabel)100 self.logger.infoPair("DVO location", self.dvoLocation)101 except:102 pass103 104 '''105 Prints datastore info106 '''107 def printDatastoreInfo(self):108 109 try:110 self.logger.infoBool("Datastore publishing?", self.datastorePublishing)111 if self.datastorePublishing:112 self.logger.infoPair("Datastore type", self.datastoreProduct)113 self.logger.infoPair("Datastore product", self.datastoreType)114 except:115 pass116 117 '''118 Prints the current deletion policy119 '''120 def printDeletionPolicy(self):121 122 try:123 self.logger.infoBool("Deleting local?", self.deleteLocal)124 self.logger.infoBool("Deleting datastore?", self.deleteDatastore)125 self.logger.infoBool("Deleting DXLayer?", self.deleteDxLayer)126 except:127 pass128 129 '''130 Prints the currently set RA/Dec bounding box131 '''132 def printBoxCoords(self):133 134 try:135 self.logger.infoPair("RA limits", "%.1f -> %.1f" % (self.minRa, self.maxRa))136 self.logger.infoPair("Dec limits", "%.1f -> %.1f" % (self.minDec, self.maxDec))137 self.logger.infoPair("Loading box size", "%.1f degrees" % self.boxSize)138 except:139 pass140 141 83 142 84 ''' … … 147 89 def getDbUser(self, dbType): return self.settingsDoc.find(dbType +"/user").text 148 90 def getDbPassword(self, dbType): return self.settingsDoc.find(dbType +"/password").text 149 -
branches/eam_branches/ipp-20121219/ippToPsps/jython/console.py
r33729 r35076 37 37 38 38 self.frame = JFrame( 39 "ippToPsps console for config '" + self.config.name + "'",39 "ippToPsps console for skychunk '" + self.skychunk.name + "'", 40 40 layout=BorderLayout(), 41 41 size=(1000, 500), … … 74 74 button = JButton('Purge dead', actionPerformed=self.purgeDead) 75 75 buttonPanel.add(button) 76 button = JButton('Change config', actionPerformed=self.changeConfig)76 button = JButton('Change skychunk', actionPerformed=self.changeSkychunk) 77 77 buttonPanel.add(button) 78 78 … … 136 136 self.ippToPspsDb.purgeDeadClients() 137 137 self.refreshClientTable(None) 138 def change Config(self, event):138 def changeSkychunk(self, event): 139 139 ids = self.getSelectedIds() 140 140 if len(ids) < 1: 141 141 JOptionPane.showMessageDialog(None, "No clients selected", "Error", JOptionPane.ERROR_MESSAGE) 142 142 return 143 comboBox = JComboBox(self.ippToPspsDb.getActive ConfigList())143 comboBox = JComboBox(self.ippToPspsDb.getActiveSkychunkList()) 144 144 if JOptionPane.showConfirmDialog(None, 145 145 comboBox, 146 "Choose a config",146 "Choose a skychunk", 147 147 JOptionPane.OK_CANCEL_OPTION, 148 148 JOptionPane.PLAIN_MESSAGE) == JOptionPane.CANCEL_OPTION: return 149 149 150 self.ippToPspsDb.set ConfigForLoaders(comboBox.getSelectedItem(), ids)150 self.ippToPspsDb.setSkychunkForLoaders(comboBox.getSelectedItem(), ids) 151 151 self.refreshClientTable(None) 152 152 -
branches/eam_branches/ipp-20121219/ippToPsps/jython/datastore.py
r33774 r35076 1 1 #!/usr/bin/env jython 2 # EAM : config -> skychunk DONE 2 3 3 4 from subprocess import call, PIPE, Popen … … 19 20 20 21 ''' 21 def __init__(self, logger, config, ippToPspsDb):22 def __init__(self, logger, skychunk, ippToPspsDb): 22 23 23 24 # setup logger 24 25 self.logger = logger 25 self. config = config26 self.skychunk = skychunk 26 27 self.ippToPspsDb = ippToPspsDb 27 28 … … 42 43 command = "dsreg --add " + name + "\ 43 44 --link --datapath " + path + "\ 44 --type " + self. config.datastoreType + "\45 --product " + self. config.datastoreProduct + "\45 --type " + self.skychunk.datastoreType + "\ 46 --product " + self.skychunk.datastoreProduct + "\ 46 47 --list " + tempFile.name 47 48 … … 75 76 --del " + name + " \ 76 77 --rm \ 77 --product " + self. config.datastoreProduct78 --product " + self.skychunk.datastoreProduct 78 79 79 80 p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE) -
branches/eam_branches/ipp-20121219/ippToPsps/jython/datastoreRemover.py
r33787 r35076 24 24 self.exitProgram("incorrect args") 25 25 26 self.datastore = Datastore(self.logger, self. config, self.ippToPspsDb)26 self.datastore = Datastore(self.logger, self.skychunk, self.ippToPspsDb) 27 27 28 28 ''' -
branches/eam_branches/ipp-20121219/ippToPsps/jython/detectionbatch.py
r35063 r35076 36 36 logger, 37 37 config, 38 skychunk, 38 39 gpc1Db, 39 40 ippToPspsDb, … … 46 47 logger, 47 48 config, 49 skychunk, 48 50 gpc1Db, 49 51 ippToPspsDb, … … 224 226 self.scratchDb.updateFilterID("FrameMeta", self.filter) 225 227 self.scratchDb.updateAllRows("FrameMeta", "calibModNum", str(self.calibModNum)) 226 self.scratchDb.updateAllRows("FrameMeta", "dataRelease", str(self. config.dataRelease))228 self.scratchDb.updateAllRows("FrameMeta", "dataRelease", str(self.skychunk.dataRelease)) 227 229 228 230 ''' … … 374 376 self.scratchDb.updateFilterID(tableName, self.filter) 375 377 self.scratchDb.updateAllRows(tableName, "calibModNum", str(self.calibModNum)) 376 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self. config.dataRelease))378 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease)) 377 379 if 'NASTRO' in header: self.totalNumPhotoRef = self.totalNumPhotoRef + int(header['NASTRO']) 378 380 self.scratchDb.replaceNullsInThisColumn(tableName, "polyOrder", "0") … … 472 474 , '" + self.dateStr + "' \ 473 475 , 0 \ 474 , " + str(self. config.dataRelease) + "\476 , " + str(self.skychunk.dataRelease) + "\ 475 477 FROM " + ippTableName 476 478 # self.logger.info(sql) … … 526 528 self.scratchDb.execute(sql) 527 529 528 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self. config.dataRelease))530 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease)) 529 531 530 532 ''' … … 571 573 WHERE a.objID = b.objID AND a.detectID = b.detectID" 572 574 self.scratchDb.execute(sql) 573 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self. config.dataRelease))575 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease)) 574 576 575 577 ''' … … 607 609 b.expTime, \ 608 610 b.airMass, \ 609 " + str(self. config.dataRelease) + " \611 " + str(self.skychunk.dataRelease) + " \ 610 612 FROM \ 611 613 Detection_" + ota + " as a \ … … 647 649 648 650 self.scratchDb.updateAllRows(tableName, "calibModNum", str(self.calibModNum)) 649 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self. config.dataRelease))651 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease)) 650 652 651 653 ''' -
branches/eam_branches/ipp-20121219/ippToPsps/jython/dvo.py
r35063 r35076 33 33 34 34 ''' 35 def __init__(self, logger, config, s cratchDbName=None):35 def __init__(self, logger, config, skychunk, scratchDbName=None): 36 36 37 37 # set up logging 38 38 self.logger = logger 39 39 self.config = config 40 self.skychunk = skychunk 40 41 41 42 # set up empty lists … … 57 58 58 59 # decide if we are using the right DVO for this scratchDb 59 self.correctDvo = self.scratchDb.isCorrectDvo(self. config.dvoLocation)60 self.correctDvo = self.scratchDb.isCorrectDvo(self.skychunk.dvoLocation) 60 61 61 62 # this scratch Db either has no DVO info ingested, or a different DVO ingested. Prompt user 62 63 if not self.correctDvo: 63 64 print "*******************************************************************************" 64 self.logger.warning("Wrong or no DVO in use. Do you want to reset and use '" + self. config.dvoLocation + "'?")65 self.logger.warning("Wrong or no DVO in use. Do you want to reset and use '" + self.skychunk.dvoLocation + "'?") 65 66 response = raw_input("(y/n) ") 66 67 if response == "y": … … 104 105 105 106 # check if we have up-to-date version 106 path = self. config.dvoLocation + "/Photcodes.dat"107 path = self.skychunk.dvoLocation + "/Photcodes.dat" 107 108 if self.scratchDb.alreadyImportedThisDvoTable(path): 108 109 self.logger.debugPair("DVO Photcodes.dat file", "up-to-date") … … 129 130 130 131 # check if we have up-to-date version 131 path = self. config.dvoLocation + "/Images.dat"132 path = self.skychunk.dvoLocation + "/Images.dat" 132 133 if self.scratchDb.alreadyImportedThisDvoTable(path): 133 134 self.logger.debugPair("DVO Images.dat file", "up-to-date") … … 154 155 if not self.correctDvo: return False 155 156 156 path = self. config.dvoLocation + "/SkyTable.fits"157 path = self.skychunk.dvoLocation + "/SkyTable.fits" 157 158 if self.scratchDb.alreadyImportedThisDvoTable(path): 158 159 self.logger.debugPair("DVO SkyTable.fits file", "up-to-date") … … 185 186 cmd += " -dbuser " + self.scratchDb.dbUser 186 187 cmd += " -dbpass " + self.scratchDb.dbPass 187 cmd += " -D CATDIR " + self. config.dvoLocation188 cmd += " -D CATDIR " + self.skychunk.dvoLocation 188 189 189 190 self.logger.infoPair("Running dvopsps", cmd) … … 196 197 197 198 self.scratchDb.setImportedThisDvoTable(path) 198 self.logger.infoPair("Finished importing SkyTable at", self. config.dvoLocation)199 self.logger.infoPair("Finished importing SkyTable at", self.skychunk.dvoLocation) 199 200 200 201 return True … … 259 260 paths = [] 260 261 for fileType in self.ingestFileTypes: 261 paths.append(self. config.dvoLocation + "/" + regionPath + "." + fileType)262 paths.append(self.skychunk.dvoLocation + "/" + regionPath + "." + fileType) 262 263 263 264 # check for the existence of all interested file types … … 332 333 # go no further if we've already partly ingested a different DVO 333 334 if not self.correctDvo: 334 self.logger.infoPair("Wrong DVO in use", self. config.dvoLocation)335 self.logger.infoPair("Wrong DVO in use", self.skychunk.dvoLocation) 335 336 return 336 337 … … 418 419 # get combined size of all interested files 419 420 for fileType in self.ingestFileTypes: 420 size = size + self.getDiskSize(self. config.dvoLocation + "/" + region + "." + fileType)421 size = size + self.getDiskSize(self.skychunk.dvoLocation + "/" + region + "." + fileType) 421 422 # EAM TEST I/O 422 423 self.logger.infoPair(fileType, size) … … 570 571 def nativeIngestDetections(self, raCenter, decCenter, boxSize): 571 572 572 # XXX put the chunk below in a separate method573 # XXX put the skychunk below in a separate method 573 574 574 575 # drop detections table … … 610 611 cmd += " -dbuser " + self.scratchDb.dbUser 611 612 cmd += " -dbpass " + self.scratchDb.dbPass 612 cmd += " -D CATDIR " + self. config.dvoLocation613 cmd += " -D CATDIR " + self.skychunk.dvoLocation 613 614 cmd += " -region " 614 615 cmd += " " + str(raCenter-halfSize) … … 617 618 cmd += " " + str(decCenter+halfSize) 618 619 619 if self. config.parallel:620 if self.skychunk.parallel: 620 621 cmd += " -parallel" 621 622 -
branches/eam_branches/ipp-20121219/ippToPsps/jython/dvodetections.py
r35016 r35076 20 20 Constructor 21 21 ''' 22 def __init__(self, logger, config, s cratchDbName):22 def __init__(self, logger, config, skychunk, scratchDbName): 23 23 24 super(DvoDetections, self).__init__(logger, config, s cratchDbName)24 super(DvoDetections, self).__init__(logger, config, skychunk, scratchDbName) 25 25 26 26 # declare DVO file types of interest … … 32 32 def ingestRegion(self, region): 33 33 34 cpmPath = self. config.dvoLocation + "/" + region + ".cpm"35 cptPath = self. config.dvoLocation + "/" + region + ".cpt"34 cpmPath = self.skychunk.dvoLocation + "/" + region + ".cpm" 35 cptPath = self.skychunk.dvoLocation + "/" + region + ".cpt" 36 36 37 37 cpmTableName = self.scratchDb.getDbFriendlyTableName(region + ".cpm") -
branches/eam_branches/ipp-20121219/ippToPsps/jython/dvoobjects.py
r35063 r35076 12 12 from dvo import Dvo 13 13 14 15 14 ''' 16 15 A class for ingesting DVO detections into MySQL … … 21 20 Constructor 22 21 ''' 23 def __init__(self, logger, config, s cratchDbName=None):22 def __init__(self, logger, config, skychunk, scratchDbName=None): 24 23 25 super(DvoObjects, self).__init__(logger, config, s cratchDbName)24 super(DvoObjects, self).__init__(logger, config, skychunk, scratchDbName) 26 25 27 26 # declare DVO file types of interest … … 38 37 for fileType in self.ingestFileTypes: 39 38 40 path = self. config.dvoLocation + "/" + region + "." + fileType39 path = self.skychunk.dvoLocation + "/" + region + "." + fileType 41 40 tableName = self.scratchDb.getDbFriendlyTableName(region + "." + fileType) 42 41 … … 64 63 cmd += " -dbuser " + self.scratchDb.dbUser 65 64 cmd += " -dbpass " + self.scratchDb.dbPass 66 cmd += " -D CATDIR " + self. config.dvoLocation65 cmd += " -D CATDIR " + self.skychunk.dvoLocation 67 66 cmd += " -cpt " + region 68 67 69 if self. config.parallel:68 if self.skychunk.parallel: 70 69 cmd += " -parallel" 71 70 -
branches/eam_branches/ipp-20121219/ippToPsps/jython/initbatch.py
r33727 r35076 28 28 logger, 29 29 config, 30 skychunk, 30 31 gpc1Db, 31 32 ippToPspsDb, … … 34 35 super(InitBatch, self).__init__(logger, 35 36 config, 37 skychunk, 36 38 gpc1Db, 37 39 ippToPspsDb, -
branches/eam_branches/ipp-20121219/ippToPsps/jython/ipptopsps.py
r35063 r35076 1 1 #!/usr/bin/env jython 2 # EAM : config -> skychunk DONE 2 3 3 4 import signal … … 9 10 10 11 from config import Config 12 from skychunk import Skychunk 11 13 from pslogger import PSLogger 12 14 from ipptopspsdb import IppToPspsDb … … 23 25 def __init__(self, argv, logToStdout=1, logToFile=0): 24 26 25 testmode = False 26 for arg in sys.argv: 27 if arg == "-test": 28 testmode = True 29 sys.argv.remove(arg) 30 if arg == "-t": 31 testmode = True 32 sys.argv.remove(arg) 33 34 # are the arsg ok? all programs require a config name 27 # set up config object (global config information, also parse command-line options, eg -test / -t) 28 self.config = Config() 29 30 # are the args ok? all programs require a config name 35 31 if len(sys.argv) < 2: 36 32 self.printUsage() … … 38 34 39 35 # some class constants 40 self.PROGNAME = os.path.basename(sys.argv[0])41 CONFIGNAME = sys.argv[1]42 36 self.HOST = socket.gethostname() 43 37 self.PID = os.getpid() … … 47 41 self.SECONDS = None 48 42 49 self.configDir = os.getenv("IPPTOPSPS_DATA")50 if self.configDir is not None:51 self.configDir = self.configDir + "/"52 53 self.createNewConfig = False54 self.rotateConfigs = False55 # a new config?56 if CONFIGNAME == "edit": self.createNewConfig = True57 # should we rotate configs for this program?58 elif CONFIGNAME == "all": self.rotateConfigs = True59 60 # set up config object61 self.config = Config(self.PROGNAME, CONFIGNAME, self.configDir)62 self.config.test = testmode63 64 if self.config.test: print "using test mode"65 else: print "not using test mode"66 67 43 self.logger = self.config.getLogger(self.HOST, self.PID, logToStdout, logToFile) 68 44 45 # argv[1] -> self.skychunk.name 46 self.skychunk = Skychunk(self.logger) 47 print "here... " 48 69 49 # create connection to databases database 70 50 try: 71 self.ippToPspsDb = IppToPspsDb(self.logger, self.config )51 self.ippToPspsDb = IppToPspsDb(self.logger, self.config, self.skychunk) 72 52 except: 73 53 self.exitProgram("Could not connect to ipptopsps Db") 74 54 raise 75 55 56 print "here... " 57 76 58 self.checkClientStatus() 59 print "here... " 77 60 78 61 # catch Ctrl-C signal 79 62 signal.signal(signal.SIGINT, self.signal_handler) 63 print "here... " 80 64 81 65 # title for log 82 66 self.logger.infoSeparator() 83 self.logger.infoTitle("ippToPsps '" + self. PROGNAME+ "' started")67 self.logger.infoTitle("ippToPsps '" + self.config.programName + "' started") 84 68 self.logger.infoPair("Host", self.HOST) 85 69 self.logger.infoPair("PID", "%d" % self.PID) 86 self.logger.infoPair("Config", self.config.name) 70 self.logger.infoPair("Skychunk", self.skychunk.name) 71 print "here... " 87 72 88 73 ''' … … 122 107 123 108 # write message to log or stdout if no logger set up 124 msg = sys.argv[0] + " < configName|all|edit> " + extra109 msg = sys.argv[0] + " <skychunkName|all|edit> " + extra 125 110 try: 126 111 self.logger.errorPair("Usage:", msg) … … 129 114 130 115 ''' 131 Refreshes the config then recreates objects with new settings 132 ''' 133 def refreshConfig(self): 134 135 # new config? 136 if self.createNewConfig: 137 self.ippToPspsDb.editConfig() 138 self.ippToPspsDb.setConfigForThisClient(self.config.name, self.HOST, self.PID) 139 self.createNewConfig = False 140 141 # if we are rotating configs, then look for next active one in list 142 if self.rotateConfigs: 143 self.ippToPspsDb.getConfigForThisClient(self.HOST, self.PID) 144 configs = self.ippToPspsDb.getActiveConfigList() 116 Refreshes the skychunk then recreates objects with new settings 117 ''' 118 def refreshSkychunk(self): 119 120 print "refresh... " 121 print "self.skychunk.createNewSkychunk: ", self.skychunk.createNewSkychunk 122 123 # new skychunk? 124 if self.skychunk.createNewSkychunk: 125 print "self.skychunk.createNewSkychunk: ", self.skychunk.createNewSkychunk 126 self.ippToPspsDb.editSkychunk() 127 print "self.skychunk.createNewSkychunk: ", self.skychunk.createNewSkychunk 128 self.ippToPspsDb.setSkychunkForThisClient(self.skychunk.name, self.HOST, self.PID) 129 print "self.skychunk.createNewSkychunk: ", self.skychunk.createNewSkychunk 130 self.skychunk.createNewSkychunk = False 131 132 print "refresh... " 133 # if we are rotating skychunks, then look for next active one in list 134 if self.skychunk.rotateSkychunks: 135 self.ippToPspsDb.getSkychunkForThisClient(self.HOST, self.PID) 136 skychunks = self.ippToPspsDb.getActiveSkychunkList() 145 137 146 138 i = 1 147 for config in configs:148 if config == self.config.name: break139 for skychunk in skychunks: 140 if skychunk == self.skychunk.name: break 149 141 i += 1 150 142 151 if i >= len(configs): newConfig = configs[0] 152 else: newConfig = configs[i] 153 154 self.ippToPspsDb.setConfigForThisClient(newConfig, self.HOST, self.PID) 155 156 return self.ippToPspsDb.readConfig(self.HOST, self.PID) 157 158 ''' 159 All implementing subclasses (programs) should call this method once in a while to see if it should be paused or killed, otherwise this updates the clients table with current time and reloads the config data 143 if i >= len(skychunks): newSkychunk = skychunks[0] 144 else: newSkychunk = skychunks[i] 145 146 self.ippToPspsDb.setSkychunkForThisClient(newSkychunk, self.HOST, self.PID) 147 148 print "refresh... " 149 return self.ippToPspsDb.readSkychunk(self.HOST, self.PID) 150 151 ''' 152 All implementing subclasses (programs) should call this method once in a while to see if it should be paused or killed, otherwise this updates the clients table with current time and reloads the skychunk data 160 153 ''' 161 154 def checkClientStatus(self): 162 155 163 self.ippToPspsDb.updateClient(self.PROGNAME, self.HOST, self.PID) 164 156 print "stat... " 157 self.ippToPspsDb.updateClient(self.config.programName, self.HOST, self.PID) 158 159 print "stat... " 165 160 if self.ippToPspsDb.isKilled(self.HOST, self.PID): 166 161 self.exitProgram("killed via Db") 167 162 168 # this loop pauses the process if we have no configor we have set it to pause163 # this loop pauses the process if we have no skychunk or we have set it to pause 169 164 firstTimeIn = True 170 while not self.refreshConfig() or self.ippToPspsDb.isPaused(self.HOST, self.PID): 171 172 self.ippToPspsDb.updateClient(self.PROGNAME, self.HOST, self.PID) 165 print "stat... " 166 while not self.refreshSkychunk() or self.ippToPspsDb.isPaused(self.HOST, self.PID): 167 168 print "stat... " 169 self.ippToPspsDb.updateClient(self.config.programName, self.HOST, self.PID) 173 170 if self.ippToPspsDb.isKilled(self.HOST, self.PID): 174 171 self.exitProgram("killed while paused") … … 177 174 time.sleep(self.PAUSEPERIOD) 178 175 176 print "stat done... " 177 179 178 180 179 ''' … … 193 192 # write message to log or stdout if no logger set up 194 193 try: 195 self.logger.infoPair(self. PROGNAME+ " exited", exitReason)194 self.logger.infoPair(self.config.programName + " exited", exitReason) 196 195 except: 197 196 print "*** Program exited: " + exitReason … … 204 203 205 204 sys.exit(0) 206 207 -
branches/eam_branches/ipp-20121219/ippToPsps/jython/ipptopspsdb.py
r35063 r35076 17 17 Constructor 18 18 ''' 19 def __init__(self, logger, config ):19 def __init__(self, logger, config, skychunk): 20 20 if (config.test): 21 21 dbType = "ipptopspsdatabase_test" … … 24 24 super(IppToPspsDb, self).__init__(logger, config, dbType) 25 25 26 self.skychunk = skychunk 27 26 28 self.MAX_FAILS = 5 27 29 … … 33 35 sql = "SELECT DISTINCT batch_id \ 34 36 FROM batch \ 35 WHERE timestamp > '" + self. config.epoch + "' \37 WHERE timestamp > '" + self.skychunk.epoch + "' \ 36 38 AND batch_type = '" + batchType + "' \ 37 AND dvo_db = '" + self. config.dvoLabel + "' \39 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 38 40 AND merged = 1 \ 39 41 AND " + column + " = 0" … … 58 60 sql = "SELECT DISTINCT batch_id \ 59 61 FROM batch \ 60 WHERE timestamp > '" + self. config.epoch + "' \62 WHERE timestamp > '" + self.skychunk.epoch + "' \ 61 63 AND batch_type = '" + batchType + "' \ 62 AND dvo_db = '" + self. config.dvoLabel + "' \64 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 63 65 AND purged = 1 \ 64 66 AND " + column + " = 0" … … 84 86 sql = "SELECT DISTINCT batch_id \ 85 87 FROM batch \ 86 WHERE timestamp > '" + self. config.epoch + "' \88 WHERE timestamp > '" + self.skychunk.epoch + "' \ 87 89 AND batch_type = '" + batchType + "' \ 88 AND dvo_db = '" + self. config.dvoLabel + "' \90 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 89 91 AND (loaded_to_ODM = -1 OR merge_worthy = 1) \ 90 92 AND " + column + " = 0" … … 152 154 sql = "SELECT DISTINCT batch_id \ 153 155 FROM batch \ 154 WHERE timestamp > '" + self. config.epoch + "' \156 WHERE timestamp > '" + self.skychunk.epoch + "' \ 155 157 AND batch_type = '" + batchType + "' \ 156 AND dvo_db = '" + self. config.dvoLabel + "' \158 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 157 159 AND processed = 1\ 158 160 AND loaded_to_datastore != 1 \ … … 181 183 sql = "SELECT batch_id \ 182 184 FROM batch \ 183 WHERE timestamp > '" + self. config.epoch + "' \184 AND dvo_db = '" + self. config.dvoLabel + "' \185 WHERE timestamp > '" + self.skychunk.epoch + "' \ 186 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 185 187 AND loaded_to_datastore = 1 \ 186 188 AND batch_type = '" + batchType + "' \ … … 210 212 sql = "SELECT batch_id \ 211 213 FROM batch \ 212 WHERE timestamp > '" + self. config.epoch + "' \213 AND dvo_db = '" + self. config.dvoLabel + "' \214 WHERE timestamp > '" + self.skychunk.epoch + "' \ 215 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 214 216 AND loaded_to_datastore = 1 \ 215 217 AND batch_type = '" + batchType + "' \ … … 239 241 sql = "SELECT batch_id \ 240 242 FROM batch \ 241 WHERE timestamp > '" + self. config.epoch + "' \242 AND dvo_db = '" + self. config.dvoLabel + "' \243 WHERE timestamp > '" + self.skychunk.epoch + "' \ 244 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 243 245 AND merge_worthy = 1 \ 244 246 AND batch_type = '" + batchType + "' \ … … 266 268 sql = "SELECT DISTINCT batch_id \ 267 269 FROM batch \ 268 WHERE timestamp > '" + self. config.epoch + "' \269 AND dvo_db = '" + self. config.dvoLabel + "' \270 WHERE timestamp > '" + self.skychunk.epoch + "' \ 271 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 270 272 AND " + column + " = " + str(value) 271 273 … … 292 294 FROM batch \ 293 295 WHERE batch_type = '" + batchType + "' \ 294 AND timestamp > '" + self. config.epoch + "' \295 AND dvo_db = '" + self. config.dvoLabel + "' \296 AND timestamp > '" + self.skychunk.epoch + "' \ 297 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 296 298 AND processed = 1 \ 297 299 AND loaded_to_datastore = 1 \ … … 319 321 FROM batch \ 320 322 WHERE batch_type = '" + batchType + "' \ 321 AND timestamp > '" + self. config.epoch + "' \322 AND dvo_db = '" + self. config.dvoLabel + "' \323 AND timestamp > '" + self.skychunk.epoch + "' \ 324 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 323 325 AND " + column + " = " + str(value) 324 326 … … 391 393 WHERE batch_type = '" + batchType + "' \ 392 394 AND processed = 1 \ 393 AND timestamp > '" + self. config.epoch + "' \394 AND dvo_db = '" + self. config.dvoLabel + "' \395 AND timestamp > '" + self.skychunk.epoch + "' \ 396 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 395 397 AND timestamp BETWEEN now() - INTERVAL " + interval + " AND now()" 396 398 … … 416 418 WHERE batch_type = '" + batchType + "' \ 417 419 AND loaded_to_datastore = 1 \ 418 AND timestamp > '" + self. config.epoch + "' \419 AND dvo_db = '" + self. config.dvoLabel + "' \420 AND timestamp > '" + self.skychunk.epoch + "' \ 421 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 420 422 ORDER BY timestamp DESC LIMIT 1" 421 423 … … 515 517 WHERE stage_id = " + str(stage_id) + " \ 516 518 AND batch_type = '" + batchType + "' \ 517 AND dvo_db = '" + self. config.dvoLabel + "' \519 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 518 520 AND batch_type != 'IN' \ 519 521 AND timestamp BETWEEN now() - INTERVAL 12 HOUR AND now()" … … 558 560 WHERE stage_id = " + str(stage_id) + " \ 559 561 AND batch_type = '" + batchType + "' \ 560 AND timestamp > '" + self. config.epoch + "' \561 AND dvo_db = '" + self. config.dvoLabel + "' \562 AND timestamp > '" + self.skychunk.epoch + "' \ 563 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 562 564 AND batch_type != 'IN' \ 563 565 AND processed = 1" … … 583 585 WHERE stage_id = " + str(stage_id) + " \ 584 586 AND batch_type = '" + batchType + "' \ 585 AND timestamp > '" + self. config.epoch + "' \586 AND dvo_db = '" + self. config.dvoLabel + "' \587 AND timestamp > '" + self.skychunk.epoch + "' \ 588 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 587 589 AND processed = -1" 588 590 … … 606 608 FROM batch \ 607 609 WHERE batch_type = '" + batchType + "' \ 608 AND timestamp > '" + self. config.epoch + "' \609 AND dvo_db = '" + self. config.dvoLabel + "' \610 AND timestamp > '" + self.skychunk.epoch + "' \ 611 AND dvo_db = '" + self.skychunk.dvoLabel + "' \ 610 612 AND processed = -1 \ 611 613 GROUP BY stage_id HAVING numoccur >= " + str(self.MAX_FAILS) … … 638 640 batchID = -1; 639 641 640 if self. config.force or \642 if self.skychunk.force or \ 641 643 (not self.alreadyProcessed(batchType, stageID) \ 642 644 and not self.processingNow(batchType, stageID) \ … … 654 656 '" + batchType + "', \ 655 657 " + str(stageID) + ", \ 656 '" + self. config.survey + "', \657 '" + self. config.dvoLabel + "', \658 '" + self. config.datastoreProduct + "' \658 '" + self.skychunk.survey + "', \ 659 '" + self.skychunk.dvoLabel + "', \ 660 '" + self.skychunk.datastoreProduct + "' \ 659 661 )" 660 662 self.logger.infoPair("heather:","sql") … … 753 755 754 756 ''' 755 Sets the configfield for this client756 ''' 757 def set ConfigForThisClient(self, config, host, pid):758 759 self.execute("UPDATE clients SET config = '" + config+ "' \757 Sets the skychunk field for this client 758 ''' 759 def setSkychunkForThisClient(self, skychunk, host, pid): 760 761 self.execute("UPDATE clients SET skychunk = '" + skychunk + "' \ 760 762 WHERE host = '" + host + "' \ 761 763 AND pid = " + str(pid)) 762 764 763 765 ''' 764 Sets the configfield for a set of loader clients765 ''' 766 def set ConfigForLoaders(self, config, ids):766 Sets the skychunk field for a set of loader clients 767 ''' 768 def setSkychunkForLoaders(self, skychunk, ids): 767 769 768 770 for id in ids: 769 self.execute("UPDATE clients SET config = '" + config+ "' \771 self.execute("UPDATE clients SET skychunk = '" + skychunk + "' \ 770 772 WHERE type = 'loader.py' \ 771 773 AND id = " + str(id)) … … 801 803 ''' 802 804 def insertClient(self, type, host, pid): 803 self.execute("INSERT INTO clients (timestamp, type, host, pid, config) VALUES (now(), '" + type + "', '" + host + "', " + str(pid) + ", '" + self.config.name + "')")805 self.execute("INSERT INTO clients (timestamp, type, host, pid, skychunk) VALUES (now(), '" + type + "', '" + host + "', " + str(pid) + ", '" + self.skychunk.name + "')") 804 806 805 807 ''' … … 845 847 846 848 ''' 847 Returns a list of available configs848 ''' 849 def getActive ConfigList(self):849 Returns a list of available skychunks 850 ''' 851 def getActiveSkychunkList(self): 850 852 851 sql = "SELECT DISTINCT name FROM configWHERE active = 1 ORDER BY name"852 853 configs = []854 try: 855 rs = self.executeQuery(sql) 856 while (rs.next()): configs.append(rs.getString(1))857 except: 858 self.logger.errorPair("Can't get confignames", sql)853 sql = "SELECT DISTINCT name FROM skychunk WHERE active = 1 ORDER BY name" 854 855 skychunks = [] 856 try: 857 rs = self.executeQuery(sql) 858 while (rs.next()): skychunks.append(rs.getString(1)) 859 except: 860 self.logger.errorPair("Can't get skychunk names", sql) 859 861 finally: 860 862 rs.close() 861 863 862 return configs863 864 ''' 865 Prompts user for info about a new or existing configand lets them neter the various details866 ''' 867 def edit Config(self):864 return skychunks 865 866 ''' 867 Prompts user for info about a new or existing skychunk and lets them neter the various details 868 ''' 869 def editSkychunk(self): 868 870 869 871 print " ********************************************************************" 870 print " * Configeditor"872 print " * Skychunk editor" 871 873 print " *" 872 response = raw_input(" * Name for new config, or existing configto edit? ")874 response = raw_input(" * Name for new skychunk, or existing skychunk to edit? ") 873 875 if response == "": return 874 self. config.name = response875 876 # attempt to insert new config, if it already exists then carry on with update877 sql = "INSERT INTO config (name) VALUES ('" + self.config.name + "')"876 self.skychunk.name = response 877 878 # attempt to insert new skychunk, if it already exists then carry on with update 879 sql = "INSERT INTO skychunk (name) VALUES ('" + self.skychunk.name + "')" 878 880 try: 879 881 self.execute(sql) 880 882 except: pass 881 883 882 # for each column in the configtable883 sql = "SHOW COLUMNS FROM config"884 # for each column in the skychunk table 885 sql = "SHOW COLUMNS FROM skychunk" 884 886 rs = self.executeQuery(sql) 885 887 while (rs.next()): … … 895 897 # get current value for this field, if any 896 898 try: 897 rs2 = self.executeQuery("SELECT " + field + " FROM config WHERE name = '" + self.config.name + "'")899 rs2 = self.executeQuery("SELECT " + field + " FROM skychunk WHERE name = '" + self.skychunk.name + "'") 898 900 rs2.first() 899 901 default = rs2.getString(1) … … 912 914 if type.find("varchar") != -1 or type.find("timestamp") != -1: quotes = "'" 913 915 else: quotes = "" 914 self.execute("UPDATE config SET " + field + " = " + quotes + response + quotes + " WHERE name = '" + self.config.name + "'")916 self.execute("UPDATE skychunk SET " + field + " = " + quotes + response + quotes + " WHERE name = '" + self.skychunk.name + "'") 915 917 916 918 print " *" … … 918 920 919 921 ''' 920 Returns configfor this client921 ''' 922 def get ConfigForThisClient(self, host, pid):923 924 sql = "SELECT config\922 Returns skychunk for this client 923 ''' 924 def getSkychunkForThisClient(self, host, pid): 925 926 sql = "SELECT skychunk \ 925 927 FROM clients \ 926 928 WHERE host = '" + host + "' \ … … 930 932 rs = self.executeQuery(sql) 931 933 rs.first() 932 self. config.name = rs.getString(1)933 except: 934 self.logger.errorPair("No configset for", "%s (pid=%d)" % (host, pid))935 self. config.isLoaded = False934 self.skychunk.name = rs.getString(1) 935 except: 936 self.logger.errorPair("No skychunk set for", "%s (pid=%d)" % (host, pid)) 937 self.skychunk.isLoaded = False 936 938 return False 937 939 … … 939 941 940 942 ''' 941 Reads config from the database and populates Configobject942 ''' 943 def read Config(self, host, pid):944 945 # first get configdefined for this client946 if not self.get ConfigForThisClient(host, pid): return False947 948 # now load that config943 Reads skychunk from the database and populates Skychunk object 944 ''' 945 def readSkychunk(self, host, pid): 946 947 # first get skychunk defined for this client 948 if not self.getSkychunkForThisClient(host, pid): return False 949 950 # now load that skychunk 949 951 sql = "SELECT \ 950 952 datastore_product \ … … 970 972 ,queue_OB \ 971 973 ,parallel \ 972 FROM config\973 WHERE name = '" + self. config.name + "'"974 975 self. config.batchTypes = []974 FROM skychunk \ 975 WHERE name = '" + self.skychunk.name + "'" 976 977 self.skychunk.batchTypes = [] 976 978 try: 977 979 rs = self.executeQuery(sql) 978 980 979 981 rs.first() 980 self. config.datastoreProduct = rs.getString(1)981 self. config.datastoreType = rs.getString(2)982 if rs.getInt(3) == 1: self. config.datastorePublishing = True983 else: self. config.datastorePublishing = False984 self. config.dvoLabel = rs.getString(4)982 self.skychunk.datastoreProduct = rs.getString(1) 983 self.skychunk.datastoreType = rs.getString(2) 984 if rs.getInt(3) == 1: self.skychunk.datastorePublishing = True 985 else: self.skychunk.datastorePublishing = False 986 self.skychunk.dvoLabel = rs.getString(4) 985 987 986 988 # if dvoLabel is null is can break queries, so set to something 987 if not self. config.dvoLabel: self.config.dvoLabel = "none"988 self. config.dvoLocation = rs.getString(5)989 self. config.minRa = rs.getDouble(6)990 self. config.maxRa = rs.getDouble(7)991 self. config.minDec = rs.getDouble(8)992 self. config.maxDec = rs.getDouble(9)993 994 self. config.boxSize = rs.getDouble(10)995 self. config.halfBox = self.config.boxSize/2.0996 self. config.boxSizeWithBorder = self.config.boxSize + (self.config.BORDER * 2)997 998 self. config.basePath = rs.getString(11)999 self. config.dataRelease = rs.getInt(12)1000 1001 self. config.deleteLocal = rs.getInt(13)1002 self. config.deleteDatastore = rs.getInt(14)1003 self. config.deleteDxLayer = rs.getInt(15)1004 1005 self. config.epoch = rs.getString(16)1006 1007 self. config.survey = rs.getString(17)1008 self. config.pspsSurvey = rs.getString(18)1009 1010 if rs.getInt(19) == 1: self. config.batchTypes.append("P2")1011 if rs.getInt(20) == 1: self. config.batchTypes.append("ST")1012 if rs.getInt(21) == 1: self. config.batchTypes.append("OB")1013 1014 self. config.force = True # TODO1015 self. config.parallel = False # TODO1016 1017 if rs.getInt(22) == 1: self. config.parallel = True1018 1019 if self. config.parallel: print "USING parallel"1020 self. config.isLoaded = True1021 except: 1022 self.logger.errorPair("Could not read config with name", self.config.name)1023 self. config.isLoaded = False1024 1025 return self. config.isLoaded989 if not self.skychunk.dvoLabel: self.skychunk.dvoLabel = "none" 990 self.skychunk.dvoLocation = rs.getString(5) 991 self.skychunk.minRa = rs.getDouble(6) 992 self.skychunk.maxRa = rs.getDouble(7) 993 self.skychunk.minDec = rs.getDouble(8) 994 self.skychunk.maxDec = rs.getDouble(9) 995 996 self.skychunk.boxSize = rs.getDouble(10) 997 self.skychunk.halfBox = self.skychunk.boxSize/2.0 998 self.skychunk.boxSizeWithBorder = self.skychunk.boxSize + (self.skychunk.BORDER * 2) 999 1000 self.skychunk.basePath = rs.getString(11) 1001 self.skychunk.dataRelease = rs.getInt(12) 1002 1003 self.skychunk.deleteLocal = rs.getInt(13) 1004 self.skychunk.deleteDatastore = rs.getInt(14) 1005 self.skychunk.deleteDxLayer = rs.getInt(15) 1006 1007 self.skychunk.epoch = rs.getString(16) 1008 1009 self.skychunk.survey = rs.getString(17) 1010 self.skychunk.pspsSurvey = rs.getString(18) 1011 1012 if rs.getInt(19) == 1: self.skychunk.batchTypes.append("P2") 1013 if rs.getInt(20) == 1: self.skychunk.batchTypes.append("ST") 1014 if rs.getInt(21) == 1: self.skychunk.batchTypes.append("OB") 1015 1016 self.skychunk.force = True # TODO 1017 self.skychunk.parallel = False # TODO 1018 1019 if rs.getInt(22) == 1: self.skychunk.parallel = True 1020 1021 if self.skychunk.parallel: print "USING parallel" 1022 self.skychunk.isLoaded = True 1023 except: 1024 self.logger.errorPair("Could not read skychunk with name", self.skychunk.name) 1025 self.skychunk.isLoaded = False 1026 1027 return self.skychunk.isLoaded 1026 1028 1027 1029 ''' … … 1031 1033 1032 1034 sql = "SELECT id FROM box \ 1033 WHERE config = '" + self.config.name + "' \1035 WHERE skychunk = '" + self.skychunk.name + "' \ 1034 1036 AND ra_center = " + str(ra) + " \ 1035 1037 AND dec_center = " + str(dec) + " \ 1036 AND box_side = " + str(self. config.boxSize)1038 AND box_side = " + str(self.skychunk.boxSize) 1037 1039 1038 1040 id = -1 … … 1050 1052 ''' 1051 1053 def removeAllBoxes(self): 1052 self.execute("DELETE FROM box WHERE config = '" + self.config.name + "'")1054 self.execute("DELETE FROM box WHERE skychunk = '" + self.skychunk.name + "'") 1053 1055 1054 1056 ''' … … 1063 1065 1064 1066 sql = "INSERT INTO box \ 1065 ( config, ra_center, dec_center, box_side) \1067 (skychunk, ra_center, dec_center, box_side) \ 1066 1068 VALUES \ 1067 ('" + self. config.name + "', " + str(ra) + ", " + str(dec) + ", " + str(self.config.boxSize) + ")"1069 ('" + self.skychunk.name + "', " + str(ra) + ", " + str(dec) + ", " + str(self.skychunk.boxSize) + ")" 1068 1070 1069 1071 self.execute(sql) … … 1104 1106 FROM box \ 1105 1107 JOIN pending ON (id = box_id) \ 1106 WHERE config = '" + self.config.name + "' \1108 WHERE skychunk = '" + self.skychunk.name + "' \ 1107 1109 AND batch_type = '" + batchType + "' \ 1108 1110 AND ra_center NOT IN \ 1109 1111 (SELECT ra_center \ 1110 1112 FROM stripe \ 1111 WHERE config = '" + self.config.name + "') \1113 WHERE skychunk = '" + self.skychunk.name + "') \ 1112 1114 GROUP BY ra_center LIMIT 1" 1113 1115 … … 1124 1126 FROM box \ 1125 1127 JOIN pending ON (id = box_id) \ 1126 WHERE config = '" + self.config.name + "' \1128 WHERE skychunk = '" + self.skychunk.name + "' \ 1127 1129 AND batch_type = '" + batchType + "' \ 1128 1130 GROUP BY ra_center \ … … 1144 1146 WHERE ra_center = " + str(raCenter) + " \ 1145 1147 AND batch_type = '" + batchType + "' \ 1146 AND config = '" + self.config.name + "' \1148 AND skychunk = '" + self.skychunk.name + "' \ 1147 1149 ORDER BY dec_center DESC" 1148 1150 … … 1177 1179 # now insert new stripe entry 1178 1180 sql = "INSERT INTO stripe \ 1179 (client_id, config, ra_center) \1180 SELECT clients.id, clients. config, " + str(raCenter) + " \1181 (client_id, skychunk, ra_center) \ 1182 SELECT clients.id, clients.skychunk, " + str(raCenter) + " \ 1181 1183 FROM clients \ 1182 1184 WHERE host = '" + host + "' \ … … 1206 1208 1207 1209 ''' 1208 Returns ids for pending items for this config1210 Returns ids for pending items for this skychunk 1209 1211 ''' 1210 1212 def getPendingIds(self, batchType): … … 1213 1215 FROM pending \ 1214 1216 JOIN box ON (box_id = id) \ 1215 WHERE config = '" + self.config.name + "' \1217 WHERE skychunk = '" + self.skychunk.name + "' \ 1216 1218 AND batch_type = '" + batchType + "'" 1217 1219 … … 1222 1224 rs.close() 1223 1225 except: 1224 self.logger.errorPair("Can't get pending ids for this config", sql)1226 self.logger.errorPair("Can't get pending ids for this skychunk", sql) 1225 1227 1226 1228 return ids … … 1253 1255 WHERE stage_id = " + str(stageID) + " \ 1254 1256 AND batch_type = '" + batchType + "' \ 1255 AND config = '" + self.config.name + "'"1257 AND skychunk = '" + self.skychunk.name + "'" 1256 1258 1257 1259 self.execute(sql) 1258 1260 1259 1261 ''' 1260 Writes density-plot data to file for pending stuff over sky for given config1262 Writes density-plot data to file for pending stuff over sky for given skychunk 1261 1263 ''' 1262 1264 def createPendingDensityPlotData(self, batchType, DATFILE): … … 1264 1266 sql = "SELECT id, ra_center, dec_center \ 1265 1267 FROM box \ 1266 WHERE config = '" + self.config.name + "' \1268 WHERE skychunk = '" + self.skychunk.name + "' \ 1267 1269 ORDER BY ra_center, dec_center" 1268 1270 … … 1317 1319 def getItemsInThisThisBox(self, ra, dec): 1318 1320 1319 halfSide = self. config.boxSize/2.01321 halfSide = self.skychunk.boxSize/2.0 1320 1322 minRa = ra-halfSide 1321 1323 maxRa = ra+halfSide … … 1346 1348 FROM stripe \ 1347 1349 JOIN clients ON (client_id = id) \ 1348 WHERE clients. config = '" + self.config.name + "' \1350 WHERE clients.skychunk = '" + self.skychunk.name + "' \ 1349 1351 ORDER BY host, started" 1350 1352 -
branches/eam_branches/ipp-20121219/ippToPsps/jython/loader.py
r35063 r35076 34 34 super(Loader, self).__init__(argv, 1, 1) 35 35 36 if self. config.parallel:36 if self.skychunk.parallel: 37 37 print "PARALLEL dvo" 38 38 else: … … 57 57 58 58 # create Datastore objects 59 self.datastore = Datastore(self.logger, self. config, self.ippToPspsDb)59 self.datastore = Datastore(self.logger, self.skychunk, self.ippToPspsDb) 60 60 61 61 # if an IN batch is requested, create and quit … … 65 65 batch = InitBatch(self.logger, 66 66 self.config, 67 self.skychunk, 67 68 self.gpc1Db, 68 69 self.ippToPspsDb, … … 77 78 78 79 79 # if an IN batch is requested, create and quit80 # if the 'once' option is passed, we do not loop multiple times in 'run' 80 81 self.onePassOnly = 0 81 82 if len(sys.argv) > 2 and sys.argv[2] == "once": … … 85 86 self.parsePollTimeArg("0.0166") 86 87 87 self. config.printAll()88 self.skychunk.printAll() 88 89 89 90 ''' 90 91 Overrides base-class version so we can ensure our scratch Db is using the right DVO Db 91 92 ''' 92 def refresh Config(self):93 94 ret = super(Loader, self).refresh Config()93 def refreshSkychunk(self): 94 95 ret = super(Loader, self).refreshSkychunk() 95 96 try: self.scratchDb 96 97 except: return ret 97 98 98 self.dvoDetections = DvoDetections(self.logger, self.config, self.s cratchDb.dbName)99 self.dvoDetections = DvoDetections(self.logger, self.config, self.skychunk, self.scratchDb.dbName) 99 100 100 101 return ret 101 102 102 103 ''' 103 Overrides base_class version so we can break out of processing loops if the configchanges104 Overrides base_class version so we can break out of processing loops if the skychunk changes 104 105 ''' 105 106 def checkClientStatus(self): 106 107 107 old ConfigName = self.config.name108 oldSkychunkName = self.skychunk.name 108 109 super(Loader, self).checkClientStatus() 109 if old ConfigName != self.config.name:110 self.logger.infoPair(" Config changed", "from '" + oldConfigName + "' to '" + self.config.name + "'")111 self. config.printAll()110 if oldSkychunkName != self.skychunk.name: 111 self.logger.infoPair("Skychunk changed", "from '" + oldSkychunkName + "' to '" + self.skychunk.name + "'") 112 self.skychunk.printAll() 112 113 return False 113 114 … … 125 126 126 127 abort = False 127 for batchType in self. config.batchTypes:128 for batchType in self.skychunk.batchTypes: 128 129 129 130 # get a stripe's worth of box IDs … … 161 162 self.logger.infoPair("Box dimensions", "%.1f / %.1f / %.1f" % (boxDim['RA'], boxDim['DEC'], boxDim['SIDE'])) 162 163 self.logger.infoPair(batchType + " items found in this box", "%d" % len(ids)) 163 boxSizeWithBorder = boxDim['SIDE'] + (self. config.BORDER * 2)164 boxSizeWithBorder = boxDim['SIDE'] + (self.skychunk.BORDER * 2) 164 165 boxSizeSansBorder = boxDim['SIDE'] 165 166 self.logger.infoPair("got here", "ok") … … 179 180 180 181 # should do we pre-ingest stuff from DVO? 181 # NOTE EAM : this chunk loads the dvo detections into the mysql db182 # NOTE EAM : this skychunk loads the dvo detections into the mysql db 182 183 # XXXX EAM : this should happen for both P2 and Stack detection 183 184 # XXXX EAM : in parallel model, this should happen for all P2 & Stack batches … … 250 251 batch = DetectionBatch(self.logger, 251 252 self.config, 253 self.skychunk, 252 254 self.gpc1Db, 253 255 self.ippToPspsDb, … … 259 261 batch = StackBatch(self.logger, 260 262 self.config, 263 self.skychunk, 261 264 self.gpc1Db, 262 265 self.ippToPspsDb, … … 269 272 batch = ObjectBatch(self.logger, 270 273 self.config, 274 self.skychunk, 271 275 self.gpc1Db, 272 276 self.ippToPspsDb, -
branches/eam_branches/ipp-20121219/ippToPsps/jython/objectbatch.py
r35056 r35076 32 32 logger, 33 33 config, 34 skychunk, 34 35 gpc1Db, 35 36 ippToPspsDb, … … 42 43 logger, 43 44 config, 45 skychunk, 44 46 gpc1Db, 45 47 ippToPspsDb, … … 52 54 53 55 try: 54 self.dvoObjects = DvoObjects(self.logger, self.config, self.s cratchDb.dbName)56 self.dvoObjects = DvoObjects(self.logger, self.config, self.skychunk, self.scratchDb.dbName) 55 57 except: 56 58 self.logger.errorPair("Unable to create instance of", "DvoObjects") … … 264 266 ,PSF_QF_PERF \ 265 267 ,STARGAL_SEP \ 266 , " + str(self. config.dataRelease) + "\268 , " + str(self.skychunk.dataRelease) + "\ 267 269 , RAND() \ 268 270 FROM " + cptTableName -
branches/eam_branches/ipp-20121219/ippToPsps/jython/plot.py
r34165 r35076 15 15 Constructor 16 16 ''' 17 def __init__(self, logger, config, ippToPspsDb):17 def __init__(self, logger, skychunk, ippToPspsDb): 18 18 19 19 self.logger = logger 20 self. config = config20 self.skychunk = skychunk 21 21 self.ippToPspsDb = ippToPspsDb 22 22 23 23 ''' 24 Creates a density plot of pending exposures for this config24 Creates a density plot of pending exposures for this skychunk 25 25 ''' 26 26 def createDensityPlot(self, batchType, forCzartool=False): 27 27 28 tempFilename = "./" + self. config.name + "_" + batchType + "_plotData.dat"28 tempFilename = "./" + self.skychunk.name + "_" + batchType + "_plotData.dat" 29 29 DATFILE = open(tempFilename,'w') 30 30 max = self.ippToPspsDb.createPendingDensityPlotData(batchType, DATFILE) … … 36 36 37 37 if forCzartool: 38 OUTPUTFILE = self.config.czarPlotsPath + "/ippToPsps_density_" + self.config.name + "_" + batchType + ".png" 38 ## XXX from config?? 39 OUTPUTFILE = self.skychunk.czarPlotsPath + "/ippToPsps_density_" + self.skychunk.name + "_" + batchType + ".png" 39 40 else: 40 OUTPUTFILE = self. config.name + "_" + batchType + "_" + timestamp + ".png"41 OUTPUTFILE = self.skychunk.name + "_" + batchType + "_" + timestamp + ".png" 41 42 42 43 f = os.popen('/home/panstarrs/ipp/local/bin/gnuplot', 'w') … … 49 50 print >> f, "set term " + TERM + "; \ 50 51 set output \"" + OUTPUTFILE + "\"; \ 51 set title \"Unprocessed " + batchType + " items for '" + self. config.name + "' as of " + timestamp + "\"; \52 set title \"Unprocessed " + batchType + " items for '" + self.skychunk.name + "' as of " + timestamp + "\"; \ 52 53 set grid; \ 53 set xrange [" + str(self. config.minRa) + ":" + str(self.config.maxRa) + "] reverse; \54 set yrange [" + str(self. config.minDec) + ":" + str(self.config.maxDec) + "]; \54 set xrange [" + str(self.skychunk.minRa) + ":" + str(self.skychunk.maxRa) + "] reverse; \ 55 set yrange [" + str(self.skychunk.minDec) + ":" + str(self.skychunk.maxDec) + "]; \ 55 56 unset key; \ 56 57 set palette rgb 22,13,10; \ -
branches/eam_branches/ipp-20121219/ippToPsps/jython/plotter.py
r33787 r35076 18 18 super(Plotter, self).__init__(argv) 19 19 20 self.plot = Plot(self.logger, self. config, self.ippToPspsDb)20 self.plot = Plot(self.logger, self.skychunk, self.ippToPspsDb) 21 21 22 22 if len(argv) < 3: -
branches/eam_branches/ipp-20121219/ippToPsps/jython/pollOdm.py
r33787 r35076 9 9 10 10 from ipptopsps import IppToPsps 11 from config import Config11 from skychunk import Skychunk 12 12 from odm import Odm 13 13 from batch import Batch … … 56 56 57 57 self.logger.infoSeparator() 58 self.logger.infoPair(" Config", self.config.name)58 self.logger.infoPair("Skychunk", self.skychunk.name) 59 59 60 60 for stage in self.stages: -
branches/eam_branches/ipp-20121219/ippToPsps/jython/pslogger.py
r33349 r35076 11 11 This will default to stout and no file output 12 12 ''' 13 def setup(self, programName, basePath, configName, host, pid, stdout=1, sendToFile=0):13 def setup(self, programName, basePath, skychunkName, host, pid, stdout=1, sendToFile=0): 14 14 15 15 formatter = logging.Formatter('%(asctime)s | %(levelname)7s | %(message)s', '%Y-%m-%d %H:%M:%S') … … 21 21 PATH = basePath + "/log" 22 22 if not os.path.exists(PATH): os.makedirs(PATH) 23 FULLPATH = PATH + "/" + programName + "_" + configName + "_" + host + "_" + str(pid) + ".log"23 FULLPATH = PATH + "/" + programName + "_" + skychunkName + "_" + host + "_" + str(pid) + ".log" 24 24 # opens file to be appended 25 25 hdlr = logging.FileHandler(FULLPATH, "a") -
branches/eam_branches/ipp-20121219/ippToPsps/jython/queue.py
r35003 r35076 29 29 # create various objects 30 30 self.gpc1Db = Gpc1Db(self.logger, self.config) 31 self.datastore = Datastore(self.logger, self. config, self.ippToPspsDb)31 self.datastore = Datastore(self.logger, self.skychunk, self.ippToPspsDb) 32 32 33 33 try: 34 self.dvoObjects = DvoObjects(self.logger, self.config )34 self.dvoObjects = DvoObjects(self.logger, self.config, self.skychunk) 35 35 except: 36 36 self.exitProgram("Unable to create instance of DvoObject") 37 37 raise 38 38 39 self. config.printAll()39 self.skychunk.printAll() 40 40 41 41 if len(argv) > 2: self.parsePollTimeArg(sys.argv[2]) … … 43 43 ''' 44 44 Main processing loop. 45 Tiled area is defined in configand looks for available stage_ids for each tile and writes them to ippToPsps database ready for processing45 Tiled area is defined in 'skychunk' and looks for available stage_ids for each tile and writes them to ippToPsps database ready for processing 46 46 by one or more loading clients that may be running on any host 47 47 ''' … … 54 54 55 55 # queue up batches that are processed but not loaded to datastore 56 for batchType in self. config.batchTypes:56 for batchType in self.skychunk.batchTypes: 57 57 58 58 self.logger.infoTitle("Previous failed datastore loads") … … 66 66 if batchType == "OB": 67 67 self.dvoObjects.setSkyArea( 68 self. config.minRa,69 self. config.maxRa,70 self. config.minDec,71 self. config.maxDec)68 self.skychunk.minRa, 69 self.skychunk.maxRa, 70 self.skychunk.minDec, 71 self.skychunk.maxDec) 72 72 rows = self.dvoObjects.allPopulatedRegionInfo 73 73 self.dvoObjects.printSummary() … … 76 76 else: 77 77 rows = self.gpc1Db.getItemsInThisDVODbForThisStage( 78 self. config.dvoLabel,78 self.skychunk.dvoLabel, 79 79 batchType, 80 self. config.minRa,81 self. config.maxRa,82 self. config.minDec,83 self. config.maxDec)80 self.skychunk.minRa, 81 self.skychunk.maxRa, 82 self.skychunk.minDec, 83 self.skychunk.maxDec) 84 84 85 85 # EAM TEST I/O … … 107 107 self.ippToPspsDb.storeAllItems(pending) 108 108 109 # loop through full range of RA/Dec queueing stuff in boxes of size self. config.boxSize109 # loop through full range of RA/Dec queueing stuff in boxes of size self.skychunk.boxSize 110 110 if len(ids) > 0: 111 111 … … 115 115 116 116 # starting positions 117 ra = self. config.minRa + self.config.halfBox118 dec = self. config.minDec + self.config.halfBox117 ra = self.skychunk.minRa + self.skychunk.halfBox 118 dec = self.skychunk.minDec + self.skychunk.halfBox 119 119 120 while ra <= self. config.maxRa:121 while dec <= self. config.maxDec:120 while ra <= self.skychunk.maxRa: 121 while dec <= self.skychunk.maxDec: 122 122 123 123 box_id = self.ippToPspsDb.insertBox(ra, dec) … … 128 128 ra, 129 129 dec, 130 self. config.boxSize,130 self.skychunk.boxSize, 131 131 len(ids))) 132 132 133 133 if len(ids) > 0: self.ippToPspsDb.insertPending(box_id, batchType, ids) 134 134 135 dec = dec + self. config.boxSize136 dec = self. config.minDec + self.config.halfBox137 ra = ra + self. config.boxSize135 dec = dec + self.skychunk.boxSize 136 dec = self.skychunk.minDec + self.skychunk.halfBox 137 ra = ra + self.skychunk.boxSize 138 138 139 139 self.logger.info("+-------------+-------------+-------------+-------------+") … … 153 153 154 154 batchName = Batch.getNameFromID(batchID) 155 subDir = Batch.getSubDir(self. config.basePath, batchType, self.config.dvoLabel)155 subDir = Batch.getSubDir(self.skychunk.basePath, batchType, self.skychunk.dvoLabel) 156 156 tarballFile = Batch.getTarballFile(batchID) 157 157 self.logger.infoPair("Batch name", batchName) -
branches/eam_branches/ipp-20121219/ippToPsps/jython/setupScratchDb.py
r35073 r35076 2 2 3 3 import sys 4 import os 5 import socket 4 6 import stilts 5 7 from java.lang import * 6 8 from java.sql import * 7 9 8 9 from ipptopsps import IppToPsps 10 from config import Config 10 11 from scratchdb import ScratchDb 12 from ipptopspsdb import IppToPspsDb 11 13 12 14 ''' 13 15 SetupScratchDb class 14 16 ''' 15 class SetupScratchDb(IppToPsps): 17 class SetupScratchDb(object): 18 19 ## XXX EAM : 2013.01.31 - i have changed the 'config.py' concept 20 ## to only include the global static information (from 21 ## settings.xml), and stripped out the dynamic information to a 22 ## new entity called 'skychunk' 16 23 17 24 ## XXX note that setupScratchDb.py fails if there are no valid … … 47 54 ''' 48 55 def __init__(self, argv): 49 super(SetupScratchDb, self).__init__(argv) 56 # set up config object 57 self.config = Config() 50 58 51 if len(argv) < 3:59 if len(argv) < 2: 52 60 self.printUsage() 53 61 self.exitProgram("incorrect args") 54 62 63 # some class constants 64 self.HOST = socket.gethostname() 65 self.PID = os.getpid() 66 67 # XXX Shouldn't config set up logger? 68 # (not yet, since we set HOST & PID with program...) 69 self.logger = self.config.getLogger(self.HOST, self.PID, 1, 0) 70 55 71 try: 56 self.scratchDb = ScratchDb(self.logger, self.config, '0', argv[2])72 self.scratchDb = ScratchDb(self.logger, self.config, argv[1]) 57 73 except: 58 74 self.exitProgram("Could not connect to a scratch Db") 59 75 raise 60 61 76 62 77 def run(self): … … 70 85 # install IN tables 71 86 self.logger.infoPair("Installing", "initialization tables") 72 if self.configDir is None: 73 tables = stilts.treads("../config/tables.IN.vot") 74 else: 75 tablepath = self.configDir + "tables.IN.vot" 76 tables = stilts.treads(tablepath) 87 tablepath = self.config.configDir + "tables.IN.vot" 88 tables = stilts.treads(tablepath) 77 89 78 90 for table in tables: … … 86 98 self.scratchDb.createDvoTables() 87 99 88 '''89 Overrides base-class version90 '''91 100 def printUsage(self): 92 super(SetupScratchDb, self).printUsage("<scratchdb_name>") 101 # write message to log or stdout if no logger set up 102 msg = os.path.basename(sys.argv[0]) + " <scratchdb_version> " 103 try: 104 self.logger.errorPair("Usage:", msg) 105 except: 106 print "*** Usage: " + msg 93 107 94 108 ''' … … 100 114 setupScratchDb.exitProgram("completed") 101 115 except: pass 102 103 -
branches/eam_branches/ipp-20121219/ippToPsps/jython/stackbatch.py
r35060 r35076 33 33 logger, 34 34 config, 35 skychunk, 35 36 gpc1Db, 36 37 ippToPspsDb, … … 43 44 logger, 44 45 config, 46 skychunk, 45 47 gpc1Db, 46 48 ippToPspsDb, … … 49 51 batchID, 50 52 "ST", 51 gpc1Db.getStackStageCmf( config.dvoLabel, stackID),53 gpc1Db.getStackStageCmf(skychunk.dvoLabel, stackID), 52 54 useFullTables) 53 55 … … 421 423 self.scratchDb.updateAllRows("StackMeta", "surveyID", str(self.surveyID)) 422 424 self.scratchDb.updateFilterID("StackMeta", self.filter) 423 self.scratchDb.updateAllRows("StackMeta", "dataRelease", str(self. config.dataRelease))425 self.scratchDb.updateAllRows("StackMeta", "dataRelease", str(self.skychunk.dataRelease)) 424 426 self.updateStackTypeID("StackMeta") 425 427 … … 528 530 self.scratchDb.updateFilterID("StackDetection", self.filter) 529 531 530 self.scratchDb.updateAllRows("StackDetection", "dataRelease", str(self. config.dataRelease))532 self.scratchDb.updateAllRows("StackDetection", "dataRelease", str(self.skychunk.dataRelease)) 531 533 532 534 self.scratchDb.updateAllRows("StackDetection", "primaryF", "0") … … 612 614 self.scratchDb.updateAllRows("StackApFlx", "surveyID", str(self.surveyID)) 613 615 self.scratchDb.updateFilterID("StackApFlx", self.filter) 614 self.scratchDb.updateAllRows("StackApFlx", "dataRelease", str(self. config.dataRelease))616 self.scratchDb.updateAllRows("StackApFlx", "dataRelease", str(self.skychunk.dataRelease)) 615 617 self.scratchDb.updateAllRows("StackApFlx", "primaryF", "0") 616 618 self.scratchDb.updateAllRows("StackApFlx", "activeFlag", "0") … … 646 648 self.scratchDb.updateAllRows("StackModelFit", "surveyID", str(self.surveyID)) 647 649 self.scratchDb.updateFilterID("StackModelFit", self.filter) 648 self.scratchDb.updateAllRows("StackModelFit", "dataRelease", str(self. config.dataRelease))650 self.scratchDb.updateAllRows("StackModelFit", "dataRelease", str(self.skychunk.dataRelease)) 649 651 self.scratchDb.updateAllRows("StackModelFit", "primaryF", "0") 650 652 self.scratchDb.updateAllRows("StackModelFit", "activeFlag", "0") … … 711 713 712 714 self.scratchDb.updateAllRows("SkinnyObject", "surveyID", str(self.surveyID)) 713 self.scratchDb.updateAllRows("SkinnyObject", "dataRelease", str(self. config.dataRelease))715 self.scratchDb.updateAllRows("SkinnyObject", "dataRelease", str(self.skychunk.dataRelease)) 714 716 715 717 ''' … … 756 758 AND b.imageID = " + str(imageID) 757 759 self.scratchDb.execute(sql) 758 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self. config.dataRelease))760 self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease)) 759 761 760 762 def populateStackDetectionCalib(self): … … 787 789 b.expTime, \ 788 790 b.airMass, \ 789 " + str(self. config.dataRelease) + " \791 " + str(self.skychunk.dataRelease) + " \ 790 792 FROM \ 791 793 StackDetection as a \ … … 801 803 802 804 ## XXX write this with the select/insert 803 # self.scratchDb.updateAllRows(tableName, "dataRelease", str(self. config.dataRelease))805 # self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease)) 804 806 805 807 ''' … … 821 823 822 824 self.scratchDb.updateFilterID("ObjectCalColor", self.filter) 823 self.scratchDb.updateAllRows("ObjectCalColor", "dataRelease", str(self. config.dataRelease))825 self.scratchDb.updateAllRows("ObjectCalColor", "dataRelease", str(self.skychunk.dataRelease)) 824 826 825 827 -
branches/eam_branches/ipp-20121219/ippToPsps/test/fulltest.sh
r35063 r35076 25 25 # mkgpc1.sh user localhost eam eam 26 26 27 set mkgpc1 = 128 set initdb = 129 set mkdummy = 130 set initscratch = 131 set initbatch = 132 set camqueue = 133 set cambatch = 127 set mkgpc1 = 0 28 set initdb = 0 29 set mkdummy = 0 30 set initscratch = 0 31 set camqueue = 0 32 set initbatch = 0 33 set cambatch = 0 34 34 set stackqueue = 1 35 35 set stackbatch = 1 … … 54 54 endif 55 55 56 # create a dummy config so setupScratchDb.py does not fail 57 if ($mkdummy) then 58 ippjython queue.py -test edit <<EOF 59 dummy 60 none 61 IPP_PSPS 62 0 63 none 64 none 65 0 66 0 67 0 68 0 69 1 70 none 71 0 72 0 73 1 74 1 75 2001-01-01 00:00:00.0 76 NONE 77 NONE 78 1 79 0 80 0 81 1 82 0 83 EOF 84 endif 56 ## XXX no longer needed : setupScratchDb does not need a fake 'config' (or 'chunk') 57 ## # create a dummy config so setupScratchDb.py does not fail 58 ## if ($mkdummy) then 59 ## ippjython queue.py -test edit <<EOF 60 ## dummy 61 ## none 62 ## IPP_PSPS 63 ## 0 64 ## none 65 ## none 66 ## 0 67 ## 0 68 ## 0 69 ## 0 70 ## 1 71 ## none 72 ## 0 73 ## 0 74 ## 1 75 ## 1 76 ## 2001-01-01 00:00:00.0 77 ## NONE 78 ## NONE 79 ## 1 80 ## 0 81 ## 0 82 ## 1 83 ## 0 84 ## EOF 85 ## endif 85 86 86 87 # re-create the ipptopsps database … … 96 97 # mysql -h localhost -u dvo -pdvo -e "create database ipptopsps_scratch3" 97 98 98 ippjython setupScratchDb.py -test dummy ipptopsps_test_scratch1 99 # ippjython setupScratchDb.py -test dummy ipptopsps_scratch2 100 # ippjython setupScratchDb.py -test dummy ipptopsps_scratch3 99 # setupScratchDb.py now takes the scratch name version, which is appended to the 100 # name in the settings.xml table 101 ippjython setupScratchDb.py -test 1 102 # ippjython setupScratchDb.py -test 2 103 # ippjython setupScratchDb.py -test 3 101 104 endif 102 105
Note:
See TracChangeset
for help on using the changeset viewer.
