/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes | Properties | Private Member Functions | Private Attributes
Scraper::daq::runinfo::RunInfo Class Reference
Inheritance diagram for Scraper::daq::runinfo::RunInfo:
Inheritance graph
[legend]
Collaboration diagram for Scraper::daq::runinfo::RunInfo:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __repr__
def __str__
def __call__
def make_CalibRunInfo

Public Attributes

 errors

Properties

 run = property( _set_run, _get_run )
 is_collected = property(_is_collected, doc=_is_collected.__doc__)
 is_valid = property(_is_valid, doc=_is_valid.__doc__)
 partition = property(lambda self:self['partitionName'].split("_")[-1])
 is_calibrun = property(lambda self:self.get('runType',None) == 'ADCalib')

Private Member Functions

def _set_run
def _get_run
def _is_collected
def _is_valid
def _preflight

Private Attributes

 _run

Detailed Description

Collects from DAQ tables, and prepares to write to offline, usage::

     from NonDbi import MetaDB
     daqm = MetaDB("tmp_daqdb")
     offm = MetaDB("tmp_offline_db")    

     ri = RunInfo(14000, daqm,offm)                   ## dolittle ctor, needs daqm and offm globals

     if ri.is_collected:                   ## querys offline
         print "already collected "
     else:
         ri()                              ## call perform the DAQ querying 
         if ri.is_valid:
             print str(ri)
         else:
             print ri.errors

Definition at line 8 of file runinfo.py.


Constructor & Destructor Documentation

def Scraper::daq::runinfo::RunInfo::__init__ (   self,
  source = "tmp_daqdb",
  target = "tmp_offline_db" 
)

Definition at line 28 of file runinfo.py.

00029                                                                     :
00030         BaseInfo.__init__(self, source, target )
00031         self._run = None
00032         self.errors = []


Member Function Documentation

def Scraper::daq::runinfo::RunInfo::_set_run (   self,
  run 
) [private]

Definition at line 33 of file runinfo.py.

00034                              :
00035         self._run = run
        self.errors = [] 
def Scraper::daq::runinfo::RunInfo::_get_run (   self) [private]

Definition at line 36 of file runinfo.py.

00037                        :
        return self._run 
def Scraper::daq::runinfo::RunInfo::__repr__ (   self)

Definition at line 40 of file runinfo.py.

00041                       :
00042         return "%s(%s)" % ( self.__class__.__name__, self._run )

def Scraper::daq::runinfo::RunInfo::__str__ (   self)

Definition at line 43 of file runinfo.py.

00044                      :
00045         return  "%s(%s)\n%s " % (  self.__class__.__name__, self._run , pformat(dict(self)) )

def Scraper::daq::runinfo::RunInfo::_is_collected (   self) [private]
Returns True when run number already appears in offline table ``DaqRunInfo``

Based on is_NewRun, needs only the run, so can be done before the ``__call__``

Definition at line 46 of file runinfo.py.

00047                            :
00048         """
00049         Returns True when run number already appears in offline table ``DaqRunInfo``
00050 
00051         Based on is_NewRun, needs only the run, so can be done before the ``__call__``
00052         """
00053         off = self.target()
00054         kdri = self.target.dbikls_("DaqRunInfo")
00055         n = off.query(kdri).filter(kdri.runNo == self._run).count()
        return n > 0
def Scraper::daq::runinfo::RunInfo::_is_valid (   self) [private]
Returns True when self has content and no errors

Definition at line 58 of file runinfo.py.

00059                        :
00060         """ 
00061         Returns True when self has content and no errors
00062         """
        return len(self) > 0 and len(self.errors) == 0
def Scraper::daq::runinfo::RunInfo::_preflight (   self) [private]
Formerly called `Validate`, prepares for DBI Vld Table

#. sets timeEnd based on timeStart and duration
#. converts to UTC

Definition at line 65 of file runinfo.py.

00066                         :
00067         """
00068         Formerly called `Validate`, prepares for DBI Vld Table
00069 
00070         #. sets timeEnd based on timeStart and duration
00071         #. converts to UTC
00072 
00073         """
00074         self['timeEnd'] = self['timeStart'] + timedelta(seconds=self['duration'])
00075         ## tz correction
00076         self['timeStart'] = self['timeStart'] + timedelta(seconds=time.timezone)
00077         self['timeEnd']   = self['timeEnd']   + timedelta(seconds=time.timezone)
00078         self['insertDate'] = datetime.now()   + timedelta(seconds=time.timezone)    ## this can go away when migrate to DybDbi

