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:
repositoriesMapping [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 – see ButlerRepoIndex.

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 single Butler instance returned by this factory to be used concurrently by multiple threads. However, separate Butler instances can safely be used by separate threads.

Methods Summary

create_butler(*, label, access_token)

Create a Butler instance.

Methods Documentation

create_butler(*, label: str, access_token: str | None) Butler

Create a Butler instance.

Parameters:
labelstr

Label of the repository to instantiate, from the repositories parameter to the LabeledButlerFactory constructor or the global repository index file.

access_tokenstr | None

Gafaelfawr access token used to authenticate to a Butler server. This is required for any repositories configured to use RemoteButler. If you only use DirectButler, this may be None.

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