barrel_embed_venv (barrel_embed v2.3.0)

View Source

Managed virtualenv for barrel_embed

Automatically creates and manages a Python virtualenv with dependencies required by embedding providers.

Venv Location

Default: priv/barrel_embed/.venv Configurable via app env: {barrel_embed, [{venv_dir, "/custom/path"}]}

Provider Dependencies

- fastembed: fastembed (~100MB) - local: sentence-transformers (~2GB) - splade: transformers, torch - colbert: transformers, torch - clip: transformers, torch, pillow

Summary

Functions

Create the managed venv. Finds Python3 and creates venv at configured path.

Ensure venv exists and is valid. Creates if missing, returns path on success.

Check if uvloop is installed in the managed venv.

Install dependencies for a provider. Automatically installs required packages for the given provider.

Check if managed venv is valid.

Refresh the managed venv. Deletes and recreates the venv.

Get the managed venv path. Returns custom path from app env or default priv/.venv

Functions

create_venv()

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

Create the managed venv. Finds Python3 and creates venv at configured path.

ensure_venv()

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

Ensure venv exists and is valid. Creates if missing, returns path on success.

has_uvloop()

-spec has_uvloop() -> boolean().

Check if uvloop is installed in the managed venv.

install_deps(Provider)

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

Install dependencies for a provider. Automatically installs required packages for the given provider.

is_valid()

-spec is_valid() -> boolean().

Check if managed venv is valid.

refresh()

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

Refresh the managed venv. Deletes and recreates the venv.

venv_path()

-spec venv_path() -> string().

Get the managed venv path. Returns custom path from app env or default priv/.venv