def Scraper::daq::runinfo::RunInfo::__call__ (   self)
Based on `get_newRunInfo` collects from DAQ tables into self:

    =====================     ========================================
      DAQ tables                 notes
    =====================     ========================================
      RUNNUMBER              
      OKSDATA
      data_tbl_onl_4_1          filled at start-of-run, **no PK**
    =====================     ========================================

no PK causes the mapping to fail for data_tbl_onl_4_1 thus revertd to low level approach 

Definition at line 79 of file runinfo.py.

00080                       :
00081         """
00082         Based on `get_newRunInfo` collects from DAQ tables into self:
00083 
00084             =====================     ========================================
00085               DAQ tables                 notes
00086             =====================     ========================================
00087               RUNNUMBER              
00088               OKSDATA
00089               data_tbl_onl_4_1          filled at start-of-run, **no PK**
00090             =====================     ========================================
00091 
00092         no PK causes the mapping to fail for data_tbl_onl_4_1 thus revertd to low level approach 
00093         """
00094 
00095         daq = self.source()
00096         krn = self.source.kls_("RUNNUMBER")
00097         rn = daq.query(krn).filter(krn.RUNNUMBER == self.run).one()   ## will throw exception if not **one** entry
00098         self.update( partitionName=rn.PARTITIONNAME, schemaVersion=rn.CONFIGSCHEMA, dataVersion=rn.CONFIGDATA, timeStart=rn.STARTAT, duration=rn.DURATION )
00099         if self['schemaVersion'] == 0 or self['dataVersion'] == 0:
00100             msg = "Unexpected RUNNUMBER entry for %s  %s " % ( self.run, vars(rn) )  
00101             log.warn(msg)
00102             self.errors.append(msg)
00103             return None
00104 
00105         kod = self.source.kls_("OKSDATA")
00106         od = daq.query(kod).filter(kod.SCHEMAVERSION == self['schemaVersion']).filter(kod.VERSION == self['dataVersion']).first()
00107         self['baseVersion'] = od.BASEVERSION
00108 
00109         engine = daq.metadb.engine
00110         result = engine.execute("SELECT trigger_type, run_type, detector_mask, timeSOR from data_tbl_onl_4_1 where run_number = %s " % self.run ) 
00111         row = result.fetchone()
00112         if row:
00113             self['triggerType'], self['runType'], self['detectorMask'], self['timeStart'] = row 
00114         else:  
00115             msg = "NO record in data_tbl_onl_4_1 for run %s " % self.run 
00116             log.warn(msg )
00117             self.errors.append(msg)
00118             return None
00119 
00120         self._preflight()
00121         return self  

def Scraper::daq::runinfo::RunInfo::make_CalibRunInfo (   self)

Definition at line 125 of file runinfo.py.

00126                                :
00127         return CalibRunInfo( self.run , self.partition, self.source, self.target )
00128        
00129 


Member Data Documentation

Definition at line 28 of file runinfo.py.

Definition at line 28 of file runinfo.py.


Property Documentation

Scraper::daq::runinfo::RunInfo::run = property( _set_run, _get_run ) [static]

Definition at line 38 of file runinfo.py.

Scraper::daq::runinfo::RunInfo::is_collected = property(_is_collected, doc=_is_collected.__doc__) [static]

Definition at line 56 of file runinfo.py.

Scraper::daq::runinfo::RunInfo::is_valid = property(_is_valid, doc=_is_valid.__doc__) [static]

Definition at line 63 of file runinfo.py.

Scraper::daq::runinfo::RunInfo::partition = property(lambda self:self['partitionName'].split("_")[-1]) [static]

Definition at line 122 of file runinfo.py.

Scraper::daq::runinfo::RunInfo::is_calibrun = property(lambda self:self.get('runType',None) == 'ADCalib') [static]

Definition at line 123 of file runinfo.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:50:03 for Scraper by doxygen 1.7.4