Public Member Functions | |
| validateTarget (self, target, ConfigClass) | |
| __init__ (self, doc, target, ConfigClass=None, default=None, check=None, deprecated=None) | |
| ConfigurableField | __get__ (self, None instance, Any owner=None, Any at=None, str label="default") |
| ConfigurableInstance[FieldTypeVar] | __get__ (self, Config instance, Any owner=None, Any at=None, str label="default") |
| __get__ (self, instance, owner=None, at=None, label="default") | |
| __set__ (self, instance, value, at=None, label="assignment") | |
| rename (self, instance) | |
| save (self, outfile, instance) | |
| freeze (self, instance) | |
| toDict (self, instance) | |
| validate (self, instance) | |
| __deepcopy__ (self, memo) | |
Public Member Functions inherited from lsst.pex.config.config.Field | |
| __class_getitem__ (cls, tuple[type,...]|type|ForwardRef params) | |
| __init__ (self, doc, dtype=None, default=None, check=None, optional=False, deprecated=None) | |
| Field[FieldTypeVar] | __get__ (self, None instance, Any owner=None, Any at=None, str label="default") |
| FieldTypeVar | __get__ (self, Config instance, Any owner=None, Any at=None, str label="default") |
| __get__ (self, instance, owner=None, at=None, label="default") | |
| None | __set__ (self, Config instance, FieldTypeVar|None value, Any at=None, str label="assignment") |
| __delete__ (self, instance, at=None, label="deletion") | |
Public Member Functions inherited from lsst.pex.config.configurableField.ConfigurableInstance | |
| __init__ (self, config, field, at=None, label="default") | |
| apply (self, *args, **kw) | |
| retarget (self, target, ConfigClass=None, at=None, label="retarget") | |
| __getattr__ (self, name) | |
| __setattr__ (self, name, value, at=None, label="assignment") | |
| __delattr__ (self, name, at=None, label="delete") | |
| __reduce__ (self) | |
Protected Member Functions | |
| _collectImports (self, instance, imports) | |
| ConfigurableInstance|None | _copy_storage (self, Config old, Config new) |
| _compare (self, instance1, instance2, shortcut, rtol, atol, output) | |
Protected Member Functions inherited from lsst.pex.config.config.Field | |
| _setup (self, doc, dtype, default, check, optional, source, deprecated) | |
| _validateValue (self, value) | |
Protected Member Functions inherited from lsst.pex.config.configurableField.ConfigurableInstance | |
| ConfigurableInstance | _copy (self, Config parent) |
| Config | _config (self) |
Static Protected Member Functions | |
| Mapping[str, Any] | _parseTypingArgs (tuple[type,...]|tuple[str,...] params, Mapping[str, Any] kwds) |
Additional Inherited Members | |
Public Attributes inherited from lsst.pex.config.config.Field | |
| dtype = dtype | |
| doc = doc | |
| deprecated = deprecated | |
| default = default | |
| check = check | |
| optional = optional | |
| source = source | |
Static Public Attributes inherited from lsst.pex.config.config.Field | |
| dict | supportedTypes = {str, bool, float, int, complex} |
Protected Attributes inherited from lsst.pex.config.configurableField.ConfigurableInstance | |
| _field = self._field.validateTarget(target, ConfigClass) | |
| _target | |
| _ConfigClass | |
| _config | |
| _value | |
Properties inherited from lsst.pex.config.configurableField.ConfigurableInstance | |
| target = property(lambda x: x._target) | |
| ConfigClass = property(lambda x: x._ConfigClass) | |
| value = property(lambda x: x._value) | |
A configuration field (`~lsst.pex.config.Field` subclass) that can be
can be retargeted towards a different configurable (often a
`lsst.pipe.base.Task` subclass).
The ``ConfigurableField`` is often used to configure subtasks, which are
tasks (`~lsst.pipe.base.Task`) called by a parent task.
Parameters
----------
doc : `str`
A description of the configuration field.
target : `lsst.pipe.base.Task` or other configurable class
The configurable target. Configurables have a ``ConfigClass``
attribute. Within the task framework, configurables are
`lsst.pipe.base.Task` subclasses).
ConfigClass : `lsst.pex.config.Config`-type, optional
The subclass of `lsst.pex.config.Config` expected as the configuration
class of the ``target``. If ``ConfigClass`` is unset then
``target.ConfigClass`` is used.
default : `type`, optional
The default configuration class. Normally this parameter is not set,
and defaults to ``ConfigClass`` (or ``target.ConfigClass``).
check : `collections.abc.Callable`, optional
Callable that takes the field's value (the ``target``) as its only
positional argument, and returns `True` if the ``target`` is valid (and
`False` otherwise).
deprecated : `None` or `str`, optional
A description of why this Field is deprecated, including removal date.
If not `None`, the string is appended to the docstring for this Field.
See Also
--------
ChoiceField
ConfigChoiceField
ConfigDictField
ConfigField
DictField
Field
ListField
RangeField
RegistryField
Notes
-----
You can use the `ConfigurableInstance.apply` method to construct a
fully-configured configurable.
| lsst.pex.config.configurableField.ConfigurableField.__deepcopy__ | ( | self, | |
| memo ) |
Customize deep-copying, because we always want a reference to the original typemap. WARNING: this must be overridden by subclasses if they change the constructor signature!
|
protected |
Call the _collectImports method on all config
objects the field may own, and union them with the supplied imports
set.
Parameters
----------
instance : instance or subclass of `lsst.pex.config.Config`
A config object that has this field defined on it
imports : `set`
Set of python modules that need imported after persistence
Reimplemented from lsst.pex.config.config.Field.
|
protected |
Compare two fields for equality.
Used by `lsst.pex.ConfigDictField.compare`.
Parameters
----------
instance1 : `lsst.pex.config.Config`
Left-hand side config instance to compare.
instance2 : `lsst.pex.config.Config`
Right-hand side config instance to compare.
shortcut : `bool`
If `True`, this function returns as soon as an inequality if found.
rtol : `float`
Relative tolerance for floating point comparisons.
atol : `float`
Absolute tolerance for floating point comparisons.
output : `collections.abc.Callable`
A callable that takes a string, used (possibly repeatedly) to
report inequalities. For example: `print`.
Returns
-------
isEqual : bool
`True` if the fields are equal, `False` otherwise.
Notes
-----
Floating point comparisons are performed by `numpy.allclose`.
Reimplemented from lsst.pex.config.config.Field.
|
protected |
Copy the storage for this field in the given field into an object suitable for storage in a new copy of that config. Any frozen storage should be unfrozen.
Reimplemented from lsst.pex.config.config.Field.
|
staticprotected |
Parse type annotations into keyword constructor arguments.
This is a special private method that interprets type arguments (i.e.
Field[str]) into keyword arguments to be passed on to the constructor.
Subclasses of Field can implement this method to customize how they
handle turning type parameters into keyword arguments (see DictField
for an example)
Parameters
----------
params : `tuple` of `type` or `tuple` of str
Parameters passed to the type annotation. These will either be
types or strings. Strings are to interpreted as forward references
and will be treated as such.
kwds : `MutableMapping` with keys of `str` and values of `Any`
These are the user supplied keywords that are to be passed to the
Field constructor.
Returns
-------
kwds : `MutableMapping` with keys of `str` and values of `Any`
The mapping of keywords that will be passed onto the constructor
of the Field. Should be filled in with any information gleaned
from the input parameters.
Raises
------
ValueError
Raised if params is of incorrect length.
Raised if a forward reference could not be resolved
Raised if there is a conflict between params and values in kwds
Reimplemented from lsst.pex.config.config.Field.
| lsst.pex.config.configurableField.ConfigurableField.freeze | ( | self, | |
| instance ) |
Make this field read-only (for internal use only).
Parameters
----------
instance : `lsst.pex.config.Config`
The config instance that contains this field.
Notes
-----
Freezing is only relevant for fields that hold subconfigs. Fields which
hold subconfigs should freeze each subconfig.
**Subclasses should implement this method.**
Reimplemented from lsst.pex.config.config.Field.
| lsst.pex.config.configurableField.ConfigurableField.rename | ( | self, | |
| instance ) |
Rename the field in a `~lsst.pex.config.Config` (for internal use
only).
Parameters
----------
instance : `lsst.pex.config.Config`
The config instance that contains this field.
Notes
-----
This method is invoked by the `lsst.pex.config.Config` object that
contains this field and should not be called directly.
Renaming is only relevant for `~lsst.pex.config.Field` instances that
hold subconfigs. `~lsst.pex.config.Field`\s that hold subconfigs should
rename each subconfig with the full field name as generated by
`lsst.pex.config.config._joinNamePath`.
Reimplemented from lsst.pex.config.config.Field.
| lsst.pex.config.configurableField.ConfigurableField.save | ( | self, | |
| outfile, | |||
| instance ) |
Save this field to a file (for internal use only).
Parameters
----------
outfile : `typing.IO`
A writeable file handle.
instance : `~lsst.pex.config.Config`
The `~lsst.pex.config.Config` instance that contains this field.
Notes
-----
This method is invoked by the `~lsst.pex.config.Config` object that
contains this field and should not be called directly.
The output consists of the documentation string
(`lsst.pex.config.Field.doc`) formatted as a Python comment. The second
line is formatted as an assignment: ``{fullname}={value}``.
This output can be executed with Python.
Reimplemented from lsst.pex.config.config.Field.
| lsst.pex.config.configurableField.ConfigurableField.toDict | ( | self, | |
| instance ) |
Convert the field value so that it can be set as the value of an
item in a `dict` (for internal use only).
Parameters
----------
instance : `~lsst.pex.config.Config`
The `~lsst.pex.config.Config` that contains this field.
Returns
-------
value : `object`
The field's value. See *Notes*.
Notes
-----
This method invoked by the owning `~lsst.pex.config.Config` object and
should not be called directly.
Simple values are passed through. Complex data structures must be
manipulated. For example, a `~lsst.pex.config.Field` holding a
subconfig should, instead of the subconfig object, return a `dict`
where the keys are the field names in the subconfig, and the values are
the field values in the subconfig.
Reimplemented from lsst.pex.config.config.Field.
| lsst.pex.config.configurableField.ConfigurableField.validate | ( | self, | |
| instance ) |
Validate the field (for internal use only).
Parameters
----------
instance : `lsst.pex.config.Config`
The config instance that contains this field.
Raises
------
lsst.pex.config.FieldValidationError
Raised if verification fails.
Notes
-----
This method provides basic validation:
- Ensures that the value is not `None` if the field is not optional.
- Ensures type correctness.
- Ensures that the user-provided ``check`` function is valid.
Most `~lsst.pex.config.Field` subclasses should call
`lsst.pex.config.Field.validate` if they re-implement
`~lsst.pex.config.Field.validate`.
Reimplemented from lsst.pex.config.config.Field.
| lsst.pex.config.configurableField.ConfigurableField.validateTarget | ( | self, | |
| target, | |||
| ConfigClass ) |
Validate the target and configuration class.
Parameters
----------
target : `type`
The configurable being verified.
ConfigClass : `lsst.pex.config.Config`-type or `None`
The configuration class associated with the ``target``. This can
be `None` if ``target`` has a ``ConfigClass`` attribute.
Raises
------
AttributeError
Raised if ``ConfigClass`` is `None` and ``target`` does not have a
``ConfigClass`` attribute.
TypeError
Raised if ``ConfigClass`` is not a `~lsst.pex.config.Config`
subclass.
ValueError
Raised if:
- ``target`` is not callable (callables have a ``__call__``
method).
- ``target`` is not startically defined (does not have
``__module__`` or ``__name__`` attributes).