lenskit.config#

LensKit general configuration

Submodules#

common

Mixins with commonly-used component configuration capabilities.

Classes#

LenskitSettings

Definition of LensKit settings.

MachineSettings

Definition for a single machine.

ParallelSettings

Configuration for LensKit's parallel processing. These settings are in the

PowerQueries

Queries for requesting power consumption data from Prometheus.

PrometheusSettings

Prometheus configuration settings.

RandomSettings

Random number generator configuration.

TuneSettings

LensKit hyperparameter tuning settings.

Functions#

load_config_data(…)

General-purpose function to automatically load configuration data and

locate_configuration_root(*[, cwd, ...])

Search for a configuration root containing a lenskit.toml file.

lenskit_config()

Get the LensKit configuration.

configure(…)

Initialize LensKit configuration.

Package Contents#

lenskit.config.load_config_data(path: pathlib.Path | os.PathLike[str], model: None = None) pydantic.JsonValue#
lenskit.config.load_config_data(path: pathlib.Path | os.PathLike[str], model: type[M]) M

General-purpose function to automatically load configuration data and optionally validate with a model.

Parameters:
  • path – The path to the configuration file.

  • model – The Pydantic model class to validate.

lenskit.config.locate_configuration_root(*, cwd=None, abort_at_pyproject=True, abort_at_gitroot=True)#

Search for a configuration root containing a lenskit.toml file.

This searches for a lenskit.toml file, beginning in the current working directory (or the alternate cwd if provided), and searching upward until one is found. Search stops if a pyproject.toml file or .git directory is found without encountering lenskit.toml.

Parameters:
Return type:

pathlib.Path | None

lenskit.config.lenskit_config()#

Get the LensKit configuration.

If no configuration has been specified, returns a default settings object.

Return type:

_schema.LenskitSettings

lenskit.config.configure(cfg_dir: pathlib.Path | None = None) _schema.LenskitSettings#
lenskit.config.configure(cfg_dir: pathlib.Path | None = None, *, settings_cls: type[SettingsClass]) SettingsClass
lenskit.config.configure(settings: _schema.LenskitSettings, /) _schema.LenskitSettings

Initialize LensKit configuration.

LensKit does not automatically read configuration files — if this function is never called, then configuration will entirely be done through defaults and environment varibles.

This function will automatically configure the global RNG, if a seed is specified. It does not configure logging.

Parameters:
  • cfg_dir – The directory in which to look for configuration files.. If not provided, uses the current directory.

  • settings_cls – The base LensKit settings class. Rarely used, only needed if a project wants to to extend LensKit settings with their own settings.

Returns:

The configured LensKit settings.

Exported Aliases#

exception lenskit.config.ConfigWarning#

Re-exported alias for lenskit.diagnostics.ConfigWarning.

lenskit.config.get_logger()#

Re-exported alias for lenskit.logging.get_logger().

lenskit.config.init_global_rng()#

Re-exported alias for lenskit.random.init_global_rng().