barrel_rerank_venv (barrel_rerank v1.0.0)

View Source

Managed Python virtual environment for barrel_rerank

Creates and manages a Python venv with all dependencies required for the rerank server (transformers, torch, uvloop).

Usage

   %% Ensure venv exists and has dependencies
   {ok, VenvPath} = barrel_rerank_venv:ensure_venv().
  
   %% Check if venv is valid
   true = barrel_rerank_venv:is_valid().
  
   %% Check for uvloop support
   true = barrel_rerank_venv:has_uvloop().
  
   %% Force refresh (reinstall deps)
   ok = barrel_rerank_venv:refresh().

Configuration

The venv path can be configured via application env:

   {barrel_rerank, [{venv_path, "/custom/path/.venv"}]}

Default path is "priv/.venv" relative to the application.

Summary

Functions

Create a new Python venv.

Ensure venv exists with all dependencies. Creates venv and installs deps if needed.

Check if uvloop is installed.

Install all required dependencies.

Check if the venv is valid (exists with Python).

Force refresh - reinstall all dependencies.

Get the venv path (configured or default).

Functions

create_venv()

-spec create_venv() -> ok | {error, term()}.

Create a new Python venv.

ensure_venv()

-spec ensure_venv() -> {ok, string()} | {error, term()}.

Ensure venv exists with all dependencies. Creates venv and installs deps if needed.

has_uvloop()

-spec has_uvloop() -> boolean().

Check if uvloop is installed.

install_deps()

-spec install_deps() -> ok | {error, term()}.

Install all required dependencies.

is_valid()

-spec is_valid() -> boolean().

Check if the venv is valid (exists with Python).

refresh()

-spec refresh() -> ok | {error, term()}.

Force refresh - reinstall all dependencies.

venv_path()

-spec venv_path() -> string().

Get the venv path (configured or default).