Skip to content

Commit

Permalink
Fix failing tests for review
Browse files Browse the repository at this point in the history
  • Loading branch information
nv-kmcgill53 committed Nov 27, 2024
1 parent 5bc5b91 commit f6b3275
Showing 1 changed file with 31 additions and 38 deletions.
69 changes: 31 additions & 38 deletions qa/L0_backend_python/env/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ locale_test() {
set -e
}

# This is only run for the default installation of python version, 3.12.
extraction_test() {
## Test re-extraction of environment.
SERVER_ARGS="--model-repository=`pwd`/models --log-verbose=1 --model-control-mode=explicit"
Expand Down Expand Up @@ -131,6 +132,9 @@ extraction_test() {
}

aws_test() {
local EXPECTED_VERSION_STRING=$1
local MODEL_TYPE=$2 # Can be one of: python_3_6, python_3_12

# Test execution environments with S3
# S3 credentials are necessary for this test. Pass via ENV variables
aws configure set default.region $AWS_DEFAULT_REGION && \
Expand All @@ -151,10 +155,6 @@ aws_test() {
BUCKET_URL=${BUCKET_URL%/}
BUCKET_URL_SLASH="${BUCKET_URL}/"

# Remove Python 3.7 model because it contains absolute paths and cannot be used
# with S3.
rm -rf models/python_3_7

# Test with the bucket url as model repository
aws s3 cp models/ "${BUCKET_URL_SLASH}" --recursive --include "*"

Expand All @@ -172,10 +172,10 @@ aws_test() {
wait $SERVER_PID

set +e
grep "$PY36_VERSION_STRING" $SERVER_LOG
grep "$EXPECTED_VERSION_STRING" $SERVER_LOG
if [ $? -ne 0 ]; then
cat $SERVER_LOG
echo -e "\n***\n*** $PY36_VERSION_STRING was not found in Triton logs. \n***"
echo -e "\n***\n*** $EXPECTED_VERSION_STRING was not found in Triton logs. \n***"
RET=1
fi
set -e
Expand All @@ -184,11 +184,14 @@ aws_test() {
aws s3 rm "${BUCKET_URL_SLASH}" --recursive --include "*"

# Test with EXECUTION_ENV_PATH outside the model directory
sed -i "s/TRITON_MODEL_DIRECTORY\/python_3_6_environment/TRITON_MODEL_DIRECTORY\/..\/python_3_6_environment/" models/python_3_6/config.pbtxt
mv models/python_3_6/python_3_6_environment.tar.gz models
sed -i "s/\$\$TRITON_MODEL_DIRECTORY\/python_3_12_environment/s3:\/\/triton-bucket-${CI_JOB_ID}\/python_3_12_environment/" models/python_3_12/config.pbtxt
mv models/python_3_12/python_3_12_environment.tar.gz models

if [[ "$MODEL_TYPE" == "python_3_6" ]]; then
sed -i "s/TRITON_MODEL_DIRECTORY\/python_3_6_environment/TRITON_MODEL_DIRECTORY\/..\/python_3_6_environment/" models/python_3_6/config.pbtxt
mv models/python_3_6/python_3_6_environment.tar.gz models
elif [[ "$MODEL_TYPE" == "python_3_12" ]]; then
sed -i "s/\$\$TRITON_MODEL_DIRECTORY\/python_3_12_environment/s3:\/\/triton-bucket-${CI_JOB_ID}\/python_3_12_environment/" models/python_3_12/config.pbtxt
mv models/python_3_12/python_3_12_environment.tar.gz models
fi

aws s3 cp models/ "${BUCKET_URL_SLASH}" --recursive --include "*"

SERVER_ARGS="--model-repository=$BUCKET_URL_SLASH --log-verbose=1"
Expand All @@ -205,14 +208,12 @@ aws_test() {
wait $SERVER_PID

set +e
for EXPECTED_VERSION_STRING in "$PY36_VERSION_STRING" "$PY312_VERSION_STRING"; do
grep "$EXPECTED_VERSION_STRING" $SERVER_LOG
if [ $? -ne 0 ]; then
cat $SERVER_LOG
echo -e "\n***\n*** $EXPECTED_VERSION_STRING was not found in Triton logs. \n***"
RET=1
fi
done
grep "$EXPECTED_VERSION_STRING" $SERVER_LOG
if [ $? -ne 0 ]; then
cat $SERVER_LOG
echo -e "\n***\n*** $EXPECTED_VERSION_STRING was not found in Triton logs. \n***"
RET=1
fi
set -e

# Clean up bucket contents and delete bucket
Expand Down Expand Up @@ -240,6 +241,7 @@ PY37_VERSION_STRING="Python version is 3.7, NumPy version is 1.20.1, and Tensorf
create_python_backend_stub
conda-pack -o python3.7.tar.gz
path_to_conda_pack=`pwd`/python3.7.tar.gz
rm -r models/ || true
mkdir -p models/python_3_7/1/
cp ../../python_models/python_version/config.pbtxt ./models/python_3_7
(cd models/python_3_7 && \
Expand All @@ -252,12 +254,6 @@ conda deactivate
if [[ "${PROPERTIES}" =~ "locale" ]]; then
locale_test $PY37_VERSION_STRING
fi
if [[ "${PROPERTIES}" =~ "extraction" ]]; then
extraction_test
fi
if [[ "${PROPERTIES}" =~ "aws" ]]; then
aws_test
fi


# Use python-3-7 without conda pack
Expand All @@ -273,6 +269,7 @@ conda install -c conda-forge libstdcxx-ng=14 -y

PY37_1_VERSION_STRING="Python version is 3.7, NumPy version is 1.20.3, and Tensorflow version is 2.1.0"
create_python_backend_stub
rm -r models/ || true
mkdir -p models/python_3_7_1/1/
cp ../../python_models/python_version/config.pbtxt ./models/python_3_7_1
(cd models/python_3_7_1 && \
Expand All @@ -285,14 +282,11 @@ cp python_backend/builddir/triton_python_backend_stub ./models/python_3_7_1
conda deactivate

if [[ "${PROPERTIES}" =~ "locale" ]]; then
locale_test $PY37_1_VERSION_STRING
fi
if [[ "${PROPERTIES}" =~ "extraction" ]]; then
extraction_test
fi
if [[ "${PROPERTIES}" =~ "aws" ]]; then
aws_test
locale_test "$PY37_1_VERSION_STRING"
fi
# if [[ "${PROPERTIES}" =~ "aws" ]]; then
# aws_test "$PY37_1_VERSION_STRING" "python_3_7_1"
# fi

# Create a model with python 3.6 version
# Tensorflow 2.1.0 only works with Python 3.4 - 3.7. Successful execution of
Expand All @@ -307,6 +301,7 @@ conda-pack -o python3.6.tar.gz
# Test relative execution env path
path_to_conda_pack='$$TRITON_MODEL_DIRECTORY/python_3_6_environment.tar.gz'
create_python_backend_stub
rm -r models/ || true
mkdir -p models/python_3_6/1/
cp ../../python_models/python_version/config.pbtxt ./models/python_3_6
cp python3.6.tar.gz models/python_3_6/python_3_6_environment.tar.gz
Expand All @@ -320,11 +315,8 @@ conda deactivate
if [[ "${PROPERTIES}" =~ "locale" ]]; then
locale_test $PY36_VERSION_STRING
fi
if [[ "${PROPERTIES}" =~ "extraction" ]]; then
extraction_test
fi
if [[ "${PROPERTIES}" =~ "aws" ]]; then
aws_test
aws_test "$PY36_VERSION_STRING" "python_3_6"
fi

# Test conda env without custom Python backend stub This environment should
Expand All @@ -338,6 +330,7 @@ conda install numpy=1.26.4 -y
conda install tensorflow=2.16.2 -y
PY312_VERSION_STRING="Python version is 3.12, NumPy version is 1.26.4, and Tensorflow version is 2.16.2"
conda pack -o python3.12.tar.gz
rm -r models/ || true
mkdir -p models/python_3_12/1/
cp ../../python_models/python_version/config.pbtxt ./models/python_3_12
cp python3.12.tar.gz models/python_3_12/python_3_12_environment.tar.gz
Expand All @@ -352,10 +345,10 @@ if [[ "${PROPERTIES}" =~ "locale" ]]; then
locale_test $PY312_VERSION_STRING
fi
if [[ "${PROPERTIES}" =~ "extraction" ]]; then
extraction_test
extraction_test
fi
if [[ "${PROPERTIES}" =~ "aws" ]]; then
aws_test
aws_test "$PY312_VERSION_STRING" "python_3_12"
fi

if [ $RET -eq 0 ]; then
Expand Down

0 comments on commit f6b3275

Please sign in to comment.