LSSTApplications  19.0.0-14-gb0260a2+2d714fc2ef,20.0.0+34a42eae2c,20.0.0+76f397ef0c,20.0.0+8558dd3f48,20.0.0+a6b6977b51,20.0.0+b2ea66fa67,20.0.0+cc669a8b45,20.0.0+d561663fb5,20.0.0+d778e99126,20.0.0+efe67588cf,20.0.0+f45b7d88f4,20.0.0+f7c597f720,20.0.0+fb43bee9b9,20.0.0+fb4d547e0d,20.0.0-1-g10df615+d8b88ec1b5,20.0.0-1-g253301a+a6b6977b51,20.0.0-1-g498fb60+ff88705a28,20.0.0-1-g4d801e7+ce0d01dabd,20.0.0-1-g5b95a8c+24eaf908b3,20.0.0-1-g8a53f90+2817c06967,20.0.0-1-gc96f8cb+fb4d547e0d,20.0.0-1-gd1c87d7+2817c06967,20.0.0-1-gdb27ee5+abab67204f,20.0.0-13-ge998c5c+9f8c516ffa,20.0.0-18-g08fba245+88079d2923,20.0.0-2-gec03fae+fb98bf9d97,20.0.0-3-gdd5c15c+a61313b210,20.0.0-34-gdb4d86a+b43b2c05ff,20.0.0-4-g4a2362f+f45b7d88f4,20.0.0-4-gfea843c+f45b7d88f4,20.0.0-5-gac0d578b1+a8c4e2ada3,20.0.0-5-gfcebe35+cfceff6a24,20.0.0-6-g01203fff+e332440eaf,20.0.0-8-gea2affd+48c001ce3c,20.0.0-9-gabd0d4c+abab67204f,20.0.0-9-gf3ab18e+fb4d547e0d,w.2020.33
LSSTDataManagementBasePackage
Public Member Functions | Public Attributes | Properties | List of all members
pex.config.registry.RegistryInstanceDict Class Reference
Inheritance diagram for pex.config.registry.RegistryInstanceDict:
pex.config.configChoiceField.ConfigInstanceDict

Public Member Functions

def __init__ (self, config, field)
 
def apply (self, *args, **kw)
 
def __setattr__ (self, attr, value)
 
def types (self)
 
def __contains__ (self, k)
 
def __len__ (self)
 
def __iter__ (self)
 
def __getitem__ (self, k, at=None, label="default")
 
def __setitem__ (self, k, value, at=None, label="assignment")
 
def __setattr__ (self, attr, value, at=None, label="assignment")
 
def freeze (self)
 

Public Attributes

 registry
 

Properties

 target = property(_getTarget)
 
 targets = property(_getTargets)
 
 names = property(_getNames, _setNames, _delNames)
 
 name = property(_getName, _setName, _delName)
 
 active = property(_getActive)
 

Detailed Description

Dictionary of instantiated configs, used to populate a `RegistryField`.

Parameters
----------
config : `lsst.pex.config.Config`
    Configuration instance.
field : `RegistryField`
    Configuration field.

Definition at line 225 of file registry.py.

Constructor & Destructor Documentation

◆ __init__()

def pex.config.registry.RegistryInstanceDict.__init__ (   self,
  config,
  field 
)

Reimplemented from pex.config.configChoiceField.ConfigInstanceDict.

Definition at line 236 of file registry.py.

236  def __init__(self, config, field):
237  ConfigInstanceDict.__init__(self, config, field)
238  self.registry = field.registry
239 

Member Function Documentation

◆ __contains__()

def pex.config.configChoiceField.ConfigInstanceDict.__contains__ (   self,
  k 
)
inherited

Definition at line 162 of file configChoiceField.py.

162  def __contains__(self, k):
163  return k in self.types
164 

◆ __getitem__()

def pex.config.configChoiceField.ConfigInstanceDict.__getitem__ (   self,
  k,
  at = None,
  label = "default" 
)
inherited

Definition at line 252 of file configChoiceField.py.

252  def __getitem__(self, k, at=None, label="default"):
253  try:
254  value = self._dict[k]
255  except KeyError:
256  try:
257  dtype = self.types[k]
258  except Exception:
259  raise FieldValidationError(self._field, self._config,
260  "Unknown key %r in Registry/ConfigChoiceField" % k)
261  name = _joinNamePath(self._config._name, self._field.name, k)
262  if at is None:
263  at = getCallStack()
264  at.insert(0, dtype._source)
265  value = self._dict.setdefault(k, dtype(__name=name, __at=at, __label=label))
266  return value
267 

◆ __iter__()

def pex.config.configChoiceField.ConfigInstanceDict.__iter__ (   self)
inherited

Definition at line 168 of file configChoiceField.py.

168  def __iter__(self):
169  return iter(self.types)
170 

◆ __len__()

def pex.config.configChoiceField.ConfigInstanceDict.__len__ (   self)
inherited

Definition at line 165 of file configChoiceField.py.

165  def __len__(self):
166  return len(self.types)
167 

◆ __setattr__() [1/2]

def pex.config.registry.RegistryInstanceDict.__setattr__ (   self,
  attr,
  value 
)

Definition at line 276 of file registry.py.

276  def __setattr__(self, attr, value):
277  if attr == "registry":
278  object.__setattr__(self, attr, value)
279  else:
280  ConfigInstanceDict.__setattr__(self, attr, value)
281 
282 

◆ __setattr__() [2/2]

