feat: migrate parler to uv

Signed-off-by: Chris Jowett <421501+cryptk@users.noreply.github.com>
This commit is contained in:
Chris Jowett 2024-05-03 12:54:26 -05:00
parent 72bdc71c52
commit 0409832944
No known key found for this signature in database
GPG Key ID: 6E4AA27F6EAB6E2B
5 changed files with 33 additions and 44 deletions

View File

@ -36,4 +36,8 @@ protogen-clean:
$(RM) backend_pb2_grpc.py backend_pb2.py
backend_pb2_grpc.py backend_pb2.py:
python3 -m grpc_tools.protoc -I../.. --python_out=. --grpc_python_out=. backend.proto
python3 -m grpc_tools.protoc -I../.. --python_out=. --grpc_python_out=. backend.proto
.PHONY: clean
clean: protogen-clean
$(RM) -r venv

View File

@ -1,39 +1,26 @@
#!/bin/bash
set -ex
SKIP_CONDA=${SKIP_CONDA:-0}
MY_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
# Check if environment exist
conda_env_exists(){
! conda list --name "${@}" >/dev/null 2>/dev/null
}
python -m venv ${MY_DIR}/venv
source ${MY_DIR}/venv/bin/activate
if [ $SKIP_CONDA -eq 1 ]; then
echo "Skipping conda environment installation"
else
export PATH=$PATH:/opt/conda/bin
if conda_env_exists "parler" ; then
echo "Creating virtual environment..."
conda env create --name parler --file $1
echo "Virtual environment created."
else
echo "Virtual environment already exists."
fi
uv pip install --requirement ${MY_DIR}/requirements.txt
if [ -f "requirements-${BUILD_TYPE}.txt" ]; then
uv pip install --requirement ${MY_DIR}/requirements-${BUILD_TYPE}.txt
fi
if [ $SKIP_CONDA -ne 1 ]; then
# Activate conda environment
source activate parler
# https://github.com/descriptinc/audiotools/issues/101
# incompatible protobuf versions.
curl -L https://raw.githubusercontent.com/protocolbuffers/protobuf/main/python/google/protobuf/internal/builder.py -o $CONDA_PREFIX/lib/python3.11/site-packages/google/protobuf/internal/builder.py
# https://github.com/descriptinc/audiotools/issues/101
# incompatible protobuf versions.
curl -L https://raw.githubusercontent.com/protocolbuffers/protobuf/main/python/google/protobuf/internal/builder.py -o $MY_DIR/venv/lib/python3.11/site-packages/google/protobuf/internal/builder.py
if [ -d "/opt/intel" ]; then
# Intel GPU: If the directory exists, we assume we are using the Intel image
# https://github.com/intel/intel-extension-for-pytorch/issues/538
uv pip install --index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/ --requirement ${MY_DIR}/requirements-intel.txt
fi
if [ "$PIP_CACHE_PURGE" = true ] ; then
if [ $SKIP_CONDA -ne 1 ]; then
# Activate conda environment
source activate parler
fi
pip cache purge
fi

View File

@ -0,0 +1,5 @@
accelerate
grpcio==1.63.0
protobuf
torch
git+https://github.com/huggingface/parler-tts.git@10016fb0300c0dc31a0fb70e26f3affee7b62f16

14
backend/python/parler-tts/run.sh Normal file → Executable file
View File

@ -1,16 +1,10 @@
#!/bin/bash
##
## A bash script wrapper that runs the parler-tts server with conda
## A bash script wrapper that runs the GRPC backend
echo "Launching gRPC server for parler-tts"
MY_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
export PATH=$PATH:/opt/conda/bin
source $MY_DIR/venv/bin/activate
# Activate conda environment
source activate parler
# get the directory where the bash script is located
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
python $DIR/parler_tts_server.py $@
python $MY_DIR/parler_tts_server.py $@

View File

@ -1,11 +1,10 @@
#!/bin/bash
##
## A bash script wrapper that runs the transformers server with conda
## A bash script wrapper that sets up and runs the tests
# Activate conda environment
source activate parler
MY_DIR="$(dirname -- "${BASH_SOURCE[0]}")"
# get the directory where the bash script is located
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
source $MY_DIR/venv/bin/activate
python -m unittest $DIR/test_parler.py
python -m unittest $MY_DIR/test_parler.py