poprox_recommender.paths#

Functions

model_file_path(name)

Get the path of a model file.

project_root()

Find the project root directory (when we are running in the project).

poprox_recommender.paths.project_root() Path#
poprox_recommender.paths.project_root(*, require: bool) Path | None

Find the project root directory (when we are running in the project).

This searches upwards from the current working directory to find the root of the project, which it identifies by the pyproject.toml file. If this function is called from a directory that is not within a checkout of the poprox-recommender repository, it will raise an error.

Parameters:

require – Whether to fail when the project root is not found, or return None. If require=False this function will stil fail on a defective project root (contains an invalid pyproject.toml).

Returns:

The full path to the project root directory. If the project root is not found and require=False, returns None.

poprox_recommender.paths.model_file_path(name)#

Get the path of a model file. It looks in the following locations, in order:

  • The path specified by the POPROX_MODELS environment variable.

  • The models directory under the project_root().

  • $CONDA_PREFIX/models (if env var CONDA_PREFIX is defined, which is done by conda activate).

Parameters:

name (str) – The path to the model file (or directory), relative to models.

Returns:

The full path to the model file, if it exists.

Return type:

Path