LSST Applications g0265f82a02+0e5473021a,g02d81e74bb+0dd8ce4237,g1470d8bcf6+3ea6592b6f,g2079a07aa2+86d27d4dc4,g2305ad1205+5ca4c0b359,g295015adf3+d10818ec9d,g2a9a014e59+6f9be1b9cd,g2bbee38e9b+0e5473021a,g337abbeb29+0e5473021a,g3ddfee87b4+703ba97ebf,g487adcacf7+4fa16da234,g50ff169b8f+96c6868917,g52b1c1532d+585e252eca,g591dd9f2cf+ffa42b374e,g5a732f18d5+53520f316c,g64a986408d+0dd8ce4237,g858d7b2824+0dd8ce4237,g8a8a8dda67+585e252eca,g99cad8db69+d39438377f,g9ddcbc5298+9a081db1e4,ga1e77700b3+15fc3df1f7,ga8c6da7877+f1d96605c8,gb0e22166c9+60f28cb32d,gb6a65358fc+0e5473021a,gba4ed39666+c2a2e4ac27,gbb8dafda3b+e5339d463f,gc120e1dc64+da31e9920e,gc28159a63d+0e5473021a,gcf0d15dbbd+703ba97ebf,gdaeeff99f8+f9a426f77a,ge6526c86ff+889fc9d533,ge79ae78c31+0e5473021a,gee10cc3b42+585e252eca,gf18bd8381d+7268b93478,gff1a9f87cc+0dd8ce4237,w.2024.16
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct Class Reference
Inheritance diagram for lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct:

Public Member Functions

 __init__ (self, Config config, ConfigurableActionStructField field, Mapping[str, ConfigurableAction] value, Any at, str label)
 
list[tuple] history (self)
 
Iterable[str] fieldNames (self)
 
None __setattr__ (self, str attr, ActionTypeVar|type[ActionTypeVar] value, at=None, label="setattr", setHistory=False)
 
Any __getattr__ (self, attr)
 
 __delattr__ (self, name)
 
Iterator[ActionTypeVar] __iter__ (self)
 
Iterable[tuple[str, ActionTypeVar]] items (self)
 
bool __bool__ (self)
 

Static Public Attributes

 update = ConfigurableActionStructUpdater()
 
 remove = ConfigurableActionStructRemover()
 

Protected Member Functions

Config _config (self)
 

Protected Attributes

 _config
 
 _field
 
 _attrs
 

Static Protected Attributes

weakref _config_ .ref
 
dict _attrs [str, ActionTypeVar]
 
ConfigurableActionStructField _field
 
list _history [tuple]
 

Detailed Description

A ConfigurableActionStruct is the storage backend class that supports
the ConfigurableActionStructField. This class should not be created
directly.

This class allows managing a collection of `ConfigurableAction` with a
struct like interface, that is to say in an attribute like notation.

Parameters
----------
config : `~lsst.pex.config.Config`
    Config to use.
field : `ConfigurableActionStructField`
    Field to use.
value : `~collections.abc.Mapping` [`str`, `ConfigurableAction`]
    Value to assign.
at : `list` of `~lsst.pex.config.callStack.StackFrame` or `None`, optional
    Stack frames to use for history recording.
label : `str`, optional
    Label to use for history recording.

Notes
-----
Attributes can be dynamically added or removed as such:

.. code-block:: python

    ConfigurableActionStructInstance.variable1 = a_configurable_action
    del ConfigurableActionStructInstance.variable1

Each action is then available to be individually configured as a normal
`lsst.pex.config.Config` object.

`ConfigurableActionStruct` supports two special convenience attributes.

The first is ``update``. You may assign a dict of `ConfigurableAction` or a
`ConfigurableActionStruct` to this attribute which will update the
`ConfigurableActionStruct` on which the attribute is invoked such that it
will be updated to contain the entries specified by the structure on the
right hand side of the equals sign.

The second convenience attribute is named ``remove``. You may assign an
iterable of strings which correspond to attribute names on the
`ConfigurableActionStruct`. All of the corresponding attributes will then
be removed. If any attribute does not exist, an `AttributeError` will be
raised. Any attributes in the Iterable prior to the name which raises will
have been removed from the `ConfigurableActionStruct`

Definition at line 96 of file _configurableActionStructField.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct.__init__ ( self,
Config config,
ConfigurableActionStructField field,
Mapping[str, ConfigurableAction] value,
Any at,
str label )

Definition at line 155 of file _configurableActionStructField.py.

162 ):
163 object.__setattr__(self, "_config_", weakref.ref(config))
164 object.__setattr__(self, "_attrs", {})
165 object.__setattr__(self, "_field", field)
166 object.__setattr__(self, "_history", [])
167
168 self.history.append(("Struct initialized", at, label))
169
170 if value is not None:
171 for k, v in value.items():
172 setattr(self, k, v)
173

