LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Private Attributes | List of all members
lsst.daf.persistence.mapper.Mapper Class Reference
Inheritance diagram for lsst.daf.persistence.mapper.Mapper:
lsst.daf.butlerUtils.cameraMapper.CameraMapper lsst.pipe.tasks.mocks.simpleMapper.SimpleMapper

Public Member Functions

def __new__
 
def __init__
 
def __getstate__
 
def __setstate__
 
def keys
 
def queryMetadata
 
def getDatasetTypes
 
def map
 
def canStandardize
 
def standardize
 
def validate
 
def backup
 

Private Attributes

 _arguments
 

Detailed Description

Mapper is a base class for all mappers.

Subclasses may define the following methods:

map_{datasetType}(self, dataId, write)
    Map a dataset id for the given dataset type into a ButlerLocation.
    If write=True, this mapping is for an output dataset.

query_{datasetType}(self, key, format, dataId)
    Return the possible values for the format fields that would produce
    datasets at the granularity of key in combination with the provided
    partial dataId.

std_{datasetType}(self, item)
    Standardize an object of the given data set type.

Methods that must be overridden:

keys(self)
    Return a list of the keys that can be used in data ids.

Other public methods:

__init__(self)

getDatasetTypes(self)

map(self, datasetType, dataId, write=False)

queryMetadata(self, datasetType, key, format, dataId)

canStandardize(self, datasetType)

standardize(self, datasetType, item, dataId)

validate(self, dataId)

Definition at line 28 of file mapper.py.

Constructor & Destructor Documentation

def lsst.daf.persistence.mapper.Mapper.__init__ (   self)

Definition at line 83 of file mapper.py.

83 
84  def __init__(self):
85  pass

Member Function Documentation

def lsst.daf.persistence.mapper.Mapper.__getstate__ (   self)

Definition at line 86 of file mapper.py.

86 
87  def __getstate__(self):
88  return self._arguments
def lsst.daf.persistence.mapper.Mapper.__new__ (   cls,
  args,
  kwargs 
)
Create a new Mapper, saving arguments for pickling.

This is in __new__ instead of __init__ to save the user
from having to save the arguments themselves (either explicitly,
or by calling the super's __init__ with all their
*args,**kwargs.  The resulting pickling system (of __new__,
__getstate__ and __setstate__ is similar to how __reduce__
is usually used, except that we save the user from any
responsibility (except when overriding __new__, but that
is not common).

Definition at line 67 of file mapper.py.

67 
68  def __new__(cls, *args, **kwargs):
69  """Create a new Mapper, saving arguments for pickling.
70 
71  This is in __new__ instead of __init__ to save the user
72  from having to save the arguments themselves (either explicitly,
73  or by calling the super's __init__ with all their
74  *args,**kwargs. The resulting pickling system (of __new__,
75  __getstate__ and __setstate__ is similar to how __reduce__
76  is usually used, except that we save the user from any
77  responsibility (except when overriding __new__, but that
78  is not common).
79  """
80  self = super(Mapper, cls).__new__(cls)
81  self._arguments = (args, kwargs)
82  return self
def lsst.daf.persistence.mapper.Mapper.__setstate__ (   self,
  state 
)

Definition at line 89 of file mapper.py.

89 
90  def __setstate__(self, state):
91  self._arguments = state
92  args, kwargs = state
93  self.__init__(*args, **kwargs)
def lsst.daf.persistence.mapper.Mapper.backup (   self,
  datasetType,
  dataId 
)
Rename any existing object with the given type and dataId.

Not implemented in the base mapper.

Definition at line 142 of file mapper.py.

143  def backup(self, datasetType, dataId):
144  """Rename any existing object with the given type and dataId.
145 
146  Not implemented in the base mapper.
147  """
148  raise NotImplementedError("Base-class Mapper does not implement backups")
def lsst.daf.persistence.mapper.Mapper.canStandardize (   self,
  datasetType 
)
Return true if this mapper can standardize an object of the given
dataset type.

Definition at line 118 of file mapper.py.

119  def canStandardize(self, datasetType):
120  """Return true if this mapper can standardize an object of the given
121  dataset type."""
122 
123  return hasattr(self, 'std_' + datasetType)
def lsst.daf.persistence.mapper.Mapper.getDatasetTypes (   self)
Return a list of the mappable dataset types.

Definition at line 103 of file mapper.py.

104  def getDatasetTypes(self):
105  """Return a list of the mappable dataset types."""
106 
107  list = []
108  for attr in dir(self):
109  if attr.startswith("map_"):
110  list.append(attr[4:])
111  return list
def lsst.daf.persistence.mapper.Mapper.keys (   self)

Definition at line 94 of file mapper.py.

94 
95  def keys(self):
96  raise NotImplementedError("keys() unimplemented")
def lsst.daf.persistence.mapper.Mapper.map (   self,
  datasetType,
  dataId,
  write = False 
)
Map a data id using the mapping method for its dataset type.

Definition at line 112 of file mapper.py.

113  def map(self, datasetType, dataId, write=False):
114  """Map a data id using the mapping method for its dataset type."""
115 
116  func = getattr(self, 'map_' + datasetType)
117  return func(self.validate(dataId), write)
def lsst.daf.persistence.mapper.Mapper.queryMetadata (   self,
  datasetType,
  key,
  format,
  dataId 
)
Return possible values for keys given a partial data id.

Definition at line 97 of file mapper.py.

97 
98  def queryMetadata(self, datasetType, key, format, dataId):
99  """Return possible values for keys given a partial data id."""
100 
101  func = getattr(self, 'query_' + datasetType)
102  return func(key, format, self.validate(dataId))
def lsst.daf.persistence.mapper.Mapper.standardize (   self,
  datasetType,
  item,
  dataId 
)
Standardize an object using the standardization method for its data
set type, if it exists.

Definition at line 124 of file mapper.py.

125  def standardize(self, datasetType, item, dataId):
126  """Standardize an object using the standardization method for its data
127  set type, if it exists."""
128 
129  if hasattr(self, 'std_' + datasetType):
130  func = getattr(self, 'std_' + datasetType)
131  return func(item, self.validate(dataId))
132  return item
def lsst.daf.persistence.mapper.Mapper.validate (   self,
  dataId 
)
Validate a dataId's contents.

If the dataId is valid, return it.  If an invalid component can be
transformed into a valid one, copy the dataId, fix the component, and
return the copy.  Otherwise, raise an exception.

Definition at line 133 of file mapper.py.

134  def validate(self, dataId):
135  """Validate a dataId's contents.
136 
137  If the dataId is valid, return it. If an invalid component can be
138  transformed into a valid one, copy the dataId, fix the component, and
139  return the copy. Otherwise, raise an exception."""
140 
141  return dataId

Member Data Documentation

lsst.daf.persistence.mapper.Mapper._arguments
private

Definition at line 80 of file mapper.py.


The documentation for this class was generated from the following file: