Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(venv): shared env #3195

Merged
merged 2 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 29 additions & 11 deletions backend/python/common/libbackend.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,23 @@
# source $(dirname $0)/../common/libbackend.sh
#
function init() {
# Name of the backend (directory name)
BACKEND_NAME=${PWD##*/}

# Path where all backends files are
MY_DIR=$(realpath `dirname $0`)

# Build type
BUILD_PROFILE=$(getBuildProfile)

# Environment directory
EDIR=${MY_DIR}

# Allow to specify a custom env dir for shared environments
if [ "x${ENV_DIR}" != "x" ]; then
EDIR=${ENV_DIR}
fi

# If a backend has defined a list of valid build profiles...
if [ ! -z "${LIMIT_TARGETS}" ]; then
isValidTarget=$(checkTargets ${LIMIT_TARGETS})
Expand Down Expand Up @@ -74,13 +87,14 @@ function getBuildProfile() {
# This function is idempotent, so you can call it as many times as you want and it will
# always result in an activated virtual environment
function ensureVenv() {
if [ ! -d "${MY_DIR}/venv" ]; then
uv venv ${MY_DIR}/venv
if [ ! -d "${EDIR}/venv" ]; then
uv venv ${EDIR}/venv
echo "virtualenv created"
fi

if [ "x${VIRTUAL_ENV}" != "x${MY_DIR}/venv" ]; then
source ${MY_DIR}/venv/bin/activate

# Source if we are not already in a Virtual env
if [ "x${VIRTUAL_ENV}" != "x${EDIR}/venv" ]; then
source ${EDIR}/venv/bin/activate
echo "virtualenv activated"
fi

Expand Down Expand Up @@ -113,21 +127,25 @@ function installRequirements() {

# These are the requirements files we will attempt to install, in order
declare -a requirementFiles=(
"${MY_DIR}/requirements-install.txt"
"${MY_DIR}/requirements.txt"
"${MY_DIR}/requirements-${BUILD_TYPE}.txt"
"${EDIR}/requirements-install.txt"
"${EDIR}/requirements.txt"
"${EDIR}/requirements-${BUILD_TYPE}.txt"
)

if [ "x${BUILD_TYPE}" != "x${BUILD_PROFILE}" ]; then
requirementFiles+=("${MY_DIR}/requirements-${BUILD_PROFILE}.txt")
requirementFiles+=("${EDIR}/requirements-${BUILD_PROFILE}.txt")
fi

# if BUILD_TYPE is empty, we are a CPU build, so we should try to install the CPU requirements
if [ "x${BUILD_TYPE}" == "x" ]; then
requirementFiles+=("${MY_DIR}/requirements-cpu.txt")
requirementFiles+=("${EDIR}/requirements-cpu.txt")
fi

requirementFiles+=("${MY_DIR}/requirements-after.txt")
requirementFiles+=("${EDIR}/requirements-after.txt")

if [ "x${BUILD_TYPE}" != "x${BUILD_PROFILE}" ]; then
requirementFiles+=("${EDIR}/requirements-${BUILD_PROFILE}-after.txt")
fi

for reqFile in ${requirementFiles[@]}; do
if [ -f ${reqFile} ]; then
Expand Down
1 change: 1 addition & 0 deletions backend/python/vllm/requirements-cublas11-after.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flash-attn
1 change: 1 addition & 0 deletions backend/python/vllm/requirements-cublas12-after.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flash-attn
Loading