Member Function Documentation

◆ __bool__()

bool lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct.__bool__ ( self)

Definition at line 242 of file _configurableActionStructField.py.

242 def __bool__(self) -> bool:
243 return bool(self._attrs)
244
245

◆ __delattr__()

lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct.__delattr__ ( self,
name )

Definition at line 228 of file _configurableActionStructField.py.

228 def __delattr__(self, name):
229 if name in self._attrs:
230 del self._attrs[name]
231 else:
232 super().__delattr__(name)
233

◆ __getattr__()

Any lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct.__getattr__ ( self,
attr )

Definition at line 220 of file _configurableActionStructField.py.

220 def __getattr__(self, attr) -> Any:
221 if attr in object.__getattribute__(self, "_attrs"):
222 result = self._attrs[attr]
223 result.identity = attr
224 return result
225 else:
226 super().__getattribute__(attr)
227

◆ __iter__()

Iterator[ActionTypeVar] lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct.__iter__ ( self)

Definition at line 234 of file _configurableActionStructField.py.

234 def __iter__(self) -> Iterator[ActionTypeVar]:
235 for name in self.fieldNames:
236 yield getattr(self, name)
237

◆ __setattr__()

None lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct.__setattr__ ( self,
str attr,
ActionTypeVar | type[ActionTypeVar] value,
at = None,
label = "setattr",
setHistory = False )

Definition at line 190 of file _configurableActionStructField.py.

197 ) -> None:
198 if hasattr(self._config, "_frozen") and self._config._frozen:
199 msg = "Cannot modify a frozen Config. " f"Attempting to set item {attr} to value {value}"
200 raise FieldValidationError(self._field, self._config, msg)
201
202 # verify that someone has not passed a string with a space or leading
203 # number or something through the dict assignment update interface
204 if not attr.isidentifier():
205 raise ValueError("Names used in ConfigurableStructs must be valid as python variable names")
206
207 if attr not in (self.__dict__.keys() | type(self).__dict__.keys()):
208 base_name = _joinNamePath(self._config._name, self._field.name)
209 name = _joinNamePath(base_name, attr)
210 if at is None:
211 at = getCallStack()
212 if isinstance(value, ConfigurableAction):
213 valueInst = type(value)(__name=name, __at=at, __label=label, **value._storage)
214 else:
215 valueInst = value(__name=name, __at=at, __label=label)
216 self._attrs[attr] = valueInst
217 else:
218 super().__setattr__(attr, value)
219

◆ _config()

Config lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct._config ( self)
protected

Definition at line 175 of file _configurableActionStructField.py.

175 def _config(self) -> Config:
176 # Config Fields should never outlive their config class instance
177 # assert that as such here
178 value = self._config_()
179 assert value is not None
180 return value
181

◆ fieldNames()

Iterable[str] lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct.fieldNames ( self)

Definition at line 187 of file _configurableActionStructField.py.

187 def fieldNames(self) -> Iterable[str]:
188 return self._attrs.keys()
189

◆ history()

list[tuple] lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct.history ( self)

Definition at line 183 of file _configurableActionStructField.py.

183 def history(self) -> list[tuple]:
184 return self._history
185

◆ items()

Iterable[tuple[str, ActionTypeVar]] lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct.items ( self)

Definition at line 238 of file _configurableActionStructField.py.

238 def items(self) -> Iterable[tuple[str, ActionTypeVar]]:
239 for name in self.fieldNames:
240 yield name, getattr(self, name)
241
std::vector< SchemaItem< Flag > > * items

Member Data Documentation

◆ _attrs [1/2]

dict lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct._attrs [str, ActionTypeVar]
staticprotected

Definition at line 147 of file _configurableActionStructField.py.

◆ _attrs [2/2]

lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct._attrs
protected

Definition at line 243 of file _configurableActionStructField.py.

◆ _config

lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct._config
protected

Definition at line 198 of file _configurableActionStructField.py.

◆ _config_

weakref lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct._config_ .ref
staticprotected

Definition at line 146 of file _configurableActionStructField.py.

◆ _field [1/2]

ConfigurableActionStructField lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct._field
staticprotected

Definition at line 148 of file _configurableActionStructField.py.

◆ _field [2/2]

lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct._field
protected

Definition at line 200 of file _configurableActionStructField.py.

◆ _history

list lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct._history [tuple]
staticprotected

Definition at line 149 of file _configurableActionStructField.py.

◆ remove

lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct.remove = ConfigurableActionStructRemover()
static

Definition at line 153 of file _configurableActionStructField.py.

◆ update

lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct.update = ConfigurableActionStructUpdater()
static

Definition at line 152 of file _configurableActionStructField.py.


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