lsst.dax.apdb g5ea96fc03c+33ab2bc355
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
lsst.dax.apdb.apdbIndex.ApdbIndex Class Reference

Public Member Functions

 __init__ (self, str|None index_path=None)
 
ResourcePath get_apdb_uri (self, str label, str|None format=None)
 
Mapping[str, str] get_entries (self)
 

Static Public Attributes

ClassVar index_env_var = "DAX_APDB_INDEX_URI"
 

Protected Member Functions

Mapping[str, str] _read_index (self, str|None index_path=None)
 

Protected Attributes

 _index_path
 
 _cache
 

Static Protected Attributes

Mapping _cache = None
 

Detailed Description

Index of well-known Apdb instances.

Parameters
----------
index_path : `str`, optional
    Path to the index configuration file, if not provided then the value
    of ``DAX_APDB_INDEX_URI`` environment variable is used to locate
    configuration file.

The index is configured from a simple YAML file whose location is
determined from ``DAX_APDB_INDEX_URI`` environment variable. The content
of the index file is a mapping of the labels to URIs in YAML format, e.g.:

.. code-block:: yaml

   dev: "/path/to/config-file.yaml"
   "prod/pex_config": "s3://bucket/apdb-prod.py"
   "prod/yaml": "s3://bucket/apdb-prod.yaml"

The labels in the index file consists of the label name and an optional
format name separated from label by slash. `get_apdb_uri` method can
use its ``format`` argument to return either a format-specific
configuration or a label-only configuration if format-specific is not
defined.

Member Function Documentation

◆ _read_index()

Mapping[str, str] lsst.dax.apdb.apdbIndex.ApdbIndex._read_index ( self,
str | None index_path = None )
protected
Return contents of the index file.

Parameters
----------
index_path : `str`, optional
    Location of the index file, if not provided then default location
    is used.

Returns
-------
entries : `~collections.abc.Mapping` [`str`, `str`]
    All known entries. Can be empty if no index can be found.

Raises
------
RuntimeError
    Raised if ``index_path`` is not provided and environment variable
    is not set.
TypeError
    Raised if content of the configuration file is incorrect.

◆ get_apdb_uri()

ResourcePath lsst.dax.apdb.apdbIndex.ApdbIndex.get_apdb_uri ( self,
str label,
str | None format = None )
Return URI for APDB configuration file given its label.

Parameters
----------
label : `str`
    Label of APDB instance.
format : `str`
    Format of the APDB configuration file, arbitrary string. This can
    be used to support an expected migration from pex_config to YAML
    configuration for APDB, code that uses pex_config could provide
    "pex_config" for ``format``. The actual key in the index is
    either a slash-separated label and format, or, if that is missing,
    just a label.

Returns
-------
uri : `~lsst.resources.ResourcePath`
    URI for the configuration file for APDB instance.

Raises
------
FileNotFoundError
    Raised if an index is defined in the environment but it
    can not be found.
ValueError
    Raised if the label is not found in the index.
RuntimeError
    Raised if ``index_path`` is not provided and environment variable
    is not set.
TypeError
    Raised if the format of the index file is incorrect.

◆ get_entries()

Mapping[str, str] lsst.dax.apdb.apdbIndex.ApdbIndex.get_entries ( self)
Retrieve all entries defined in index.

Returns
-------
entries : `~collections.abc.Mapping` [`str`, `str`]
    All known index entries.

Raises
------
RuntimeError
    Raised if ``index_path`` is not provided and environment variable
    is not set.
TypeError
    Raised if content of the configuration file is incorrect.

The documentation for this class was generated from the following file: