LSST Applications g00274db5b6+edbf708997,g00d0e8bbd7+edbf708997,g199a45376c+5137f08352,g1fd858c14a+1d4b6db739,g262e1987ae+f4d9505c4f,g29ae962dfc+7156fb1a53,g2cef7863aa+73c82f25e4,g35bb328faa+edbf708997,g3e17d7035e+5b3adc59f5,g3fd5ace14f+852fa6fbcb,g47891489e3+6dc8069a4c,g53246c7159+edbf708997,g64539dfbff+9f17e571f4,g67b6fd64d1+6dc8069a4c,g74acd417e5+ae494d68d9,g786e29fd12+af89c03590,g7ae74a0b1c+a25e60b391,g7aefaa3e3d+536efcc10a,g7cc15d900a+d121454f8d,g87389fa792+a4172ec7da,g89139ef638+6dc8069a4c,g8d7436a09f+28c28d8d6d,g8ea07a8fe4+db21c37724,g92c671f44c+9f17e571f4,g98df359435+b2e6376b13,g99af87f6a8+b0f4ad7b8d,gac66b60396+966efe6077,gb88ae4c679+7dec8f19df,gbaa8f7a6c5+38b34f4976,gbf99507273+edbf708997,gc24b5d6ed1+9f17e571f4,gca7fc764a6+6dc8069a4c,gcc769fe2a4+97d0256649,gd7ef33dd92+6dc8069a4c,gdab6d2f7ff+ae494d68d9,gdbb4c4dda9+9f17e571f4,ge410e46f29+6dc8069a4c,geaed405ab2+e194be0d2b,w.2025.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
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)
 

Public Attributes

 history
 
 fieldNames
 

Static Public Attributes

 update = ConfigurableActionStructUpdater()
 
 remove = ConfigurableActionStructRemover()
 

Protected Member Functions

ConfigurableActionStruct _copy (self, Config config)
 
Config _config (self)
 

Protected Attributes

 _config
 
 _field = f"Cannot modify a frozen Config. Attempting to set item {attr} to value {value}"
 

Static Protected Attributes

weakref _config_ .ref
 
dict _attrs [str, ActionTypeVar]
 
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 if at is not None:
169 self.history.append(("Struct initialized", at, label))
170
171 if value is not None:
172 for k, v in value.items():
173 setattr(self, k, v)
174

Member Function Documentation

◆ __bool__()

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

Definition at line 248 of file _configurableActionStructField.py.

248 def __bool__(self) -> bool:
249 return bool(self._attrs)
250
251

◆ __delattr__()

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

Definition at line 234 of file _configurableActionStructField.py.

234 def __delattr__(self, name):
235 if name in self._attrs:
236 del self._attrs[name]
237 else:
238 super().__delattr__(name)
239

◆ __getattr__()

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

Definition at line 226 of file _configurableActionStructField.py.

226 def __getattr__(self, attr) -> Any:
227 if attr in object.__getattribute__(self, "_attrs"):
228 result = self._attrs[attr]
229 result.identity = attr
230 return result
231 else:
232 super().__getattribute__(attr)
233

◆ __iter__()

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

Definition at line 240 of file _configurableActionStructField.py.

240 def __iter__(self) -> Iterator[ActionTypeVar]:
241 for name in self.fieldNames:
242 yield getattr(self, name)
243

◆ __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 196 of file _configurableActionStructField.py.

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

◆ _config()

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

Definition at line 181 of file _configurableActionStructField.py.

181 def _config(self) -> Config:
182 # Config Fields should never outlive their config class instance
183 # assert that as such here
184 value = self._config_()
185 assert value is not None
186 return value
187

◆ _copy()

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

Definition at line 175 of file _configurableActionStructField.py.

175 def _copy(self, config: Config) -> ConfigurableActionStruct:
176 result = ConfigurableActionStruct(config, self._field, self._attrs, at=None, label="copy")
177 result.history.extend(self.history)
178 return result
179

◆ fieldNames()

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

Definition at line 193 of file _configurableActionStructField.py.

193 def fieldNames(self) -> Iterable[str]:
194 return self._attrs.keys()
195

◆ history()

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

Definition at line 189 of file _configurableActionStructField.py.

189 def history(self) -> list[tuple]:
190 return self._history
191

◆ items()

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

Definition at line 244 of file _configurableActionStructField.py.

244 def items(self) -> Iterable[tuple[str, ActionTypeVar]]:
245 for name in self.fieldNames:
246 yield name, getattr(self, name)
247

Member Data Documentation

◆ _attrs

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

Definition at line 147 of file _configurableActionStructField.py.

◆ _config

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

Definition at line 204 of file _configurableActionStructField.py.

◆ _config_

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

Definition at line 146 of file _configurableActionStructField.py.

◆ _field

lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct._field = f"Cannot modify a frozen Config. Attempting to set item {attr} to value {value}"
protected

Definition at line 206 of file _configurableActionStructField.py.

◆ _history

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

Definition at line 149 of file _configurableActionStructField.py.

◆ fieldNames

lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct.fieldNames

Definition at line 241 of file _configurableActionStructField.py.

◆ history

lsst.pex.config.configurableActions._configurableActionStructField.ConfigurableActionStruct.history

Definition at line 177 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: