LSST Applications g0265f82a02+d6b5cd48b5,g02d81e74bb+a41d3748ce,g1470d8bcf6+6be6c9203b,g2079a07aa2+14824f138e,g212a7c68fe+a4f2ea4efa,g2305ad1205+72971fe858,g295015adf3+ab2c85acae,g2bbee38e9b+d6b5cd48b5,g337abbeb29+d6b5cd48b5,g3ddfee87b4+31b3a28dff,g487adcacf7+082e807817,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+b2918d57ae,g5a732f18d5+66d966b544,g64a986408d+a41d3748ce,g858d7b2824+a41d3748ce,g8a8a8dda67+a6fc98d2e7,g99cad8db69+7fe4acdf18,g9ddcbc5298+d4bad12328,ga1e77700b3+246acaaf9c,ga8c6da7877+84af8b3ff8,gb0e22166c9+3863383f4c,gb6a65358fc+d6b5cd48b5,gba4ed39666+9664299f35,gbb8dafda3b+d8d527deb2,gc07e1c2157+b2dbe6b631,gc120e1dc64+61440b2abb,gc28159a63d+d6b5cd48b5,gcf0d15dbbd+31b3a28dff,gdaeeff99f8+a38ce5ea23,ge6526c86ff+39927bb362,ge79ae78c31+d6b5cd48b5,gee10cc3b42+a6fc98d2e7,gf1cff7945b+a41d3748ce,v24.1.5.rc1
LSST Data Management Base Package
|
Public Member Functions | |
__init__ (self, configBaseType=Config) | |
register (self, name, target, ConfigClass=None) | |
__getitem__ (self, key) | |
__len__ (self) | |
__iter__ (self) | |
__contains__ (self, key) | |
makeField (self, doc, default=None, optional=False, multi=False, on_none=None) | |
Protected Attributes | |
_configBaseType | |
_dict | |
A base class for global registries, which map names to configurables. A registry acts like a read-only dictionary with an additional `register` method to add targets. Targets in the registry are configurables (see *Notes*). Parameters ---------- configBaseType : `lsst.pex.config.Config`-type The base class for config classes in the registry. Notes ----- A configurable is a callable with call signature ``(config, *args)`` Configurables typically create an algorithm or are themselves the algorithm. Often configurables are `lsst.pipe.base.Task` subclasses, but this is not required. A ``Registry`` has these requirements: - All configurables added to a particular registry have the same call signature. - All configurables in a registry typically share something important in common. For example, all configurables in ``psfMatchingRegistry`` return a PSF matching class that has a ``psfMatch`` method with a particular call signature. Examples -------- This examples creates a configurable class ``Foo`` and adds it to a registry. First, creating the configurable: >>> from lsst.pex.config import Registry, Config >>> class FooConfig(Config): ... val = Field(dtype=int, default=3, doc="parameter for Foo") ... >>> class Foo: ... ConfigClass = FooConfig ... def __init__(self, config): ... self.config = config ... def addVal(self, num): ... return self.config.val + num ... Next, create a ``Registry`` instance called ``registry`` and register the ``Foo`` configurable under the ``"foo"`` key: >>> registry = Registry() >>> registry.register("foo", Foo) >>> print(list(registry.keys())) ["foo"] Now ``Foo`` is conveniently accessible from the registry itself. Finally, use the registry to get the configurable class and create an instance of it: >>> FooConfigurable = registry["foo"] >>> foo = FooConfigurable(FooConfigurable.ConfigClass()) >>> foo.addVal(5) 8
Definition at line 59 of file registry.py.
lsst.pex.config.registry.Registry.__init__ | ( | self, | |
configBaseType = Config ) |
Definition at line 123 of file registry.py.
lsst.pex.config.registry.Registry.__contains__ | ( | self, | |
key ) |
Definition at line 186 of file registry.py.
lsst.pex.config.registry.Registry.__getitem__ | ( | self, | |
key ) |
Definition at line 177 of file registry.py.
lsst.pex.config.registry.Registry.__iter__ | ( | self | ) |
Definition at line 183 of file registry.py.
lsst.pex.config.registry.Registry.__len__ | ( | self | ) |
Definition at line 180 of file registry.py.
lsst.pex.config.registry.Registry.makeField | ( | self, | |
doc, | |||
default = None, | |||
optional = False, | |||
multi = False, | |||
on_none = None ) |
Create a `RegistryField` configuration field from this registry. Parameters ---------- doc : `str` A description of the field. default : object, optional The default target for the field. optional : `bool`, optional When `False`, `lsst.pex.config.Config.validate` fails if the field's value is `None`. multi : `bool`, optional A flag to allow multiple selections in the `RegistryField` if `True`. on_none : `Callable`, optional A callable that should be invoked when ``apply`` is called but the selected name or names is `None`. Will be passed the field attribute proxy (`RegistryInstanceDict`) and then all positional and keyword arguments passed to ``apply``. Returns ------- field : `lsst.pex.config.RegistryField` `~lsst.pex.config.RegistryField` Configuration field.
Reimplemented in lsst.meas.base.pluginRegistry.PluginRegistry.
Definition at line 189 of file registry.py.
lsst.pex.config.registry.Registry.register | ( | self, | |
name, | |||
target, | |||
ConfigClass = None ) |
Add a new configurable target to the registry. Parameters ---------- name : `str` Name that the ``target`` is registered under. The target can be accessed later with `dict`-like patterns using ``name`` as the key. target : obj A configurable type, usually a subclass of `lsst.pipe.base.Task`. ConfigClass : `lsst.pex.config.Config`-type, optional A subclass of `lsst.pex.config.Config` used to configure the configurable. If `None` then the configurable's ``ConfigClass`` attribute is used. Raises ------ RuntimeError Raised if an item with ``name`` is already in the registry. AttributeError Raised if ``ConfigClass`` is `None` and ``target`` does not have a ``ConfigClass`` attribute. Notes ----- If ``ConfigClass`` is provided then the ``target`` configurable is wrapped in a new object that forwards function calls to it. Otherwise the original ``target`` is stored.
Reimplemented in lsst.meas.base.pluginRegistry.PluginRegistry.
Definition at line 134 of file registry.py.
|
protected |
Definition at line 131 of file registry.py.
|
protected |
Definition at line 132 of file registry.py.