Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python binding build. Add L0_python_api to test Python binding #6319

Merged
merged 3 commits into from
Sep 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Dockerfile.QA
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ RUN mkdir -p qa/common && \
cp bin/backend_output_detail_test qa/L0_backend_output_detail/. && \
cp -r deploy/mlflow-triton-plugin qa/L0_mlflow/.

RUN mkdir -p qa/pkgs && \
cp python/triton*.whl qa/pkgs/. && \
cp python/test_binding.py qa/L0_python_api/.

# caffe2plan will not exist if the build was done without TensorRT enabled
RUN if [ -f bin/caffe2plan ]; then \
cp bin/caffe2plan qa/common/.; \
Expand Down Expand Up @@ -369,6 +373,10 @@ RUN rm -fr qa/L0_copyrights qa/L0_build_variants && \
"tritonclient-*linux*.whl" | xargs printf -- '%s[all]' | \
xargs pip3 install --upgrade

# Install Triton Python API
RUN find qa/pkgs/ -maxdepth 1 -type f -name \
"tritonserver-*.whl" | xargs pip3 install --upgrade

ENV LD_LIBRARY_PATH /opt/tritonserver/qa/clients:${LD_LIBRARY_PATH}

# DLIS-3631: Needed to run Perf Analyzer CI tests correctly
Expand Down
10 changes: 9 additions & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,13 @@ def core_build(
os.path.join(repo_install_dir, "lib", "libtritonserver.so"),
os.path.join(install_dir, "lib"),
)
# [FIXME] Placing the Triton server wheel file in 'python' for now, should
# have been upload to pip registry and be able to install directly
cmake_script.mkdir(os.path.join(install_dir, "python"))
cmake_script.cp(
os.path.join(repo_install_dir, "python", "tritonserver*.whl"),
os.path.join(install_dir, "python"),
)

cmake_script.mkdir(os.path.join(install_dir, "include", "triton"))
cmake_script.cpdir(
Expand Down Expand Up @@ -1854,7 +1861,7 @@ def cibase_build(
os.path.join(repo_dir, "src", "test", "models"),
os.path.join(ci_dir, "src", "test"),
)
# Skip copying the artifacts in the bin and lib as those directories will
# Skip copying the artifacts in the bin, lib, and python as those directories will
# be missing when the core build is not enabled.
if not FLAGS.no_core_build:
cmake_script.cpdir(os.path.join(repo_install_dir, "bin"), ci_dir)
Expand All @@ -1863,6 +1870,7 @@ def cibase_build(
os.path.join(repo_install_dir, "lib", "libtritonrepoagent_relocation.so"),
os.path.join(ci_dir, "lib"),
)
cmake_script.cpdir(os.path.join(repo_install_dir, "python"), ci_dir)

# Some of the backends are needed for CI testing
cmake_script.mkdir(os.path.join(ci_dir, "backends"))
Expand Down
50 changes: 50 additions & 0 deletions qa/L0_python_api/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of NVIDIA CORPORATION nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

TEST_LOG="./python_binding.log"

RET=0

rm -f $TEST_LOG

set +e

python test_binding.py > $TEST_LOG 2>&1
if [ $? -ne 0 ]; then
echo -e "\n***\n*** Test Failed\n***"
RET=1
fi
set -e

if [ $RET -eq 0 ]; then
echo -e "\n***\n*** Test Passed\n***"
else
cat $TEST_LOG
echo -e "\n***\n*** Test FAILED\n***"
fi

exit $RET