Skip to content

Commit

Permalink
Adding tests ensuring locale setting is passed to python backend inte…
Browse files Browse the repository at this point in the history
…rpreter
  • Loading branch information
nnshah1 committed Jun 26, 2023
1 parent 8e6628f commit 01b3b5d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
36 changes: 36 additions & 0 deletions qa/L0_backend_python/env/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,42 @@ for EXPECTED_VERSION_STRING in "$PY36_VERSION_STRING" "$PY37_VERSION_STRING" "$P
RET=1
fi
done

# Test default (non set) locale in python stub processes
# NOTE: In certain pybind versions, the locale settings may not be propagated from parent to
# stub processes correctly. See https://github.com/triton-inference-server/python_backend/pull/260.
export LC_ALL=INVALID
grep "Locale is (None, None)" $SERVER_LOG
if [ $? -ne 0 ]; then
cat $SERVER_LOG
echo -e "\n***\n*** Default unset Locale was not found in Triton logs. \n***"
RET=1
fi
set -e

rm $SERVER_LOG

# Test locale set via environment variable in python stub processes
# NOTE: In certain pybind versions, the locale settings may not be propagated from parent to
# stub processes correctly. See https://github.com/triton-inference-server/python_backend/pull/260.
export LC_ALL=C.UTF-8
run_server
if [ "$SERVER_PID" == "0" ]; then
echo -e "\n***\n*** Failed to start $SERVER\n***"
cat $SERVER_LOG
exit 1
fi

kill $SERVER_PID
wait $SERVER_PID

set +e
grep "Locale is ('en_US', 'UTF-8')" $SERVER_LOG
if [ $? -ne 0 ]; then
cat $SERVER_LOG
echo -e "\n***\n*** Locale UTF-8 was not found in Triton logs. \n***"
RET=1
fi
set -e

rm $SERVER_LOG
Expand Down
2 changes: 2 additions & 0 deletions qa/python_models/python_version/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import numpy as np
import sys
import os
import locale
import triton_python_backend_utils as pb_utils


Expand Down Expand Up @@ -54,6 +55,7 @@ def initialize(self, args):
print(
f'Python version is {sys.version_info.major}.{sys.version_info.minor}, NumPy version is {np.version.version}, and Tensorflow version is {tensorflow.__version__}',
flush=True)
print(f'Locale is {locale.getlocale()}', flush=True)

def execute(self, requests):
""" This function is called on inference request.
Expand Down

0 comments on commit 01b3b5d

Please sign in to comment.