Skip to content

Commit db3d08b

Browse files
authored
Add testing for handling bls error in initialize and finalize functions (#5469)
* Add testing for handling bls error during initialize and finalize functions * Update the error message
1 parent 521d952 commit db3d08b

File tree

5 files changed

+212
-0
lines changed

5 files changed

+212
-0
lines changed

qa/L0_backend_python/bls/test.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,53 @@ for TRIAL in non_decoupled decoupled ; do
172172
wait $SERVER_PID
173173
done
174174

175+
# Test error handling when BLS is used in "initialize" or "finalize" function
176+
ERROR_MESSAGE="BLS is only supported during the 'execute' function."
177+
178+
rm -fr ./models
179+
mkdir -p models/bls_init_error/1/
180+
cp ../../python_models/bls_init_error/model.py models/bls_init_error/1/
181+
cp ../../python_models/bls_init_error/config.pbtxt models/bls_init_error
182+
SERVER_LOG="./bls_init_error_server.log"
183+
184+
run_server
185+
if [ "$SERVER_PID" != "0" ]; then
186+
echo -e "*** FAILED: unexpected success starting $SERVER" >> $CLIENT_LOG
187+
RET=1
188+
kill $SERVER_PID
189+
wait $SERVER_PID
190+
else
191+
if grep "$ERROR_MESSAGE" $SERVER_LOG; then
192+
echo -e "Found \"$ERROR_MESSAGE\"" >> $CLIENT_LOG
193+
else
194+
echo -e "Not found \"$ERROR_MESSAGE\"" >> $CLIENT_LOG
195+
RET=1
196+
fi
197+
fi
198+
199+
rm -fr ./models
200+
mkdir -p models/bls_finalize_error/1/
201+
cp ../../python_models/bls_finalize_error/model.py models/bls_finalize_error/1/
202+
cp ../../python_models/bls_finalize_error/config.pbtxt models/bls_finalize_error/
203+
SERVER_LOG="./bls_finalize_error_server.log"
204+
205+
run_server
206+
if [ "$SERVER_PID" == "0" ]; then
207+
echo -e "\n***\n*** Failed to start $SERVER\n***"
208+
cat $SERVER_LOG
209+
exit 1
210+
fi
211+
212+
kill $SERVER_PID
213+
wait $SERVER_PID
214+
215+
if grep "$ERROR_MESSAGE" $SERVER_LOG; then
216+
echo -e "Found \"$ERROR_MESSAGE\"" >> $CLIENT_LOG
217+
else
218+
echo -e "Not found \"$ERROR_MESSAGE\"" >> $CLIENT_LOG
219+
RET=1
220+
fi
221+
175222
if [ $RET -eq 1 ]; then
176223
cat $CLIENT_LOG
177224
cat $SERVER_LOG
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# Redistribution and use in source and binary forms, with or without
4+
# modification, are permitted provided that the following conditions
5+
# are met:
6+
# * Redistributions of source code must retain the above copyright
7+
# notice, this list of conditions and the following disclaimer.
8+
# * Redistributions in binary form must reproduce the above copyright
9+
# notice, this list of conditions and the following disclaimer in the
10+
# documentation and/or other materials provided with the distribution.
11+
# * Neither the name of NVIDIA CORPORATION nor the names of its
12+
# contributors may be used to endorse or promote products derived
13+
# from this software without specific prior written permission.
14+
#
15+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23+
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
name: "bls_finalize_error"
28+
backend: "python"
29+
30+
output [
31+
{
32+
name: "OUTPUT0"
33+
data_type: TYPE_FP32
34+
dims: [ 16 ]
35+
}
36+
]
37+
38+
instance_group [{ kind: KIND_CPU }]
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# Redistribution and use in source and binary forms, with or without
4+
# modification, are permitted provided that the following conditions
5+
# are met:
6+
# * Redistributions of source code must retain the above copyright
7+
# notice, this list of conditions and the following disclaimer.
8+
# * Redistributions in binary form must reproduce the above copyright
9+
# notice, this list of conditions and the following disclaimer in the
10+
# documentation and/or other materials provided with the distribution.
11+
# * Neither the name of NVIDIA CORPORATION nor the names of its
12+
# contributors may be used to endorse or promote products derived
13+
# from this software without specific prior written permission.
14+
#
15+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23+
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
import triton_python_backend_utils as pb_utils
28+
import time
29+
import numpy as np
30+
31+
class TritonPythonModel:
32+
def initialize(self, args):
33+
pass
34+
35+
def execute(self, requests):
36+
pass
37+
38+
def finalize(self):
39+
print('Cleaning up...')
40+
input0_np = np.random.randint(3, size=1, dtype=np.int32)
41+
input0 = pb_utils.Tensor('IN', input0_np)
42+
infer_request = pb_utils.InferenceRequest(model_name='square_int32',
43+
inputs=[input0],
44+
requested_output_names=['OUT'])
45+
infer_responses = infer_request.exec(decoupled=True)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# Redistribution and use in source and binary forms, with or without
4+
# modification, are permitted provided that the following conditions
5+
# are met:
6+
# * Redistributions of source code must retain the above copyright
7+
# notice, this list of conditions and the following disclaimer.
8+
# * Redistributions in binary form must reproduce the above copyright
9+
# notice, this list of conditions and the following disclaimer in the
10+
# documentation and/or other materials provided with the distribution.
11+
# * Neither the name of NVIDIA CORPORATION nor the names of its
12+
# contributors may be used to endorse or promote products derived
13+
# from this software without specific prior written permission.
14+
#
15+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23+
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
name: "bls_init_error"
28+
backend: "python"
29+
30+
output [
31+
{
32+
name: "OUTPUT0"
33+
data_type: TYPE_FP32
34+
dims: [ 16 ]
35+
}
36+
]
37+
38+
instance_group [{ kind: KIND_CPU }]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
#
3+
# Redistribution and use in source and binary forms, with or without
4+
# modification, are permitted provided that the following conditions
5+
# are met:
6+
# * Redistributions of source code must retain the above copyright
7+
# notice, this list of conditions and the following disclaimer.
8+
# * Redistributions in binary form must reproduce the above copyright
9+
# notice, this list of conditions and the following disclaimer in the
10+
# documentation and/or other materials provided with the distribution.
11+
# * Neither the name of NVIDIA CORPORATION nor the names of its
12+
# contributors may be used to endorse or promote products derived
13+
# from this software without specific prior written permission.
14+
#
15+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
16+
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18+
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
19+
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20+
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21+
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23+
# OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26+
27+
import triton_python_backend_utils as pb_utils
28+
import time
29+
import numpy as np
30+
31+
class TritonPythonModel:
32+
def initialize(self, args):
33+
input0_np = np.random.randint(3, size=1, dtype=np.int32)
34+
input0 = pb_utils.Tensor('IN', input0_np)
35+
infer_request = pb_utils.InferenceRequest(model_name='square_int32',
36+
inputs=[input0],
37+
requested_output_names=['OUT'])
38+
infer_responses = infer_request.exec(decoupled=True)
39+
40+
def execute(self, requests):
41+
pass
42+
43+
def finalize(self):
44+
print('Cleaning up...')

0 commit comments

Comments
 (0)