mirror of
https://github.com/tencentmusic/supersonic.git
synced 2025-12-12 12:37:55 +00:00
[improvement](python) remove virtualenv in python shell (#395)
This commit is contained in:
@@ -82,39 +82,25 @@ function runJavaService {
|
|||||||
# run python service
|
# run python service
|
||||||
function runPythonService {
|
function runPythonService {
|
||||||
pythonRunDir=${runtimeDir}/supersonic-${model_name}/llmparser
|
pythonRunDir=${runtimeDir}/supersonic-${model_name}/llmparser
|
||||||
cd $pythonRunDir
|
cd $pythonRunDir
|
||||||
# check if venv is available
|
nohup ${python_path} supersonic_llmparser.py > $pythonRunDir/llmparser.log 2>&1 &
|
||||||
if ! ${python_path} -c "import venv" &> /dev/null; then
|
# add health check
|
||||||
echo "venv not found, installing virtualenv via pip..."
|
for i in {1..10}
|
||||||
pip install virtualenv
|
do
|
||||||
# create a virtual environment using virtualenv
|
echo "llmparser health check attempt $i..."
|
||||||
virtualenv venv
|
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
|
else
|
||||||
# create a virtual environment using venv
|
if [ "$i" -eq 10 ]; then
|
||||||
${python_path} -m venv venv
|
echo "llmparser Health check failed after 10 attempts."
|
||||||
fi
|
echo "May still downloading model files. Please check llmparser.log in runtime directory."
|
||||||
# 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
|
fi
|
||||||
done
|
echo "Retrying after 5 seconds..."
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user