Skip to content

Commit 40c2c45

Browse files
authored
Add Python binding build. Add L0_python_api to test Python binding (#6319)
* Add L0_python_api to test Python binding * Install Python API in CI image * Fix QA build
1 parent 6527c73 commit 40c2c45

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

Dockerfile.QA

+8
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ RUN mkdir -p qa/common && \
143143
cp bin/backend_output_detail_test qa/L0_backend_output_detail/. && \
144144
cp -r deploy/mlflow-triton-plugin qa/L0_mlflow/.
145145

146+
RUN mkdir -p qa/pkgs && \
147+
cp python/triton*.whl qa/pkgs/. && \
148+
cp python/test_binding.py qa/L0_python_api/.
149+
146150
# caffe2plan will not exist if the build was done without TensorRT enabled
147151
RUN if [ -f bin/caffe2plan ]; then \
148152
cp bin/caffe2plan qa/common/.; \
@@ -369,6 +373,10 @@ RUN rm -fr qa/L0_copyrights qa/L0_build_variants && \
369373
"tritonclient-*linux*.whl" | xargs printf -- '%s[all]' | \
370374
xargs pip3 install --upgrade
371375

376+
# Install Triton Python API
377+
RUN find qa/pkgs/ -maxdepth 1 -type f -name \
378+
"tritonserver-*.whl" | xargs pip3 install --upgrade
379+
372380
ENV LD_LIBRARY_PATH /opt/tritonserver/qa/clients:${LD_LIBRARY_PATH}
373381

374382
# DLIS-3631: Needed to run Perf Analyzer CI tests correctly

build.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,13 @@ def core_build(
16831683
os.path.join(repo_install_dir, "lib", "libtritonserver.so"),
16841684
os.path.join(install_dir, "lib"),
16851685
)
1686+
# [FIXME] Placing the Triton server wheel file in 'python' for now, should
1687+
# have been upload to pip registry and be able to install directly
1688+
cmake_script.mkdir(os.path.join(install_dir, "python"))
1689+
cmake_script.cp(
1690+
os.path.join(repo_install_dir, "python", "tritonserver*.whl"),
1691+
os.path.join(install_dir, "python"),
1692+
)
16861693

16871694
cmake_script.mkdir(os.path.join(install_dir, "include", "triton"))
16881695
cmake_script.cpdir(
@@ -1854,7 +1861,7 @@ def cibase_build(
18541861
os.path.join(repo_dir, "src", "test", "models"),
18551862
os.path.join(ci_dir, "src", "test"),
18561863
)
1857-
# Skip copying the artifacts in the bin and lib as those directories will
1864+
# Skip copying the artifacts in the bin, lib, and python as those directories will
18581865
# be missing when the core build is not enabled.
18591866
if not FLAGS.no_core_build:
18601867
cmake_script.cpdir(os.path.join(repo_install_dir, "bin"), ci_dir)
@@ -1863,6 +1870,7 @@ def cibase_build(
18631870
os.path.join(repo_install_dir, "lib", "libtritonrepoagent_relocation.so"),
18641871
os.path.join(ci_dir, "lib"),
18651872
)
1873+
cmake_script.cpdir(os.path.join(repo_install_dir, "python"), ci_dir)
18661874

18671875
# Some of the backends are needed for CI testing
18681876
cmake_script.mkdir(os.path.join(ci_dir, "backends"))

qa/L0_python_api/test.sh

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3+
#
4+
# Redistribution and use in source and binary forms, with or without
5+
# modification, are permitted provided that the following conditions
6+
# are met:
7+
# * Redistributions of source code must retain the above copyright
8+
# notice, this list of conditions and the following disclaimer.
9+
# * Redistributions in binary form must reproduce the above copyright
10+
# notice, this list of conditions and the following disclaimer in the
11+
# documentation and/or other materials provided with the distribution.
12+
# * Neither the name of NVIDIA CORPORATION nor the names of its
13+
# contributors may be used to endorse or promote products derived
14+
# from this software without specific prior written permission.
15+
#
16+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
17+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
20+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
21+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
24+
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27+
28+
TEST_LOG="./python_binding.log"
29+
30+
RET=0
31+
32+
rm -f $TEST_LOG
33+
34+
set +e
35+
36+
python test_binding.py > $TEST_LOG 2>&1
37+
if [ $? -ne 0 ]; then
38+
echo -e "\n***\n*** Test Failed\n***"
39+
RET=1
40+
fi
41+
set -e
42+
43+
if [ $RET -eq 0 ]; then
44+
echo -e "\n***\n*** Test Passed\n***"
45+
else
46+
cat $TEST_LOG
47+
echo -e "\n***\n*** Test FAILED\n***"
48+
fi
49+
50+
exit $RET

0 commit comments

Comments
 (0)