Skip to content

Commit dff25f4

Browse files
committed
Update tests
1 parent 482409e commit dff25f4

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

qa/L0_input_validation/input_validation_test.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,12 @@ def test_client_input_shape_validation(self):
146146
inputs[0].set_data_from_numpy(input0_data)
147147
inputs[1].set_data_from_numpy(input1_data)
148148

149+
# 1. Test wrong shapes with correct element counts
149150
# Compromised input shapes
150151
inputs[0].set_shape([2, 8])
151152
inputs[1].set_shape([2, 8])
152153

154+
# If element count is correct but shape is wrong, core will return an error.
153155
with self.assertRaises(InferenceServerException) as e:
154156
triton_client.infer(model_name=model_name, inputs=inputs)
155157
err_str = str(e.exception)
@@ -158,10 +160,12 @@ def test_client_input_shape_validation(self):
158160
err_str,
159161
)
160162

163+
# 2. Test wrong shapes with wrong element counts
161164
# Compromised input shapes
162165
inputs[0].set_shape([1, 8])
163166
inputs[1].set_shape([1, 8])
164167

168+
# If element count is wrong, client returns an error.
165169
with self.assertRaises(InferenceServerException) as e:
166170
triton_client.infer(model_name=model_name, inputs=inputs)
167171
err_str = str(e.exception)
@@ -208,15 +212,6 @@ def identity_inference(triton_client, np_array, binary_data):
208212
else:
209213
triton_client = tritongrpcclient.InferenceServerClient("localhost:8001")
210214

211-
# Example using BYTES input tensor with utf-8 encoded string that
212-
# has an embedded null character.
213-
null_chars_array = np.array(
214-
["he\x00llo".encode("utf-8") for i in range(16)], dtype=np.object_
215-
)
216-
null_char_data = null_chars_array.reshape([1, 16])
217-
identity_inference(triton_client, null_char_data, True) # Using binary data
218-
identity_inference(triton_client, null_char_data, False) # Using JSON data
219-
220215
# Example using BYTES input tensor with 16 elements, where each
221216
# element is a 4-byte binary blob with value 0x00010203. Can use
222217
# dtype=np.bytes_ in this case.

0 commit comments

Comments
 (0)