daq_config_server#

Top level API.

daq_config_server.__version__: str#

Version number as calculated by pypa/setuptools_scm

Members

ConfigClient

Client to communicate with a deployed config service with a configurable cache and logger

class daq_config_server.ConfigClient(url: str = 'https://daq-config.diamond.ac.uk', log: Logger | None = None, cache_size: int = 10, cache_lifetime_s: int = 3600)[source]#

Client to communicate with a deployed config service with a configurable cache and logger

Parameters:
  • url – Base URL of the config server. Defaults to central service.

  • log – Optional logger instance.

  • cache_size – Size of the cache (maximum number of items can be stored).

  • cache_lifetime_s – Lifetime of the cache (in seconds).

get_file_contents(file_path: str | ~pathlib.Path, desired_return_type: type[~typing.Any] = <class 'str'>, reset_cached_result: bool = False, force_parser: ~collections.abc.Callable[[str], ~typing.Any] | None = None) Any[source]#

Get contents of a file from the config server in the format specified. Optionally look for cached result before making request.

Current supported return types are: str, bytes, dict. This option will determine how the server attempts to decode the file. Note that only untyped dictionaries are currently supported

Parameters:
  • file_path – Path to the file.

  • desired_return_type – Specify how to parse the response.

  • reset_cached_result – If true, make a request and store response in cache, otherwise look for cached response before making new request

  • force_parser – Optionally provide a function to convert the contents of a config file to the desired return type. This overides whatever converter is specified for that file in the FILE_TO_CONVERTER_MAP, and can be used if the config file isn’t in the FILE_TO_CONVERTER_MAP at all. This should only be used for testing or when waiting on a release that will add the file to the FILE_TO_CONVERTER_MAP.

Returns:

The file contents, in the format specified.