From d4374f7074d0ef2b955853285d4154e8529cfbb9 Mon Sep 17 00:00:00 2001 From: Scott Date: Tue, 14 Nov 2023 17:51:47 +0800 Subject: [PATCH] (fix):using virtual env and fix chromadb's version (#381) --- assembly/bin/supersonic-common.sh | 52 ++++++++++++++-------- chat/core/src/main/python/requirements.txt | 2 +- 2 files changed, 34 insertions(+), 20 deletions(-) diff --git a/assembly/bin/supersonic-common.sh b/assembly/bin/supersonic-common.sh index 456952fcc..810b47912 100755 --- a/assembly/bin/supersonic-common.sh +++ b/assembly/bin/supersonic-common.sh @@ -82,25 +82,39 @@ function runJavaService { # run python service function runPythonService { pythonRunDir=${runtimeDir}/supersonic-${model_name}/llmparser - cd $pythonRunDir - nohup ${python_path} supersonic_llmparser.py > $pythonRunDir/llmparser.log 2>&1 & - # add health check - for i in {1..10} - do - echo "llmparser health check attempt $i..." - response=$(curl -s http://${LLMPARSER_HOST}:${LLMPARSER_PORT}/health) - echo "llmparser health check response: $response" - status_ok="Healthy" - if [[ $response == *$status_ok* ]] ; then - echo "llmparser Health check passed." - break + cd $pythonRunDir + # check if venv is available + if ! ${python_path} -c "import venv" &> /dev/null; then + echo "venv not found, installing virtualenv via pip..." + pip install virtualenv + # create a virtual environment using virtualenv + virtualenv venv else - if [ "$i" -eq 10 ]; then - echo "llmparser Health check failed after 10 attempts." - echo "May still downloading model files. Please check llmparser.log in runtime directory." - fi - echo "Retrying after 5 seconds..." - sleep 5 + # create a virtual environment using venv + ${python_path} -m venv venv fi - done + # activate the virtual environment + source venv/bin/activate + # install dependencies + pip install --upgrade -r requirements.txt + nohup ${python_path} supersonic_llmparser.py > $pythonRunDir/llmparser.log 2>&1 & + # add health check + for i in {1..10} + do + echo "llmparser health check attempt $i..." + response=$(curl -s http://${LLMPARSER_HOST}:${LLMPARSER_PORT}/health) + echo "llmparser health check response: $response" + status_ok="Healthy" + if [[ $response == *$status_ok* ]] ; then + echo "llmparser Health check passed." + break + else + if [ "$i" -eq 10 ]; then + echo "llmparser Health check failed after 10 attempts." + echo "May still downloading model files. Please check llmparser.log in runtime directory." + fi + echo "Retrying after 5 seconds..." + sleep 5 + fi + done } diff --git a/chat/core/src/main/python/requirements.txt b/chat/core/src/main/python/requirements.txt index 5bedde364..72766887a 100644 --- a/chat/core/src/main/python/requirements.txt +++ b/chat/core/src/main/python/requirements.txt @@ -1,7 +1,7 @@ langchain==0.0.207 openai==0.27.4 fastapi==0.95.1 -chromadb==0.3.21 +chromadb==0.3.26 tiktoken==0.3.3 uvicorn[standard]==0.21.1 pandas==1.5.3