IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 8, 2011, 2:44:12 PM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20110906
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110906

  • branches/eam_branches/ipp-20110906/ippToPsps/jython/load.py

    r32227 r32630  
    77import time
    88import sys
     9import os
     10import socket
    911import logging.config
    1012from xml.etree.ElementTree import ElementTree, Element, tostring
     
    3537        logger.infoPair("Batch name", batchName)
    3638
    37         Batch.publishToDatastore(datastore, ippToPspsDb, batchID, batchName, subDir, tarballFile)
    38 
     39        Batch.publishToDatastore(datastore, batchID, batchName, subDir, tarballFile)
    3940
    4041'''
     
    5455        logger.errorPair("Problem loading IDs from config under", "options/ids/id")
    5556
    56     # no config dictated IDs, so get from DVO instead
    5757    if len(allIDs) > 0:
    5858        logger.infoPair("Using config IDs (not DVO)", "%d" % len(allIDs))
     59    # no config dictated IDs, so get from DVO instead
    5960    else:
    60         allIDs = gpc1Db.getIDsInThisDVODbForThisStage(DVOGPC1LABEL, batchType)
     61
     62        if MINRA and MAXRA and MINDEC and MAXDEC:
     63            allIDs = gpc1Db.getIDsInThisDVODbForThisStage(DVOGPC1LABEL, batchType, MINRA, MAXRA, MINDEC, MAXDEC)
     64        else:
     65            allIDs = gpc1Db.getIDsInThisDVODbForThisStage(DVOGPC1LABEL, batchType)
     66
    6167        logger.infoPair("All %s items in DVO" % batchType, "%d" % len(allIDs))
    6268
     
    6773    else:
    6874        processedIDs = ippToPspsDb.getProcessedIDs(batchType, EPOCH, DVOGPC1LABEL)
    69         logger.infoPair("Processed %s items" % batchType, "%d" % len(processedIDs))
    70         ids = list(set(allIDs) - set(processedIDs))
    71         logger.infoPair("Unprocessed %s items" % batchType, "%d" % len(ids))
     75        consistaentlyFailedIDs = ippToPspsDb.getConsistentlyFailedIDs(batchType, EPOCH, DVOGPC1LABEL)
     76        ids = list(set(allIDs) - set(processedIDs) - set(consistaentlyFailedIDs))
     77        logger.infoPair("Processed items", "%d" % len(processedIDs))
     78        logger.infoPair("Consistently failing items", "%d" % len(consistaentlyFailedIDs))
     79        logger.infoPair("Unprocessed items", "%d" % len(ids))
    7280
    7381    logger.infoPair("%s items queued" % batchType, "%d" % len(ids))
    7482
    7583    # loop round IDs of all items to be processed
     84    ippToPspsDb.lockBatchTable()
    7685    for id in ids:
    7786
    78         if not FORCE and ippToPspsDb.alreadyProcessed(batchType, id, EPOCH, DVOGPC1LABEL): continue
    79         if not FORCE and ippToPspsDb.consistentlyFailed(batchType, id, EPOCH, DVOGPC1LABEL, 3): continue
     87        batchID = ippToPspsDb.createNewBatch(
     88                batchType,
     89                id,
     90                SURVEY,
     91                EPOCH,
     92                DVOGPC1LABEL,
     93                datastore.product,
     94                FORCE)
     95       
     96        if batchID < 0: continue;
     97
     98        ippToPspsDb.unlockTables()
    8099
    81100        if batchType == "P2":
     
    85104                    gpc1Db,
    86105                    ippToPspsDb,
    87                     id)
     106                    id,
     107                    batchID)
    88108        elif batchType == "ST":
    89109            batch = StackBatch(logger,
     
    92112                    gpc1Db,
    93113                    ippToPspsDb,
    94                     id)
     114                    id,
     115                    batchID)
    95116
    96117        batch.run()
     118
     119        ippToPspsDb.lockBatchTable()
     120
     121        logger.infoSeparator()
    97122
    98123        # if in TEST mode, then quit after one batch
    99124        if TEST: break
    100125
     126    ippToPspsDb.unlockTables()
    101127
    102128'''
     
    122148logger = logging.getLogger("ippToPspsLog")
    123149
     150# get hostnamee and PID for unique log naming
     151HOST = socket.gethostname()
     152PID = os.getpid()
     153
    124154# if in test mode, print log to screen, otherwise, only to file
    125 logger.setup(configDoc, "ippToPsps", TEST, not TEST)
     155logger.setup(configDoc, "ippToPsps", TEST, not TEST, HOST, PID)
    126156
    127157# create database objects
    128158gpc1Db = Gpc1Db(logger, configDoc)
    129159ippToPspsDb = IppToPspsDb(logger, configDoc)
    130 datastore = Datastore(logger, configDoc)
     160datastore = Datastore(logger, configDoc, ippToPspsDb)
    131161
    132162# check we connected ok
     
    143173QUEUE_P2 = int(configDoc.find("options/queueP2").text)
    144174QUEUE_ST = int(configDoc.find("options/queueST").text)
     175SURVEY = configDoc.find("options/survey").text
     176
     177# get equatorial coord limits, if any
     178MINRA = None
     179MAXRA = None
     180MINDEC = None
     181MAXDEC = None
     182try:
     183    MINRA = float(configDoc.find("dvo/minRA").text)
     184    MAXRA = float(configDoc.find("dvo/maxRA").text)
     185    MINDEC = float(configDoc.find("dvo/minDec").text)
     186    MAXDEC = float(configDoc.find("dvo/maxDec").text)
     187except:
     188    pass
    145189
    146190# prompt user: FORCE and PUBLISH is a dangerous combination
     
    180224    # queue all items for all batch types, sequentially
    181225    if QUEUE_IN:
    182        batch = InitBatch(logger, CONFIG, configDoc, gpc1Db, ippToPspsDb)
    183        batch.run()
     226       batchID = ippToPspsDb.createNewBatch(
     227                 "IN",
     228                 0,
     229                 SURVEY,
     230                 EPOCH,
     231                 DVOGPC1LABEL,
     232                 datastore.product,
     233                 1)
     234       if batchID > 0:
     235           batch = InitBatch(logger, CONFIG, configDoc, gpc1Db, ippToPspsDb, batchID)
     236           batch.run()
    184237       break;
    185238
Note: See TracChangeset for help on using the changeset viewer.