def pex.config.configChoiceField.ConfigInstanceDict.__setattr__ (   self,
  attr,
  value,
  at = None,
  label = "assignment" 
)
inherited

Definition at line 300 of file configChoiceField.py.

300  def __setattr__(self, attr, value, at=None, label="assignment"):
301  if hasattr(getattr(self.__class__, attr, None), '__set__'):
302  # This allows properties to work.
303  object.__setattr__(self, attr, value)
304  elif attr in self.__dict__ or attr in ["_history", "_field", "_config", "_dict",
305  "_selection", "__doc__", "_typemap"]:
306  # This allows specific private attributes to work.
307  object.__setattr__(self, attr, value)
308  else:
309  # We throw everything else.
310  msg = "%s has no attribute %s" % (_typeStr(self._field), attr)
311  raise FieldValidationError(self._field, self._config, msg)
312 

◆ __setitem__()

def pex.config.configChoiceField.ConfigInstanceDict.__setitem__ (   self,
  k,
  value,
  at = None,
  label = "assignment" 
)
inherited

Definition at line 268 of file configChoiceField.py.

268  def __setitem__(self, k, value, at=None, label="assignment"):
269  if self._config._frozen:
270  raise FieldValidationError(self._field, self._config, "Cannot modify a frozen Config")
271 
272  try:
273  dtype = self.types[k]
274  except Exception:
275  raise FieldValidationError(self._field, self._config, "Unknown key %r" % k)
276 
277  if value != dtype and type(value) != dtype:
278  msg = "Value %s at key %k is of incorrect type %s. Expected type %s" % \
279  (value, k, _typeStr(value), _typeStr(dtype))
280  raise FieldValidationError(self._field, self._config, msg)
281 
282  if at is None:
283  at = getCallStack()
284  name = _joinNamePath(self._config._name, self._field.name, k)
285  oldValue = self._dict.get(k, None)
286  if oldValue is None:
287  if value == dtype:
288  self._dict[k] = value(__name=name, __at=at, __label=label)
289  else:
290  self._dict[k] = dtype(__name=name, __at=at, __label=label, **value._storage)
291  else:
292  if value == dtype:
293  value = value()
294  oldValue.update(__at=at, __label=label, **value._storage)
295 

◆ apply()

def pex.config.registry.RegistryInstanceDict.apply (   self,
args,
**  kw 
)
Call the active target(s) with the active config as a keyword arg

If this is a multi-selection field, return a list obtained by calling
each active target with its corresponding active config.

Additional arguments will be passed on to the configurable target(s)

Definition at line 256 of file registry.py.

256  def apply(self, *args, **kw):
257  """Call the active target(s) with the active config as a keyword arg
258 
259  If this is a multi-selection field, return a list obtained by calling
260  each active target with its corresponding active config.
261 
262  Additional arguments will be passed on to the configurable target(s)
263  """
264  if self.active is None:
265  msg = "No selection has been made. Options: %s" % \
266  " ".join(self.types.registry.keys())
267  raise FieldValidationError(self._field, self._config, msg)
268  if self._field.multi:
269  retvals = []
270  for c in self._selection:
271  retvals.append(self.types.registry[c](*args, config=self[c], **kw))
272  return retvals
273  else:
274  return self.types.registry[self.name](*args, config=self[self.name], **kw)
275 

◆ freeze()

def pex.config.configChoiceField.ConfigInstanceDict.freeze (   self)
inherited
Invoking this freeze method will create a local copy of the field
attribute's typemap. This decouples this instance dict from the
underlying objects type map ensuring that and subsequent changes to the
typemap will not be reflected in this instance (i.e imports adding
additional registry entries).

Definition at line 313 of file configChoiceField.py.

313  def freeze(self):
314  """Invoking this freeze method will create a local copy of the field
315  attribute's typemap. This decouples this instance dict from the
316  underlying objects type map ensuring that and subsequent changes to the
317  typemap will not be reflected in this instance (i.e imports adding
318  additional registry entries).
319  """
320  if self._typemap is None:
321  self._typemap = copy.deepcopy(self.types)
322 
323 

◆ types()

def pex.config.configChoiceField.ConfigInstanceDict.types (   self)
inherited

Definition at line 159 of file configChoiceField.py.

159  def types(self):
160  return self._typemap if self._typemap is not None else self._field.typemap
161 

Member Data Documentation

◆ registry

pex.config.registry.RegistryInstanceDict.registry

Definition at line 238 of file registry.py.

Property Documentation

◆ active

pex.config.configChoiceField.ConfigInstanceDict.active = property(_getActive)
staticinherited

Definition at line 245 of file configChoiceField.py.

◆ name

pex.config.configChoiceField.ConfigInstanceDict.name = property(_getName, _setName, _delName)
staticinherited

Definition at line 230 of file configChoiceField.py.

◆ names

pex.config.configChoiceField.ConfigInstanceDict.names = property(_getNames, _setNames, _delNames)
staticinherited

Definition at line 224 of file configChoiceField.py.

◆ target

pex.config.registry.RegistryInstanceDict.target = property(_getTarget)
static

Definition at line 246 of file registry.py.

◆ targets

pex.config.registry.RegistryInstanceDict.targets = property(_getTargets)
static

Definition at line 254 of file registry.py.


The documentation for this class was generated from the following file:
pex.config.callStack.getCallStack
def getCallStack(skip=0)
Definition: callStack.py:175
type
table::Key< int > type
Definition: Detector.cc:163
astshim.fitsChanContinued.iter
def iter(self)
Definition: fitsChanContinued.py:88