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 shared between multiple threads. Note that DirectButler itself is not currently threadsafe, so this guarantee does not buy you much. See DM-42317.

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