DiscoveryClient#

class rubin.repertoire.DiscoveryClient(http_client=None, *, base_url=None)#

Bases: object

Client for Phalanx service and dataset discovery.

Services that want to discover Phalanx services and datasets and that are not using the IVOA discovery protocols should use this client. Software running on a Science Pipelines stack container should instead use the client provided by lsst.rsp.

Discovery information is cached inside this client where appropriate. Callers should call the methods on this object each time discovery information is needed and not cache the results locally.

Normally, the environment variable REPERTOIRE_BASE_URL should be set by the Phalanx chart for the application and will be used to locate the base URL of the Repertoire discovery service in the local Phalanx environment.

Parameters:
  • http_client (AsyncClient | None, default: None) – Existing httpx.AsyncClient to use instead of creating a new one. This allows the caller to reuse an existing client and connection pool.

  • base_url (str | None, default: None) – Base URL of Repertoire, overriding the REPERTOIRE_BASE_URL environment variable. If this parameter is not provided and REPERTOIRE_BASE_URL is not set in the environment, RepertoireUrlError will be raised.

Methods Summary

aclose()

Close the HTTP client pool, if one wasn't provided.

applications()

List applications installed in the local Phalanx environment.

build_nublado_dict()

Generate discovery data for Nublado containers.

butler_config_for(dataset)

Return the Butler configuration URL for a given dataset.

butler_repositories()

Return the Butler repository mapping for the local environment.

datasets()

List datasets available in the local Phalanx environment.

influxdb_connection_info(database)

Get connection information for an InfluxDB database.

influxdb_credentials(database, token)

Get credentials for an InfluxDB database.

influxdb_databases()

List InfluxDB databases available in the local Phalanx environment.

url_for_data(service, dataset, *[, version])

Return the base API URL for a given data service.

url_for_internal(service, *[, version])

Return the base API URL for a given internal service.

url_for_ui(service)

Return the base URL for a given UI service.

versions_for_data(service, dataset)

Return the available API versions for a data service.

versions_for_internal(service)

Return the available API versions for an internal service.

Methods Documentation

async aclose()#

Close the HTTP client pool, if one wasn’t provided.

This object must not be used after calling this method.

Return type:

None

async applications()#

List applications installed in the local Phalanx environment.

Returns:

Phalanx application names expected to be deployed in the local environment. This is based on Phalanx configuration as injected into the Repertoire service, not based on what is currently deployed, so some applications may be missing if the environment is out of sync with the configuration.

Return type:

list of str

Raises:

RepertoireError – Raised on error fetching discovery information from Repertoire.

async build_nublado_dict()#

Generate discovery data for Nublado containers.

User science payloads using a Nublado container consume a pre-generated JSON dump of a restricted and hopefully stable subset of service discovery to allow support of possibly years-old code from older container versions. This method generates a dict containing that stripped-down data set, suitable for subsequent JSON encoding.

Returns:

Restricted subset of discovery information, suitable for JSON encoding.

Return type:

dict of dict

async butler_config_for(dataset)#

Return the Butler configuration URL for a given dataset.

Parameters:

dataset (str) – Short name of a dataset, chosen from the results of datasets.

Returns:

URL to the Butler configuration, or None if that dataset is not recognized or does not have a Butler configuration.

Return type:

str or None

Raises:

RepertoireError – Raised on error fetching discovery information from Repertoire.

async butler_repositories()#

Return the Butler repository mapping for the local environment.

Returns:

Mapping of dataset labels to Butler configuration URLs. This result is suitable for use as the constructor argument to lsst.daf.butler.LabeledButlerFactory.

Return type:

dict of str

Raises:

RepertoireError – Raised on error fetching discovery information from Repertoire.

async datasets()#

List datasets available in the local Phalanx environment.

Returns:

Short identifiers (dp1, for example) of the datasets expected to be available in the local Phalanx environment. These are the valid dataset arguments to butler_config_for and url_for_data.

Return type:

list of str

Raises:

RepertoireError – Raised on error fetching discovery information from Repertoire.

async influxdb_connection_info(database)#

Get connection information for an InfluxDB database.

This does not include authentication credentials. Authenticated clients can call influxdb_credentials instead to get full connection information.

Parameters:

database (str) – Short name of the InfluxDB database. Call influxdb_databases to get the valid values.

Returns:

Connection information for an InfluxDB database, or None if this database was not found in this environment.

Return type:

InfluxDatabase or None

Raises:

RepertoireError – Raised on error fetching discovery information from Repertoire.

async influxdb_credentials(database, token)#

Get credentials for an InfluxDB database.

Parameters:
  • database (str) – Short name of the InfluxDB database. Call influxdb_databases to get the valid values.

  • token (str) – Gafaelfawr token to use for authentication. Database information may only be available to users with specific scopes.

Returns:

Connection information for an InfluxDB database, including credentials, or None if this database was not found in this environment.

Return type:

InfluxDatabaseWithCredentials or None

Raises:

RepertoireError – Raised on error fetching discovery information from Repertoire.

async influxdb_databases()#

List InfluxDB databases available in the local Phalanx environment.

These may or may not be locally hosted, but the credentials and connection information is available to authenticated users.

Returns:

Short identifiers (summit_efd, for example) of the available InfluxDB databases. This string should be passed as the database argument to influxdb_connection_info.

Return type:

list of str

Raises:

RepertoireError – Raised on error fetching discovery information from Repertoire.

async url_for_data(service, dataset, *, version=None)#

Return the base API URL for a given data service.

Parameters:
  • service (str) – Name of the service.

  • dataset (str) – Dataset that will be queried via the API, chosen from the results of datasets.

  • version (str | None, default: None) – If given, return the URL for a specific version of the API instead.

Returns:

Base URL of the API, or None if the service, dataset, or version is not available in this environment.

Return type:

str or None

Raises:

RepertoireError – Raised on error fetching discovery information from Repertoire.

async url_for_internal(service, *, version=None)#

Return the base API URL for a given internal service.

Parameters:
  • service (str) – Name of the service.

  • version (str | None, default: None) – If given, return the URL for a specific version of the API instead.

Returns:

Base URL of the API, or None if the service or version is not available in this environment.

Return type:

str or None

Raises:

RepertoireError – Raised on error fetching discovery information from Repertoire.

async url_for_ui(service)#

Return the base URL for a given UI service.

Parameters:

service (str) – Name of the service.

Returns:

Base URL of the service, or None if the service is not available in this environment.

Return type:

str or None

Raises:

RepertoireError – Raised on error fetching discovery information from Repertoire.

async versions_for_data(service, dataset)#

Return the available API versions for a data service.

Parameters:
  • service (str) – Name of the service.

  • dataset (str) – Dataset that will be queried via the API, chosen from the results of datasets.

Returns:

List of versions. If the API is not versioned, this list will be empty. If the service or dataset is not available in this environment, returns None.

Return type:

list of str or None

async versions_for_internal(service)#

Return the available API versions for an internal service.

Parameters:

service (str) – Name of the service.

Returns:

List of versions. If the API is not versioned, this list will be empty. If the service is not available in this environment, returns None.

Return type:

list of str or None