LSST Applications 27.0.0,g0265f82a02+469cd937ee,g02d81e74bb+21ad69e7e1,g1470d8bcf6+cbe83ee85a,g2079a07aa2+e67c6346a6,g212a7c68fe+04a9158687,g2305ad1205+94392ce272,g295015adf3+81dd352a9d,g2bbee38e9b+469cd937ee,g337abbeb29+469cd937ee,g3939d97d7f+72a9f7b576,g487adcacf7+71499e7cba,g50ff169b8f+5929b3527e,g52b1c1532d+a6fc98d2e7,g591dd9f2cf+df404f777f,g5a732f18d5+be83d3ecdb,g64a986408d+21ad69e7e1,g858d7b2824+21ad69e7e1,g8a8a8dda67+a6fc98d2e7,g99cad8db69+f62e5b0af5,g9ddcbc5298+d4bad12328,ga1e77700b3+9c366c4306,ga8c6da7877+71e4819109,gb0e22166c9+25ba2f69a1,gb6a65358fc+469cd937ee,gbb8dafda3b+69d3c0e320,gc07e1c2157+a98bf949bb,gc120e1dc64+615ec43309,gc28159a63d+469cd937ee,gcf0d15dbbd+72a9f7b576,gdaeeff99f8+a38ce5ea23,ge6526c86ff+3a7c1ac5f1,ge79ae78c31+469cd937ee,gee10cc3b42+a6fc98d2e7,gf1cff7945b+21ad69e7e1,gfbcc870c63+9a11dc8c8f
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.