Skip to content

Environments (mtb.env)

Install the environments the methods run in. dry_run=True shows each environment's state and download size. The environments are built for Linux and, for the methods that Windows and macOS list, for Windows and for macOS with Apple silicon. On an Intel Mac only the dry run works.

Name Summary
mtb.env.install Install the environments a set of methods needs, on Linux or Windows.
Details

A run activates the installed environment folder, <envs_dir>/<env>, directly, so no conda binary is needed. When no folder exists but conda is installed, it uses conda run -n <env> instead. MULTIBENCH_RUN_MODE=conda|prefix forces one mode, and prefix with no environment folder raises OSError naming envs_dir. envs_dir defaults to MULTIBENCH_ENVS_DIR when set. mtb.config lists the other defaults.

In prefix mode on Linux the command runs under bash -c after setting CONDA_PREFIX, putting <prefix>/bin first on PATH and sourcing <prefix>/etc/conda/activate.d/*.sh. On Windows the environment's own python.exe or Rscript.exe runs the script, with CONDA_PREFIX set and the environment's folders first on PATH.

GPU or CPU? describes the CPU and GPU builds.

mtb.env.install

install(
    methods: list[str] | None = None,
    *,
    category: str | None = None,
    dry_run: bool = False,
    flavor: str = "auto",
    build: bool = False,
)

Install the environments a set of methods needs, on Linux or Windows.

Each env is unpacked from its published archive, or built from its lockfile where none is published (on Windows nothing is built: a method without a published Windows archive is refused). Installed envs are skipped. Then the method scripts are downloaded to mtb.config.repo_path if they are missing.

PARAMETERS DESCRIPTION
methods

Method ids to cover; None = every method of category, or every method.

type list[str] | None default None

category

vertical, diagonal, mosaic or cross: the methods to cover when methods is None.

type str | None default None

dry_run

True = install nothing and return each env's state and size.

type bool default False

flavor

'cpu', 'gpu' or 'auto' ('gpu' when an NVIDIA GPU is visible): the archive build of each env. An env whose methods never use a GPU takes its CPU build whatever flavor is.

type str default 'auto'

build

True = build every env from its lockfile instead of unpacking the archive.

type bool default False

RETURNS DESCRIPTION
DataFrame

One row per env, the env serving the most methods first: env, methods, state ('have', 'packed archive published', 'name taken' ... on a dry run; 'PACKED', 'BUILD' after an install), flavor ('cpu', 'gpu', or 'any' for one archive for both), archive_bytes (the download) and unpacked_bytes (on disk).

RAISES DESCRIPTION
KeyError

Unknown method id.

OSError

A real install on a host that is neither Linux nor Windows; on Windows, a method without a Windows environment, build=True, or an archive that could not be downloaded.

RuntimeError

build=True without conda, a failed build, or a failed download of the method scripts.

Examples

>>> import multibench as mtb
>>> mtb.env.install(["Matilda", "totalVI"], dry_run=True)
>>> mtb.env.install(category="vertical")