LabeledButlerFactory¶
- class lsst.daf.butler.LabeledButlerFactory(repositories: Mapping[str, str] | None = None)¶
Bases:
object
Factory for efficiently instantiating Butler instances from the repository index file. This is intended for use from long-lived services that want to instantiate a separate Butler instance for each end user request.
- Parameters:
- repositories
Mapping
[str
,str
], optional Keys are arbitrary labels, and values are URIs to Butler configuration files. If not provided, defaults to the global repository index configured by the
DAF_BUTLER_REPOSITORY_INDEX
environment variable – seeButlerRepoIndex
.
- repositories
Notes
This interface is currently considered experimental and is subject to change.
For each label in the repository index, caches shared state to allow fast instantiation of new instances.
Instance methods on this class are threadsafe – a single instance of
LabeledButlerFactory
can be used concurrently by multiple threads. It is NOT safe for a singleButler
instance returned by this factory to be used concurrently by multiple threads. However, separateButler
instances can safely be used by separate threads.Methods Summary
bind
(access_token)Create a callable factory function for generating Butler instances with out needing to specify access tokans again.
create_butler
(*, label, access_token)Create a Butler instance.
Methods Documentation
- bind(access_token: str | None) LabeledButlerFactoryProtocol ¶
Create a callable factory function for generating Butler instances with out needing to specify access tokans again.
- Parameters:
- Returns:
- bound
LabeledButlerFactoryProtocol
A callable that takes a label as input and returns a Butler instance.
- bound
- create_butler(*, label: str, access_token: str | None) Butler ¶
Create a Butler instance.
- Parameters:
- label
str
Label of the repository to instantiate, from the
repositories
parameter to theLabeledButlerFactory
constructor or the global repository index file.- access_token
str
|None
Gafaelfawr access token used to authenticate to a Butler server. This is required for any repositories configured to use
RemoteButler
. If you only useDirectButler
, this may beNone
.
- label
- Raises:
- KeyError
Raised if the label is not found in the index.
Notes
For a service making requests on behalf of end users, the access token should normally be a “delegated” token so that access permissions are based on the end user instead of the service. See https://gafaelfawr.lsst.io/user-guide/gafaelfawringress.html#requesting-delegated-tokens