Skip to content

Commit bbe0614

Browse files
committed
Formatting
1 parent be2cb1c commit bbe0614

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

qa/L0_client_cancellation/client_cancellation_test.py

+24-21
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232

3333
import asyncio
3434
import queue
35+
import time
3536
import unittest
3637
from functools import partial
37-
import time
3838

3939
import numpy as np
4040
import test_util as tu
@@ -54,6 +54,7 @@ def callback(user_data, result, error):
5454
else:
5555
user_data._completed_requests.put(result)
5656

57+
5758
class ClientCancellationTest(tu.TestResultCollector):
5859
def setUp(self):
5960
self.model_name_ = "custom_identity_int32"
@@ -69,13 +70,13 @@ def _record_end_time_ms(self):
6970

7071
def _test_runtime_duration(self, upper_limit):
7172
self.assertTrue(
72-
(self._end_time_ms - self._start_time_ms) < upper_limit,
73-
"test runtime expected less than "
74-
+ str(upper_limit)
75-
+ "ms response time, got "
76-
+ str(self._end_time_ms - self._start_time_ms)
77-
+ " ms",
78-
)
73+
(self._end_time_ms - self._start_time_ms) < upper_limit,
74+
"test runtime expected less than "
75+
+ str(upper_limit)
76+
+ "ms response time, got "
77+
+ str(self._end_time_ms - self._start_time_ms)
78+
+ " ms",
79+
)
7980

8081
def _prepare_request(self):
8182
self.inputs_ = []
@@ -85,7 +86,6 @@ def _prepare_request(self):
8586

8687
self.inputs_[0].set_data_from_numpy(self.input0_data_)
8788

88-
8989
def test_grpc_async_infer(self):
9090
# Sends a request using async_infer to a
9191
# model that takes 10s to execute. Issues
@@ -115,13 +115,13 @@ def test_grpc_async_infer(self):
115115
# Wait until the results is captured via callback
116116
data_item = user_data._completed_requests.get()
117117
self.assertEqual(type(data_item), grpcclient.CancelledError)
118-
118+
119119
self._record_end_time_ms()
120120
self._test_runtime_duration(5000)
121121

122122
def test_grpc_stream_infer(self):
123123
# Sends a request using async_stream_infer to a
124-
# model that takes 10s to execute. Issues stream
124+
# model that takes 10s to execute. Issues stream
125125
# closure with cancel_requests=True. The client
126126
# should return with appropriate exception within
127127
# 5s.
@@ -134,9 +134,7 @@ def test_grpc_stream_infer(self):
134134

135135
# The model is configured to take three seconds to send the
136136
# response. Expect an exception for small timeout values.
137-
triton_client.start_stream(
138-
callback=partial(callback, user_data)
139-
)
137+
triton_client.start_stream(callback=partial(callback, user_data))
140138
self._record_start_time_ms()
141139
for i in range(1):
142140
triton_client.async_stream_infer(
@@ -148,11 +146,10 @@ def test_grpc_stream_infer(self):
148146

149147
data_item = user_data._completed_requests.get()
150148
self.assertEqual(type(data_item), grpcclient.CancelledError)
151-
149+
152150
self._record_end_time_ms()
153151
self._test_runtime_duration(5000)
154152

155-
156153
def test_aio_grpc_async_infer(self):
157154
# Sends a request using infer of grpc.aio to a
158155
# model that takes 10s to execute. Issues
@@ -187,7 +184,6 @@ async def test_aio_infer(self):
187184
self._record_end_time_ms()
188185
self._test_runtime_duration(5000)
189186

190-
191187
asyncio.run(test_aio_infer(self))
192188

193189
def test_aio_grpc_stream_infer(self):
@@ -198,17 +194,23 @@ def test_aio_grpc_stream_infer(self):
198194
# 5s.
199195
async def test_aio_streaming_infer(self):
200196
async with aiogrpcclient.InferenceServerClient(
201-
url="localhost:8001", verbose=True) as triton_client:
197+
url="localhost:8001", verbose=True
198+
) as triton_client:
199+
202200
async def async_request_iterator():
203201
for i in range(1):
204202
await asyncio.sleep(1)
205-
yield {"model_name": self.model_name_,
203+
yield {
204+
"model_name": self.model_name_,
206205
"inputs": self.inputs_,
207-
"outputs": self.outputs_}
206+
"outputs": self.outputs_,
207+
}
208208

209209
self._prepare_request()
210210
self._record_start_time_ms()
211-
response_iterator = triton_client.stream_infer(inputs_iterator=async_request_iterator(), get_call_obj=True)
211+
response_iterator = triton_client.stream_infer(
212+
inputs_iterator=async_request_iterator(), get_call_obj=True
213+
)
212214
streaming_call = await response_iterator.__anext__()
213215

214216
async def cancel_streaming(streaming_call):
@@ -228,5 +230,6 @@ async def handle_response(response_iterator):
228230

229231
asyncio.run(test_aio_streaming_infer(self))
230232

233+
231234
if __name__ == "__main__":
232235
unittest.main()

0 commit comments

Comments
 (0)