IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35076


Ignore:
Timestamp:
Jan 31, 2013, 4:13:09 PM (13 years ago)
Author:
eugene
Message:

split out config (static info) and skychunk (area being processed)

Location:
branches/eam_branches/ipp-20121219/ippToPsps
Files:
1 added
27 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20121219/ippToPsps/config/ippToPspsDbSchema.sql

    r35063 r35076  
    5858  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
    5959  `id` bigint(20) unsigned NOT NULL auto_increment,
    60   `config` varchar(30) default NULL,
     60  `skychunk` varchar(30) default NULL,
    6161  `ra_center` float default NULL,
    6262  `dec_center` float default NULL,
    6363  `box_side` float default NULL,
    6464  PRIMARY KEY  (`id`),
    65   KEY `fk_config` (`config`),
    66   CONSTRAINT `fk_config` FOREIGN KEY (`config`) REFERENCES `config` (`name`) ON DELETE CASCADE
     65  KEY `fk_skychunk` (`skychunk`),
     66  CONSTRAINT `fk_skychunk` FOREIGN KEY (`skychunk`) REFERENCES `skychunk` (`name`) ON DELETE CASCADE
    6767) ENGINE=InnoDB AUTO_INCREMENT=44588 DEFAULT CHARSET=latin1;
    6868SET character_set_client = @saved_cs_client;
     
    8080  `pid` bigint(20) unsigned NOT NULL,
    8181  `host` varchar(20) NOT NULL,
    82   `config` varchar(30) default NULL,
     82  `skychunk` varchar(30) default NULL,
    8383  `paused` tinyint(1) default '0',
    8484  `killed` tinyint(1) default '0',
     
    9191
    9292--
    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
     96DROP TABLE IF EXISTS `skychunk`;
     97SET @saved_cs_client     = @@character_set_client;
     98SET character_set_client = utf8;
     99CREATE TABLE `skychunk` (
    100100  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP,
    101101  `name` varchar(30) NOT NULL,
     
    200200CREATE TABLE `stripe` (
    201201  `client_id` bigint(20) unsigned default NULL,
    202   `config` varchar(30) default NULL,
     202  `skychunk` varchar(30) default NULL,
    203203  `ra_center` float default NULL,
    204204  UNIQUE KEY `unique_key` (`client_id`),
  • branches/eam_branches/ipp-20121219/ippToPsps/doc/upgrade.txt

    r35075 r35076  
    1818  encompases both the static configuration information and the
    1919  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
    2024
    2125* client : an instance of an ipptopsps running proccess
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/Makefile.am

    r34969 r35076  
    3232  scratchdb.py \
    3333  setupScratchDb.py \
     34  skychunk.py \
    3435  stackbatch.py
    3536
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/batch.py

    r35056 r35076  
    3030                 logger,
    3131                 config,
     32                 skychunk,
    3233                 gpc1Db,
    3334                 ippToPspsDb,
     
    4647        self.readHeader = False
    4748        self.config = config
     49        self.skychunk = skychunk
    4850        self.fits = fits
    4951        self.useFullTables = useFullTables
     
    5557
    5658        # self.testprint()
    57 
    58         self.configDir = os.getenv("IPPTOPSPS_DATA")
    59         if self.configDir is not None:
    60             self.configDir = self.configDir + "/"
    6159
    6260        # set up class variables
     
    6765        self.scratchDb = scratchDb
    6866        self.batchType = batchType;
    69         self.pspsVoTableFilePath = self.configDir + "tables." + batchType + ".vot"
     67        self.pspsVoTableFilePath = self.config.configDir + "tables." + batchType + ".vot"
    7068
    7169        # self.testprint()
     
    8583        self.tablesToExport = []
    8684
    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)
    8987        else:
    9088            self.surveyID = -1;
    9189       
    9290        # create datastore object
    93         self.datastore = Datastore(self.logger, self.config, self.ippToPspsDb)
    94 
    95         # get local storage location from config
     91        self.datastore = Datastore(self.logger, self.skychunk, self.ippToPspsDb)
     92
     93        # get local storage location from skychunk
    9694        self.batchName = Batch.getNameFromID(self.batchID)
    9795        self.subDir = Batch.getSubDir(
    98                 self.config.basePath,
     96                self.skychunk.basePath,
    9997                self.batchType,
    100                 self.config.dvoLabel)
     98                self.skychunk.dvoLabel)
    10199
    102100        self.localOutPath = Batch.getOutputPath(
    103                 self.config.basePath,
     101                self.skychunk.basePath,
    104102                self.batchType,
    105                 self.config.dvoLabel,
     103                self.skychunk.dvoLabel,
    106104                self.batchID)
    107105
     
    253251        root.attrib['type'] = self.batchType
    254252        root.attrib['timestamp'] = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    255         root.attrib['survey'] = self.config.pspsSurvey
     253        root.attrib['survey'] = self.skychunk.pspsSurvey
    256254
    257255        # min/max object IDs
     
    294292        # set up filenams and paths
    295293        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)
    297295        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)
    299297
    300298        # tar directory
     
    516514
    517515        # TODO path to DVO prog hardcoded temporarily
    518         cmd = "../src/dvograbber " + self.config.settingsPath + " " + self.scratchDb.dbName + " " + self.config.dvoLocation
     516        cmd = "../src/dvograbber " + self.config.settingsPath + " " + self.scratchDb.dbName + " " + self.skychunk.dvoLocation
    519517        self.logger.infoPair("Running DVO", cmd)
    520518        p = Popen(cmd, shell=True, stdout=PIPE)
     
    532530    '''
    533531    Creates and publishes a batch
    534     TODO all methods call below should throw exceptions on failure
     532    TODO all method calls below should throw exceptions on failure
    535533    '''
    536534    def run(self):
     
    561559   
    562560        if self.writeBatchManifest():
    563             if self.config.datastorePublishing:
     561            if self.skychunk.datastorePublishing:
    564562
    565563                # tar and zip ready for publication to datastore
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/batchRepublisher.py

    r33866 r35076  
    3030            self.exitProgram("incorrect args")
    3131
    32         self.datastore = Datastore(self.logger, self.config, self.ippToPspsDb)
     32        self.datastore = Datastore(self.logger, self.skychunk, self.ippToPspsDb)
    3333        self.BATCHID = int(sys.argv[2])
    3434
     
    4040        batchName = Batch.getNameFromID(self.BATCHID)
    4141        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)
    4343        tarballFile = Batch.getTarballFile(self.BATCHID)
    4444
     
    5050        self.logger.infoPair("Reseting batch in database", "%d" % self.BATCHID)
    5151        self.ippToPspsDb.resetBatch(self.BATCHID)
    52         self.logger.infoPair("publishing to", self.config.datastoreProduct)
     52        self.logger.infoPair("publishing to", self.skychunk.datastoreProduct)
    5353        Batch.publishToDatastore(self.datastore, self.BATCHID, batchName, subDir, tarballFile)
    5454
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/cleanup.py

    r33818 r35076  
    2626        super(Cleanup, self).__init__(argv)
    2727
    28         self.datastore = Datastore(self.logger, self.config, self.ippToPspsDb)
     28        self.datastore = Datastore(self.logger, self.skychunk, self.ippToPspsDb)
    2929        self.dxlayer = DXLayer(self.logger)
    3030        if len(argv) > 2: self.parsePollTimeArg(sys.argv[2])
     
    4040
    4141            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()
    4444            self.clean("IN")
    4545            self.clean("P2")
     
    8989   
    9090        # delete stuff from local disk
    91         if self.config.deleteLocal:
     91        if self.skychunk.deleteLocal:
    9292            count = 0
    9393            for id in deleteFromLocalIDs:
    9494       
    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):
    9696                    self.ippToPspsDb.updateDeletedLocal(id, 1)
    9797                    count = count + 1
     
    100100   
    101101        # remove stuff from datastore
    102         if self.config.deleteDatastore:
     102        if self.skychunk.deleteDatastore:
    103103            count = 0
    104104            for id in deleteFromDatastoreIDs:
     
    112112       
    113113        # remove stuff from DXLayer
    114         if self.config.deleteDxLayer:
     114        if self.skychunk.deleteDxLayer:
    115115            count = 0
    116116            for id in deleteFromDxLayerIDs:
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/config.py

    r35075 r35076  
    11#!/usr/bin/env jython
    22
     3import sys
     4import os
    35import logging
    46from xml.etree.ElementTree import ElementTree, Element, tostring
     
    68from pslogger import PSLogger
    79
    8 
    910'''
    10 A class encapsulating a ippToPsps configuration. This information is stored in the 'config' table
    11 of the ipptopsps database, but there are some higher level config details in the 'settings.xml' file
     11A class encapsulating the globald ippToPsps configuration information.
     12This is stored in the 'settings.xml' file in the config directory
    1213'''
    1314class Config(object):
     
    1819    Basically reads the entire config and stores values to class variables
    1920    '''
    20     def __init__(self, programName, name, configDir):
     21    def __init__(self):
    2122
    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 + "/"
    2549
    2650        # self.configdir is set in ipptopsps.jy on init based on env(IPPTOPSPS_DATA)
    2751        # for test purposes, an uninstalled system may use the config information from
    2852        # 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"
    3354
    3455        self.logger = None
     
    3758        self.logPath = self.settingsDoc.find("logPath").text
    3859
    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
    8165
    8266    '''
     
    8569    def getLogger(self, host, pid, stdout=1, sendToFile=0):
    8670       
     71        print "get Logger: ", host, pid
    8772        logging.setLoggerClass(PSLogger)
     73        print "done Logger 1"
    8874        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"
    9081
    9182        return self.logger
    92 
    93     '''
    94     Prints the currently set DVO info
    95     '''
    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             pass
    103    
    104     '''
    105     Prints datastore info
    106     '''
    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             pass
    116    
    117     '''
    118     Prints the current deletion policy
    119     '''
    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             pass
    128    
    129     '''
    130     Prints the currently set RA/Dec bounding box
    131     '''
    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             pass
    140    
    14183
    14284    '''
     
    14789    def getDbUser(self, dbType): return self.settingsDoc.find(dbType +"/user").text
    14890    def getDbPassword(self, dbType): return self.settingsDoc.find(dbType +"/password").text
    149 
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/console.py

    r33729 r35076  
    3737   
    3838        self.frame = JFrame(
    39                 "ippToPsps console for config '" + self.config.name + "'",
     39                "ippToPsps console for skychunk '" + self.skychunk.name + "'",
    4040                layout=BorderLayout(),
    4141                size=(1000, 500),
     
    7474        button = JButton('Purge dead', actionPerformed=self.purgeDead)
    7575        buttonPanel.add(button)
    76         button = JButton('Change config', actionPerformed=self.changeConfig)
     76        button = JButton('Change skychunk', actionPerformed=self.changeSkychunk)
    7777        buttonPanel.add(button)
    7878
     
    136136        self.ippToPspsDb.purgeDeadClients()
    137137        self.refreshClientTable(None)
    138     def changeConfig(self, event):
     138    def changeSkychunk(self, event):
    139139        ids = self.getSelectedIds()
    140140        if len(ids) < 1:
    141141            JOptionPane.showMessageDialog(None, "No clients selected", "Error", JOptionPane.ERROR_MESSAGE)
    142142            return
    143         comboBox = JComboBox(self.ippToPspsDb.getActiveConfigList())
     143        comboBox = JComboBox(self.ippToPspsDb.getActiveSkychunkList())
    144144        if JOptionPane.showConfirmDialog(None,
    145145                comboBox,
    146                 "Choose a config",
     146                "Choose a skychunk",
    147147                JOptionPane.OK_CANCEL_OPTION,
    148148                JOptionPane.PLAIN_MESSAGE) == JOptionPane.CANCEL_OPTION: return
    149149
    150         self.ippToPspsDb.setConfigForLoaders(comboBox.getSelectedItem(), ids)
     150        self.ippToPspsDb.setSkychunkForLoaders(comboBox.getSelectedItem(), ids)
    151151        self.refreshClientTable(None)
    152152
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/datastore.py

    r33774 r35076  
    11#!/usr/bin/env jython
     2# EAM : config -> skychunk DONE
    23
    34from subprocess import call, PIPE, Popen
     
    1920
    2021    '''
    21     def __init__(self, logger, config, ippToPspsDb):
     22    def __init__(self, logger, skychunk, ippToPspsDb):
    2223   
    2324        # setup logger
    2425        self.logger = logger
    25         self.config = config
     26        self.skychunk = skychunk
    2627        self.ippToPspsDb = ippToPspsDb
    2728
     
    4243        command  = "dsreg --add " + name + "\
    4344                    --link --datapath " + path + "\
    44                     --type " + self.config.datastoreType + "\
    45                     --product " + self.config.datastoreProduct + "\
     45                    --type " + self.skychunk.datastoreType + "\
     46                    --product " + self.skychunk.datastoreProduct + "\
    4647                    --list " + tempFile.name
    4748
     
    7576                   --del " + name + " \
    7677                   --rm \
    77                    --product " + self.config.datastoreProduct
     78                   --product " + self.skychunk.datastoreProduct
    7879
    7980        p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE)
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/datastoreRemover.py

    r33787 r35076  
    2424            self.exitProgram("incorrect args")
    2525
    26         self.datastore = Datastore(self.logger, self.config, self.ippToPspsDb)
     26        self.datastore = Datastore(self.logger, self.skychunk, self.ippToPspsDb)
    2727
    2828    '''
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/detectionbatch.py

    r35063 r35076  
    3636                 logger,
    3737                 config,
     38                 skychunk,
    3839                 gpc1Db,
    3940                 ippToPspsDb,
     
    4647               logger,
    4748               config,
     49               skychunk,
    4850               gpc1Db,
    4951               ippToPspsDb,
     
    224226        self.scratchDb.updateFilterID("FrameMeta", self.filter)
    225227        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))
    227229
    228230    '''
     
    374376        self.scratchDb.updateFilterID(tableName, self.filter)
    375377        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))
    377379        if 'NASTRO' in header: self.totalNumPhotoRef = self.totalNumPhotoRef + int(header['NASTRO'])
    378380        self.scratchDb.replaceNullsInThisColumn(tableName, "polyOrder", "0")
     
    472474               , '" + self.dateStr + "' \
    473475               , 0 \
    474                , " + str(self.config.dataRelease) + "\
     476               , " + str(self.skychunk.dataRelease) + "\
    475477               FROM " + ippTableName
    476478        # self.logger.info(sql)
     
    526528        self.scratchDb.execute(sql)
    527529
    528         self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
     530        self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease))
    529531
    530532    '''
     
    571573            WHERE a.objID = b.objID AND a.detectID = b.detectID"
    572574        self.scratchDb.execute(sql)
    573         self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
     575        self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease))
    574576       
    575577    '''
     
    607609          b.expTime,       \
    608610          b.airMass,       \
    609           " + str(self.config.dataRelease) + " \
     611          " + str(self.skychunk.dataRelease) + " \
    610612         FROM              \
    611613           Detection_" + ota + " as a \
     
    647649
    648650        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))
    650652
    651653    '''
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/dvo.py

    r35063 r35076  
    3333
    3434    '''
    35     def __init__(self, logger, config, scratchDbName=None):
     35    def __init__(self, logger, config, skychunk, scratchDbName=None):
    3636
    3737        # set up logging
    3838        self.logger = logger
    3939        self.config = config
     40        self.skychunk = skychunk
    4041
    4142        # set up empty lists
     
    5758
    5859        # 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)
    6061
    6162        # this scratch Db either has no DVO info ingested, or a different DVO ingested. Prompt user
    6263        if not self.correctDvo:
    6364            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 + "'?")
    6566            response = raw_input("(y/n) ")
    6667            if response == "y":
     
    104105
    105106        # check if we have up-to-date version
    106         path = self.config.dvoLocation + "/Photcodes.dat"
     107        path = self.skychunk.dvoLocation + "/Photcodes.dat"
    107108        if self.scratchDb.alreadyImportedThisDvoTable(path):
    108109            self.logger.debugPair("DVO Photcodes.dat file", "up-to-date")
     
    129130
    130131        # check if we have up-to-date version
    131         path = self.config.dvoLocation + "/Images.dat"
     132        path = self.skychunk.dvoLocation + "/Images.dat"
    132133        if self.scratchDb.alreadyImportedThisDvoTable(path):
    133134            self.logger.debugPair("DVO Images.dat file", "up-to-date")
     
    154155        if not self.correctDvo: return False
    155156
    156         path =  self.config.dvoLocation + "/SkyTable.fits"
     157        path =  self.skychunk.dvoLocation + "/SkyTable.fits"
    157158        if self.scratchDb.alreadyImportedThisDvoTable(path):
    158159            self.logger.debugPair("DVO SkyTable.fits file", "up-to-date")       
     
    185186            cmd += " -dbuser " + self.scratchDb.dbUser
    186187            cmd += " -dbpass " + self.scratchDb.dbPass
    187             cmd += " -D CATDIR " + self.config.dvoLocation
     188            cmd += " -D CATDIR " + self.skychunk.dvoLocation
    188189
    189190            self.logger.infoPair("Running dvopsps", cmd)
     
    196197       
    197198        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)
    199200
    200201        return True
     
    259260           paths = []
    260261           for fileType in self.ingestFileTypes:
    261                paths.append(self.config.dvoLocation + "/" + regionPath + "." + fileType)
     262               paths.append(self.skychunk.dvoLocation + "/" + regionPath + "." + fileType)
    262263
    263264           # check for the existence of all interested file types
     
    332333        # go no further if we've already partly ingested a different DVO
    333334        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)
    335336            return
    336337
     
    418419             # get combined size of all interested files
    419420             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)
    421422                 # EAM TEST I/O
    422423                 self.logger.infoPair(fileType, size)
     
    570571    def nativeIngestDetections(self, raCenter, decCenter, boxSize):
    571572
    572         # XXX put the chunk below in a separate method
     573        # XXX put the skychunk below in a separate method
    573574       
    574575        # drop detections table
     
    610611        cmd += " -dbuser " + self.scratchDb.dbUser
    611612        cmd += " -dbpass " + self.scratchDb.dbPass
    612         cmd += " -D CATDIR " + self.config.dvoLocation
     613        cmd += " -D CATDIR " + self.skychunk.dvoLocation
    613614        cmd += " -region "
    614615        cmd += " " + str(raCenter-halfSize)
     
    617618        cmd += " " + str(decCenter+halfSize)
    618619
    619         if self.config.parallel:
     620        if self.skychunk.parallel:
    620621            cmd += " -parallel"
    621622
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/dvodetections.py

    r35016 r35076  
    2020    Constructor
    2121    '''
    22     def __init__(self, logger, config, scratchDbName):
     22    def __init__(self, logger, config, skychunk, scratchDbName):
    2323
    24         super(DvoDetections, self).__init__(logger, config, scratchDbName)
     24        super(DvoDetections, self).__init__(logger, config, skychunk, scratchDbName)
    2525
    2626        # declare DVO file types of interest
     
    3232    def ingestRegion(self, region):
    3333
    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"
    3636
    3737       cpmTableName = self.scratchDb.getDbFriendlyTableName(region + ".cpm")
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/dvoobjects.py

    r35063 r35076  
    1212from dvo import Dvo
    1313
    14 
    1514'''
    1615A class for ingesting DVO detections into MySQL
     
    2120    Constructor
    2221    '''
    23     def __init__(self, logger, config, scratchDbName=None):
     22    def __init__(self, logger, config, skychunk, scratchDbName=None):
    2423
    25         super(DvoObjects, self).__init__(logger, config, scratchDbName)
     24        super(DvoObjects, self).__init__(logger, config, skychunk, scratchDbName)
    2625
    2726        # declare DVO file types of interest
     
    3837       for fileType in self.ingestFileTypes:
    3938
    40            path = self.config.dvoLocation + "/" + region + "." + fileType
     39           path = self.skychunk.dvoLocation + "/" + region + "." + fileType
    4140           tableName = self.scratchDb.getDbFriendlyTableName(region + "." + fileType)
    4241
     
    6463        cmd += " -dbuser " + self.scratchDb.dbUser
    6564        cmd += " -dbpass " + self.scratchDb.dbPass
    66         cmd += " -D CATDIR " + self.config.dvoLocation
     65        cmd += " -D CATDIR " + self.skychunk.dvoLocation
    6766        cmd += " -cpt " + region
    6867
    69         if self.config.parallel:
     68        if self.skychunk.parallel:
    7069            cmd += " -parallel"
    7170
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/initbatch.py

    r33727 r35076  
    2828            logger,
    2929            config,
     30            skychunk,
    3031            gpc1Db,
    3132            ippToPspsDb,
     
    3435       super(InitBatch, self).__init__(logger,
    3536               config,
     37               skychunk,
    3638               gpc1Db,
    3739               ippToPspsDb,
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/ipptopsps.py

    r35063 r35076  
    11#!/usr/bin/env jython
     2# EAM : config -> skychunk DONE
    23
    34import signal
     
    910
    1011from config import Config
     12from skychunk import Skychunk
    1113from pslogger import PSLogger
    1214from ipptopspsdb import IppToPspsDb
     
    2325    def __init__(self, argv, logToStdout=1, logToFile=0):
    2426
    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
    3531        if len(sys.argv) < 2:
    3632            self.printUsage()
     
    3834
    3935        # some class constants
    40         self.PROGNAME = os.path.basename(sys.argv[0])
    41         CONFIGNAME = sys.argv[1]
    4236        self.HOST = socket.gethostname()
    4337        self.PID = os.getpid()
     
    4741        self.SECONDS = None
    4842
    49         self.configDir = os.getenv("IPPTOPSPS_DATA")
    50         if self.configDir is not None:
    51             self.configDir = self.configDir + "/"
    52 
    53         self.createNewConfig = False
    54         self.rotateConfigs = False
    55         # a new config?
    56         if CONFIGNAME == "edit": self.createNewConfig = True
    57         # should we rotate configs for this program?
    58         elif CONFIGNAME == "all": self.rotateConfigs = True
    59 
    60         # set up config object
    61         self.config = Config(self.PROGNAME, CONFIGNAME, self.configDir)
    62         self.config.test = testmode
    63 
    64         if self.config.test: print "using test mode"
    65         else: print "not using test mode"
    66 
    6743        self.logger = self.config.getLogger(self.HOST, self.PID, logToStdout, logToFile)
    6844
     45        # argv[1] -> self.skychunk.name
     46        self.skychunk = Skychunk(self.logger)
     47        print "here... "
     48
    6949        # create connection to databases database
    7050        try:
    71             self.ippToPspsDb = IppToPspsDb(self.logger, self.config)
     51            self.ippToPspsDb = IppToPspsDb(self.logger, self.config, self.skychunk)
    7252        except:
    7353            self.exitProgram("Could not connect to ipptopsps Db")
    7454            raise
    7555
     56        print "here... "
     57
    7658        self.checkClientStatus()
     59        print "here... "
    7760
    7861        # catch Ctrl-C signal
    7962        signal.signal(signal.SIGINT, self.signal_handler)
     63        print "here... "
    8064
    8165        # title for log
    8266        self.logger.infoSeparator()
    83         self.logger.infoTitle("ippToPsps '" + self.PROGNAME + "' started")
     67        self.logger.infoTitle("ippToPsps '" + self.config.programName + "' started")
    8468        self.logger.infoPair("Host", self.HOST)
    8569        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... "
    8772
    8873    '''
     
    122107
    123108        # write message to log or stdout if no logger set up
    124         msg = sys.argv[0] + " <configName|all|edit> " + extra
     109        msg = sys.argv[0] + " <skychunkName|all|edit> " + extra
    125110        try:
    126111            self.logger.errorPair("Usage:", msg)
     
    129114
    130115    '''
    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()
    145137             
    146138            i = 1
    147             for config in configs:
    148                if config == self.config.name: break
     139            for skychunk in skychunks:
     140               if skychunk == self.skychunk.name: break
    149141               i += 1
    150142
    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
    160153    '''
    161154    def checkClientStatus(self):
    162155
    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... "
    165160        if self.ippToPspsDb.isKilled(self.HOST, self.PID):
    166161            self.exitProgram("killed via Db")
    167162       
    168         # this loop pauses the process if we have no config or we have set it to pause
     163        # this loop pauses the process if we have no skychunk or we have set it to pause
    169164        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)
    173170            if self.ippToPspsDb.isKilled(self.HOST, self.PID):
    174171                self.exitProgram("killed while paused")
     
    177174            time.sleep(self.PAUSEPERIOD)
    178175
     176        print "stat done... "
     177
    179178
    180179    '''
     
    193192        # write message to log or stdout if no logger set up
    194193        try:
    195             self.logger.infoPair(self.PROGNAME + " exited", exitReason)
     194            self.logger.infoPair(self.config.programName + " exited", exitReason)
    196195        except:
    197196            print "*** Program exited: " + exitReason
     
    204203
    205204        sys.exit(0)
    206    
    207 
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/ipptopspsdb.py

    r35063 r35076  
    1717    Constructor
    1818    '''
    19     def __init__(self, logger, config):
     19    def __init__(self, logger, config, skychunk):
    2020        if (config.test):
    2121            dbType = "ipptopspsdatabase_test"
     
    2424        super(IppToPspsDb, self).__init__(logger, config, dbType)
    2525
     26        self.skychunk = skychunk
     27
    2628        self.MAX_FAILS = 5
    2729
     
    3335        sql = "SELECT DISTINCT batch_id \
    3436               FROM batch \
    35                WHERE timestamp > '" + self.config.epoch + "' \
     37               WHERE timestamp > '" + self.skychunk.epoch + "' \
    3638               AND batch_type = '" + batchType + "' \
    37                AND dvo_db = '" + self.config.dvoLabel + "' \
     39               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
    3840               AND merged = 1 \
    3941               AND " + column + " = 0"
     
    5860        sql = "SELECT DISTINCT batch_id \
    5961               FROM batch \
    60                WHERE timestamp > '" + self.config.epoch + "' \
     62               WHERE timestamp > '" + self.skychunk.epoch + "' \
    6163               AND batch_type = '" + batchType + "' \
    62                AND dvo_db = '" + self.config.dvoLabel + "' \
     64               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
    6365               AND purged = 1 \
    6466               AND " + column + " = 0"
     
    8486        sql = "SELECT DISTINCT batch_id \
    8587               FROM batch \
    86                WHERE timestamp > '" + self.config.epoch + "' \
     88               WHERE timestamp > '" + self.skychunk.epoch + "' \
    8789               AND batch_type = '" + batchType + "' \
    88                AND dvo_db = '" + self.config.dvoLabel + "' \
     90               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
    8991               AND (loaded_to_ODM = -1 OR merge_worthy = 1) \
    9092               AND " + column + " = 0"
     
    152154        sql = "SELECT DISTINCT batch_id \
    153155               FROM batch \
    154                WHERE timestamp > '" + self.config.epoch + "' \
     156               WHERE timestamp > '" + self.skychunk.epoch + "' \
    155157               AND batch_type = '" + batchType + "' \
    156                AND dvo_db = '" + self.config.dvoLabel + "' \
     158               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
    157159               AND processed = 1\
    158160               AND loaded_to_datastore != 1 \
     
    181183        sql = "SELECT batch_id \
    182184               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 + "' \
    185187               AND loaded_to_datastore = 1 \
    186188               AND batch_type = '" + batchType + "' \
     
    210212        sql = "SELECT batch_id \
    211213               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 + "' \
    214216               AND loaded_to_datastore = 1 \
    215217               AND batch_type = '" + batchType + "' \
     
    239241        sql = "SELECT batch_id \
    240242               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 + "' \
    243245               AND merge_worthy = 1 \
    244246               AND batch_type = '" + batchType + "' \
     
    266268        sql = "SELECT DISTINCT batch_id \
    267269               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 + "' \
    270272               AND " + column + " = " + str(value)
    271273
     
    292294               FROM batch \
    293295               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 + "' \
    296298               AND processed = 1 \
    297299               AND loaded_to_datastore = 1 \
     
    319321               FROM batch \
    320322               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 + "' \
    323325               AND " + column + " = " + str(value)
    324326
     
    391393               WHERE batch_type = '" + batchType + "' \
    392394               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 + "' \
    395397               AND timestamp BETWEEN now() - INTERVAL " + interval + " AND now()"
    396398
     
    416418               WHERE batch_type = '" + batchType + "' \
    417419               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 + "' \
    420422               ORDER BY timestamp DESC LIMIT 1"
    421423
     
    515517               WHERE stage_id = " + str(stage_id) + " \
    516518               AND batch_type = '" + batchType + "' \
    517                AND dvo_db = '" + self.config.dvoLabel + "' \
     519               AND dvo_db = '" + self.skychunk.dvoLabel + "' \
    518520               AND batch_type != 'IN' \
    519521               AND timestamp BETWEEN now() - INTERVAL 12 HOUR AND now()"
     
    558560               WHERE stage_id = " + str(stage_id) + " \
    559561               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 + "' \
    562564               AND batch_type != 'IN' \
    563565               AND processed = 1"
     
    583585               WHERE stage_id = " + str(stage_id) + " \
    584586               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 + "' \
    587589               AND processed = -1"
    588590
     
    606608               FROM batch \
    607609               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 + "' \
    610612               AND processed = -1 \
    611613               GROUP BY stage_id HAVING numoccur >= " + str(self.MAX_FAILS)
     
    638640        batchID = -1;
    639641
    640         if self.config.force or \
     642        if self.skychunk.force or \
    641643            (not self.alreadyProcessed(batchType, stageID) \
    642644            and not self.processingNow(batchType, stageID) \
     
    654656                       '" + batchType + "', \
    655657                       " + 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 + "' \
    659661                       )"
    660662            self.logger.infoPair("heather:","sql")
     
    753755
    754756    '''
    755     Sets the config field for this client
    756     '''
    757     def setConfigForThisClient(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 + "' \
    760762                WHERE host = '" + host + "' \
    761763                AND pid = " + str(pid))
    762764
    763765    '''
    764     Sets the config field for a set of loader clients
    765     '''
    766     def setConfigForLoaders(self, config, ids):
     766    Sets the skychunk field for a set of loader clients
     767    '''
     768    def setSkychunkForLoaders(self, skychunk, ids):
    767769
    768770        for id in ids:
    769             self.execute("UPDATE clients SET config = '" + config + "' \
     771            self.execute("UPDATE clients SET skychunk = '" + skychunk + "' \
    770772                    WHERE type = 'loader.py' \
    771773                    AND id = " + str(id))
     
    801803    '''
    802804    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 + "')")
    804806
    805807    '''
     
    845847
    846848    '''
    847     Returns a list of available configs
    848     '''
    849     def getActiveConfigList(self):
     849    Returns a list of available skychunks
     850    '''
     851    def getActiveSkychunkList(self):
    850852       
    851         sql = "SELECT DISTINCT name FROM config WHERE 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 config names", 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)
    859861        finally:
    860862            rs.close()
    861863
    862         return configs
    863 
    864     '''
    865     Prompts user for info about a new or existing config and lets them neter the various details
    866     '''
    867     def editConfig(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):
    868870
    869871       print " ********************************************************************"
    870        print " *              Config editor"
     872       print " *              Skychunk editor"
    871873       print " *"
    872        response = raw_input(" * Name for new config, or existing config to edit? ")
     874       response = raw_input(" * Name for new skychunk, or existing skychunk to edit? ")
    873875       if response == "": return
    874        self.config.name = response
    875 
    876        # attempt to insert new config, if it already exists then carry on with update
    877        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 + "')"
    878880       try:       
    879881           self.execute(sql)
    880882       except: pass
    881883
    882        # for each column in the config table
    883        sql = "SHOW COLUMNS FROM config"
     884       # for each column in the skychunk table
     885       sql = "SHOW COLUMNS FROM skychunk"
    884886       rs = self.executeQuery(sql)
    885887       while (rs.next()):
     
    895897           # get current value for this field, if any
    896898           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 + "'")
    898900               rs2.first()
    899901               default = rs2.getString(1)
     
    912914               if type.find("varchar") != -1 or type.find("timestamp") != -1: quotes = "'"
    913915               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 + "'")
    915917       
    916918       print " *"
     
    918920
    919921    '''
    920     Returns config for this client
    921     '''
    922     def getConfigForThisClient(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 \
    925927               FROM clients \
    926928               WHERE host = '" + host + "' \
     
    930932            rs = self.executeQuery(sql)
    931933            rs.first()
    932             self.config.name = rs.getString(1)
    933         except:
    934             self.logger.errorPair("No config set for", "%s (pid=%d)" % (host, pid))
    935             self.config.isLoaded = False
     934            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
    936938            return False
    937939
     
    939941
    940942    '''
    941     Reads config from the database and populates Config object
    942     '''
    943     def readConfig(self, host, pid):
    944 
    945         # first get config defined for this client
    946         if not self.getConfigForThisClient(host, pid): return False
    947 
    948         # now load that config
     943    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
    949951        sql = "SELECT \
    950952        datastore_product \
     
    970972        ,queue_OB \
    971973        ,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 = []
    976978        try:
    977979            rs = self.executeQuery(sql)
    978980
    979981            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 = True
    983             else: self.config.datastorePublishing = False
    984             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)
    985987
    986988            # 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.0
    996             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 # TODO
    1015             self.config.parallel = False # TODO
    1016 
    1017             if rs.getInt(22) == 1: self.config.parallel = True
    1018 
    1019             if self.config.parallel: print "USING parallel"
    1020             self.config.isLoaded = True
    1021         except:
    1022             self.logger.errorPair("Could not read config with name", self.config.name)
    1023             self.config.isLoaded = False
    1024 
    1025         return self.config.isLoaded
     989            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
    10261028
    10271029    '''
     
    10311033
    10321034        sql = "SELECT id FROM box \
    1033                WHERE config  = '" + self.config.name + "' \
     1035               WHERE skychunk  = '" + self.skychunk.name + "' \
    10341036               AND ra_center = " + str(ra) + " \
    10351037               AND dec_center = " + str(dec) + " \
    1036                AND box_side = " + str(self.config.boxSize)
     1038               AND box_side = " + str(self.skychunk.boxSize)
    10371039
    10381040        id = -1
     
    10501052    '''
    10511053    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 + "'")
    10531055
    10541056    '''
     
    10631065
    10641066            sql = "INSERT INTO box \
    1065                    (config, ra_center, dec_center, box_side) \
     1067                   (skychunk, ra_center, dec_center, box_side) \
    10661068                   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) + ")"
    10681070
    10691071            self.execute(sql)
     
    11041106               FROM box \
    11051107               JOIN pending ON (id = box_id) \
    1106                WHERE config = '" + self.config.name + "' \
     1108               WHERE skychunk = '" + self.skychunk.name + "' \
    11071109               AND batch_type = '" + batchType + "' \
    11081110               AND ra_center NOT IN \
    11091111               (SELECT ra_center \
    11101112                FROM stripe \
    1111                 WHERE config = '" + self.config.name + "') \
     1113                WHERE skychunk = '" + self.skychunk.name + "') \
    11121114               GROUP BY ra_center LIMIT 1"
    11131115
     
    11241126                   FROM box \
    11251127                   JOIN pending ON (id = box_id) \
    1126                    WHERE config = '" + self.config.name + "' \
     1128                   WHERE skychunk = '" + self.skychunk.name + "' \
    11271129                   AND batch_type = '" + batchType + "' \
    11281130                   GROUP BY ra_center \
     
    11441146               WHERE ra_center = " + str(raCenter) + " \
    11451147               AND batch_type = '" + batchType + "' \
    1146                AND config = '" + self.config.name + "' \
     1148               AND skychunk = '" + self.skychunk.name + "' \
    11471149               ORDER BY dec_center DESC"
    11481150
     
    11771179        # now insert new stripe entry
    11781180        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) + " \
    11811183               FROM clients \
    11821184               WHERE host = '" + host + "' \
     
    12061208
    12071209    '''
    1208     Returns ids for pending items for this config
     1210    Returns ids for pending items for this skychunk
    12091211    '''
    12101212    def getPendingIds(self, batchType):
     
    12131215               FROM pending \
    12141216               JOIN box ON (box_id = id) \
    1215                WHERE config = '" + self.config.name + "' \
     1217               WHERE skychunk = '" + self.skychunk.name + "' \
    12161218               AND batch_type = '" + batchType + "'"
    12171219
     
    12221224            rs.close()
    12231225        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)
    12251227
    12261228        return ids
     
    12531255               WHERE stage_id = " + str(stageID) + " \
    12541256               AND batch_type = '" + batchType + "' \
    1255                AND config = '" + self.config.name + "'"
     1257               AND skychunk = '" + self.skychunk.name + "'"
    12561258
    12571259        self.execute(sql)
    12581260
    12591261    '''
    1260     Writes density-plot data to file for pending stuff over sky for given config
     1262    Writes density-plot data to file for pending stuff over sky for given skychunk
    12611263    '''
    12621264    def createPendingDensityPlotData(self, batchType, DATFILE):
     
    12641266        sql = "SELECT id, ra_center, dec_center \
    12651267               FROM box \
    1266                WHERE config = '" + self.config.name + "' \
     1268               WHERE skychunk = '" + self.skychunk.name + "' \
    12671269               ORDER BY ra_center, dec_center"
    12681270
     
    13171319    def getItemsInThisThisBox(self, ra, dec):
    13181320
    1319         halfSide = self.config.boxSize/2.0
     1321        halfSide = self.skychunk.boxSize/2.0
    13201322        minRa =  ra-halfSide
    13211323        maxRa = ra+halfSide
     
    13461348               FROM stripe \
    13471349               JOIN clients ON (client_id = id) \
    1348                WHERE clients.config = '" + self.config.name + "' \
     1350               WHERE clients.skychunk = '" + self.skychunk.name + "' \
    13491351               ORDER BY host, started"
    13501352
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/loader.py

    r35063 r35076  
    3434        super(Loader, self).__init__(argv, 1, 1)
    3535
    36         if self.config.parallel:
     36        if self.skychunk.parallel:
    3737            print "PARALLEL dvo"
    3838        else:
     
    5757       
    5858        # create Datastore objects
    59         self.datastore = Datastore(self.logger, self.config, self.ippToPspsDb)
     59        self.datastore = Datastore(self.logger, self.skychunk, self.ippToPspsDb)
    6060
    6161        # if an IN batch is requested, create and quit
     
    6565               batch = InitBatch(self.logger,
    6666                       self.config,
     67                       self.skychunk,
    6768                       self.gpc1Db,
    6869                       self.ippToPspsDb,
     
    7778   
    7879
    79         # if an IN batch is requested, create and quit
     80        # if the 'once' option is passed, we do not loop multiple times in 'run'
    8081        self.onePassOnly = 0
    8182        if len(sys.argv) > 2 and sys.argv[2] == "once":
     
    8586        self.parsePollTimeArg("0.0166")
    8687
    87         self.config.printAll()
     88        self.skychunk.printAll()
    8889
    8990    '''
    9091    Overrides base-class version so we can ensure our scratch Db is using the right DVO Db
    9192    '''
    92     def refreshConfig(self):
    93 
    94         ret = super(Loader, self).refreshConfig()
     93    def refreshSkychunk(self):
     94
     95        ret = super(Loader, self).refreshSkychunk()
    9596        try: self.scratchDb
    9697        except: return ret
    9798           
    98         self.dvoDetections = DvoDetections(self.logger, self.config, self.scratchDb.dbName)
     99        self.dvoDetections = DvoDetections(self.logger, self.config, self.skychunk, self.scratchDb.dbName)
    99100
    100101        return ret
    101102
    102103    '''
    103     Overrides base_class version so we can break out of processing loops if the config changes
     104    Overrides base_class version so we can break out of processing loops if the skychunk changes
    104105    '''
    105106    def checkClientStatus(self):
    106107
    107         oldConfigName = self.config.name
     108        oldSkychunkName = self.skychunk.name
    108109        super(Loader, self).checkClientStatus()
    109         if oldConfigName != 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()
    112113            return False
    113114
     
    125126
    126127            abort = False
    127             for batchType in self.config.batchTypes:
     128            for batchType in self.skychunk.batchTypes:
    128129
    129130                # get a stripe's worth of box IDs
     
    161162                    self.logger.infoPair("Box dimensions", "%.1f / %.1f / %.1f" % (boxDim['RA'], boxDim['DEC'], boxDim['SIDE']))
    162163                    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)
    164165                    boxSizeSansBorder = boxDim['SIDE']
    165166                    self.logger.infoPair("got here", "ok")
     
    179180
    180181                            # should do we pre-ingest stuff from DVO?
    181                             # NOTE EAM : this chunk loads the dvo detections into the mysql db
     182                            # NOTE EAM : this skychunk loads the dvo detections into the mysql db
    182183                            # XXXX EAM : this should happen for both P2 and Stack detection
    183184                            # XXXX EAM : in parallel model, this should happen for all P2 & Stack batches
     
    250251                    batch = DetectionBatch(self.logger,
    251252                            self.config,
     253                            self.skychunk,
    252254                            self.gpc1Db,
    253255                            self.ippToPspsDb,
     
    259261                    batch = StackBatch(self.logger,
    260262                            self.config,
     263                            self.skychunk,
    261264                            self.gpc1Db,
    262265                            self.ippToPspsDb,
     
    269272                    batch = ObjectBatch(self.logger,
    270273                            self.config,
     274                            self.skychunk,
    271275                            self.gpc1Db,
    272276                            self.ippToPspsDb,
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/objectbatch.py

    r35056 r35076  
    3232                 logger,
    3333                 config,
     34                 skychunk,
    3435                 gpc1Db,
    3536                 ippToPspsDb,
     
    4243               logger,
    4344               config,
     45               skychunk,
    4446               gpc1Db,
    4547               ippToPspsDb,
     
    5254
    5355       try:
    54            self.dvoObjects = DvoObjects(self.logger, self.config, self.scratchDb.dbName)
     56           self.dvoObjects = DvoObjects(self.logger, self.config, self.skychunk, self.scratchDb.dbName)
    5557       except:
    5658           self.logger.errorPair("Unable to create instance of", "DvoObjects")
     
    264266               ,PSF_QF_PERF \
    265267               ,STARGAL_SEP \
    266                , " + str(self.config.dataRelease) + "\
     268               , " + str(self.skychunk.dataRelease) + "\
    267269               , RAND() \
    268270               FROM " + cptTableName
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/plot.py

    r34165 r35076  
    1515    Constructor
    1616    '''
    17     def __init__(self, logger, config, ippToPspsDb):
     17    def __init__(self, logger, skychunk, ippToPspsDb):
    1818
    1919        self.logger = logger
    20         self.config = config
     20        self.skychunk = skychunk
    2121        self.ippToPspsDb = ippToPspsDb
    2222
    2323    '''
    24     Creates a density plot of pending exposures for this config
     24    Creates a density plot of pending exposures for this skychunk
    2525    '''
    2626    def createDensityPlot(self, batchType, forCzartool=False):
    2727
    28         tempFilename = "./" + self.config.name + "_" + batchType + "_plotData.dat"
     28        tempFilename = "./" + self.skychunk.name + "_" + batchType + "_plotData.dat"
    2929        DATFILE = open(tempFilename,'w')
    3030        max = self.ippToPspsDb.createPendingDensityPlotData(batchType, DATFILE)
     
    3636
    3737        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"
    3940        else:
    40             OUTPUTFILE = self.config.name + "_" + batchType + "_" + timestamp + ".png"
     41            OUTPUTFILE = self.skychunk.name + "_" + batchType + "_" + timestamp + ".png"
    4142
    4243        f = os.popen('/home/panstarrs/ipp/local/bin/gnuplot', 'w')
     
    4950        print >> f, "set term " + TERM + "; \
    5051            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 + "\"; \
    5253            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) + "]; \
    5556            unset key; \
    5657            set palette rgb 22,13,10; \
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/plotter.py

    r33787 r35076  
    1818        super(Plotter, self).__init__(argv)
    1919
    20         self.plot = Plot(self.logger, self.config, self.ippToPspsDb)
     20        self.plot = Plot(self.logger, self.skychunk, self.ippToPspsDb)
    2121 
    2222        if len(argv) < 3:
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/pollOdm.py

    r33787 r35076  
    99
    1010from ipptopsps import IppToPsps
    11 from config import Config
     11from skychunk import Skychunk
    1212from odm import Odm
    1313from batch import Batch
     
    5656
    5757            self.logger.infoSeparator()
    58             self.logger.infoPair("Config", self.config.name)
     58            self.logger.infoPair("Skychunk", self.skychunk.name)
    5959
    6060            for stage in self.stages:
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/pslogger.py

    r33349 r35076  
    1111   This will default to stout and no file output
    1212   '''
    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):
    1414
    1515       formatter = logging.Formatter('%(asctime)s | %(levelname)7s | %(message)s', '%Y-%m-%d %H:%M:%S')
     
    2121           PATH = basePath + "/log"
    2222           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"
    2424           # opens file to be appended
    2525           hdlr = logging.FileHandler(FULLPATH, "a")
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/queue.py

    r35003 r35076  
    2929        # create various objects
    3030        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)
    3232
    3333        try:
    34             self.dvoObjects = DvoObjects(self.logger, self.config)
     34            self.dvoObjects = DvoObjects(self.logger, self.config, self.skychunk)
    3535        except:
    3636            self.exitProgram("Unable to create instance of DvoObject")
    3737            raise
    3838
    39         self.config.printAll()
     39        self.skychunk.printAll()
    4040
    4141        if len(argv) > 2: self.parsePollTimeArg(sys.argv[2])
     
    4343    '''
    4444    Main processing loop.
    45     Tiled area is defined in config and looks for available stage_ids for each tile and writes them to ippToPsps database ready for processing
     45    Tiled area is defined in 'skychunk' and looks for available stage_ids for each tile and writes them to ippToPsps database ready for processing
    4646    by one or more loading clients that may be running on any host
    4747    '''
     
    5454       
    5555            # 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:
    5757
    5858                self.logger.infoTitle("Previous failed datastore loads")
     
    6666                if batchType == "OB":
    6767                    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)
    7272                    rows = self.dvoObjects.allPopulatedRegionInfo
    7373                    self.dvoObjects.printSummary()
     
    7676                else:
    7777                    rows = self.gpc1Db.getItemsInThisDVODbForThisStage(
    78                             self.config.dvoLabel,
     78                            self.skychunk.dvoLabel,
    7979                            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)
    8484
    8585                # EAM TEST I/O
     
    107107                self.ippToPspsDb.storeAllItems(pending)
    108108
    109                 # loop through full range of RA/Dec queueing stuff in boxes of size self.config.boxSize
     109                # loop through full range of RA/Dec queueing stuff in boxes of size self.skychunk.boxSize
    110110                if len(ids) > 0:
    111111
     
    115115   
    116116                    # starting positions
    117                     ra = self.config.minRa + self.config.halfBox
    118                     dec = self.config.minDec + self.config.halfBox
     117                    ra = self.skychunk.minRa + self.skychunk.halfBox
     118                    dec = self.skychunk.minDec + self.skychunk.halfBox
    119119   
    120                     while ra <= self.config.maxRa:
    121                        while dec <= self.config.maxDec:
     120                    while ra <= self.skychunk.maxRa:
     121                       while dec <= self.skychunk.maxDec:
    122122           
    123123                           box_id = self.ippToPspsDb.insertBox(ra, dec)
     
    128128                                       ra,
    129129                                       dec,
    130                                        self.config.boxSize,
     130                                       self.skychunk.boxSize,
    131131                                       len(ids)))
    132132               
    133133                           if len(ids) > 0: self.ippToPspsDb.insertPending(box_id, batchType, ids)
    134134
    135                            dec = dec + self.config.boxSize
    136                        dec = self.config.minDec + self.config.halfBox
    137                        ra = ra + self.config.boxSize
     135                           dec = dec + self.skychunk.boxSize
     136                       dec = self.skychunk.minDec + self.skychunk.halfBox
     137                       ra = ra + self.skychunk.boxSize
    138138           
    139139                self.logger.info("+-------------+-------------+-------------+-------------+")
     
    153153   
    154154            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)
    156156            tarballFile = Batch.getTarballFile(batchID)
    157157            self.logger.infoPair("Batch name", batchName)
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/setupScratchDb.py

    r35073 r35076  
    22
    33import sys
     4import os
     5import socket
    46import stilts
    57from java.lang import *
    68from java.sql import *
    79
    8 
    9 from ipptopsps import IppToPsps
     10from config import Config
    1011from scratchdb import ScratchDb
     12from ipptopspsdb import IppToPspsDb
    1113
    1214'''
    1315SetupScratchDb class
    1416'''
    15 class SetupScratchDb(IppToPsps):
     17class 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'
    1623
    1724    ## XXX note that setupScratchDb.py fails if there are no valid
     
    4754    '''
    4855    def __init__(self, argv):
    49         super(SetupScratchDb, self).__init__(argv)
     56        # set up config object
     57        self.config = Config()
    5058
    51         if len(argv) < 3:
     59        if len(argv) < 2:
    5260            self.printUsage()
    5361            self.exitProgram("incorrect args")
    5462
     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
    5571        try:
    56             self.scratchDb = ScratchDb(self.logger, self.config, '0', argv[2])
     72            self.scratchDb = ScratchDb(self.logger, self.config, argv[1])
    5773        except:
    5874            self.exitProgram("Could not connect to a scratch Db")
    5975            raise
    60 
    6176
    6277    def run(self):
     
    7085        # install IN tables
    7186        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)
    7789
    7890        for table in tables:
     
    8698        self.scratchDb.createDvoTables()
    8799
    88     '''
    89     Overrides base-class version
    90     '''
    91100    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
    93107
    94108'''
     
    100114    setupScratchDb.exitProgram("completed")
    101115except: pass
    102 
    103 
  • branches/eam_branches/ipp-20121219/ippToPsps/jython/stackbatch.py

    r35060 r35076  
    3333                 logger,
    3434                 config,
     35                 skychunk,
    3536                 gpc1Db,
    3637                 ippToPspsDb,
     
    4344               logger,
    4445               config,
     46               skychunk,
    4547               gpc1Db,
    4648               ippToPspsDb,
     
    4951               batchID,
    5052               "ST",
    51                gpc1Db.getStackStageCmf(config.dvoLabel, stackID),
     53               gpc1Db.getStackStageCmf(skychunk.dvoLabel, stackID),
    5254               useFullTables)
    5355
     
    421423        self.scratchDb.updateAllRows("StackMeta", "surveyID", str(self.surveyID))
    422424        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))
    424426        self.updateStackTypeID("StackMeta")
    425427
     
    528530        self.scratchDb.updateFilterID("StackDetection", self.filter)
    529531       
    530         self.scratchDb.updateAllRows("StackDetection", "dataRelease", str(self.config.dataRelease))
     532        self.scratchDb.updateAllRows("StackDetection", "dataRelease", str(self.skychunk.dataRelease))
    531533       
    532534        self.scratchDb.updateAllRows("StackDetection", "primaryF", "0")
     
    612614        self.scratchDb.updateAllRows("StackApFlx", "surveyID", str(self.surveyID))
    613615        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))
    615617        self.scratchDb.updateAllRows("StackApFlx", "primaryF", "0")
    616618        self.scratchDb.updateAllRows("StackApFlx", "activeFlag", "0")
     
    646648        self.scratchDb.updateAllRows("StackModelFit", "surveyID", str(self.surveyID))
    647649        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))
    649651        self.scratchDb.updateAllRows("StackModelFit", "primaryF", "0")
    650652        self.scratchDb.updateAllRows("StackModelFit", "activeFlag", "0")
     
    711713
    712714        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))
    714716
    715717    '''   
     
    756758            AND b.imageID = " + str(imageID)
    757759        self.scratchDb.execute(sql)
    758         self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.config.dataRelease))
     760        self.scratchDb.updateAllRows(tableName, "dataRelease", str(self.skychunk.dataRelease))
    759761       
    760762    def populateStackDetectionCalib(self):
     
    787789          b.expTime,       \
    788790          b.airMass,       \
    789           " + str(self.config.dataRelease) + " \
     791          " + str(self.skychunk.dataRelease) + " \
    790792         FROM              \
    791793           StackDetection as a \
     
    801803
    802804        ## 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))
    804806
    805807    '''
     
    821823
    822824        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))
    824826
    825827
  • branches/eam_branches/ipp-20121219/ippToPsps/test/fulltest.sh

    r35063 r35076  
    2525# mkgpc1.sh user localhost eam eam
    2626
    27 set mkgpc1       = 1
    28 set initdb       = 1
    29 set mkdummy      = 1
    30 set initscratch  = 1
    31 set initbatch    = 1
    32 set camqueue     = 1
    33 set cambatch     = 1
     27set mkgpc1       = 0
     28set initdb       = 0
     29set mkdummy      = 0
     30set initscratch  = 0
     31set camqueue     = 0
     32set initbatch    = 0
     33set cambatch     = 0
    3434set stackqueue   = 1
    3535set stackbatch   = 1
     
    5454endif
    5555
    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
    8586
    8687# re-create the ipptopsps database
     
    9697  # mysql -h localhost -u dvo -pdvo -e "create database ipptopsps_scratch3"
    9798
    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
    101104endif
    102105
Note: See TracChangeset for help on using the changeset viewer.