install_utils#
Programmatic environment setup: install the medvision_ds dataset package, the vendored lmms-eval fork, CUDA toolkits and vLLM, and configure the Hugging Face / data-directory environment variables.
Installation and environment-setup helpers for the MedVision benchmark.
This module bundles the routines used to provision a runtime for the benchmark:
installing the vendored lmms-eval package and the medvision_ds dataset
codebase, and configuring the environment variables that point Hugging Face and
the MedVision dataset loader at a chosen data directory. It also provides
convenience installers for CUDA, PyTorch, Flash-Attention, and vLLM used when
setting up per-model conda environments.
- medvision_bm.utils.install_utils.install_vendored_lmms_eval(editable_install=True, proj_dependency=None)[source]#
Install the vendored
lmms-evalpackage that ships insidemedvision_bm.Locates the
medvision_lmms_evalpackage shipped as package data and installs it via the shared installer. Editable installation is used by default because the task definition files are otherwise not discovered.- Parameters:
editable_install (bool) – Install in editable (
pip install -e) mode. Defaults toTrue.proj_dependency (str, optional) – Name of an optional-dependency extra to install (rendered as
.[extra]). Defaults toNone.
- medvision_bm.utils.install_utils.setup_env_hf(data_dir)[source]#
Point Hugging Face’s cache and dataset cache at
data_dir.Sets
HF_HOMEandHF_DATASETS_CACHEto subdirectories ofdata_dirso that models and datasets are cached under the benchmark’s data directory.- Parameters:
data_dir (str) – Data directory; a relative path is resolved to an absolute path.
- medvision_bm.utils.install_utils.setup_env_medvision_ds(data_dir, force_install_code=True, force_download_data=False)[source]#
Set the environment variables that configure the
medvision_dsloader.Sets
MedVision_DATA_DIRtodata_dir(creating the directory if needed) and, when requested, the force-install and force-download flags read by the dataset codebase. The flags are only set when their argument isTrue; they are left unchanged otherwise.- Parameters:
data_dir (str) – Data directory; a relative path is resolved to an absolute path.
force_install_code (bool) – When
True, setMedVision_FORCE_INSTALL_CODE=trueto force reinstallation of the dataset codebase. Defaults toTrue.force_download_data (bool) – When
True, setMedVision_FORCE_DOWNLOAD_DATA=trueto force re-download of the data. Defaults toFalse.
- medvision_bm.utils.install_utils.setup_env_hf_medvision_ds(data_dir, force_install_code=True, force_download_data=False)[source]#
Configure both the
medvision_dsand Hugging Face environment variables.Calls
setup_env_medvision_dsfollowed bysetup_env_hffor the same data directory.- Parameters:
data_dir (str) – Data directory; a relative path is resolved to an absolute path.
force_install_code (bool) – Forwarded to
setup_env_medvision_ds. Defaults toTrue.force_download_data (bool) – Forwarded to
setup_env_medvision_ds. Defaults toFalse.
- medvision_bm.utils.install_utils.install_medvision_ds(data_dir, local_dir=None)[source]#
Build and install the
medvision_dsdataset codebase from source.When
local_dirisNone, downloads the dataset’ssrc/directory from theYongchengYAO/MedVisionHugging Face dataset repo intodata_dir; otherwise usessrc/underlocal_dir. A wheel is built from that source (guarded by aflockbuild lock, with a no-lock fallback) and installed with--force-reinstall. Finally, the Hugging Face andmedvision_dsenvironment variables are configured fordata_dir.- Parameters:
data_dir (str) – Data directory used for the snapshot download and for environment setup; a relative path is resolved to an absolute path.
local_dir (str, optional) – Directory containing an existing
src/tree to install from. When provided, no download is performed. Defaults toNone.