3535
3636
3737async def rate_limited_image_iter (
38- min_interval_ms : int ,
39- max_images : int | None = None ,
40- counter : list [int ] | None = None ,
41- ) -> AsyncIterator [ImageData ]:
38+ min_interval_ms : int ,
39+ max_images : int | None = None ,
40+ counter : list [int ] | None = None ,
41+ ) -> AsyncIterator [ImageData ]:
4242 """Generate images with a minimum interval between yields."""
4343 last_yield_time = time .time ()
4444 async for image in iter_images (max_images , counter ):
@@ -50,10 +50,8 @@ async def rate_limited_image_iter(
5050
5151
5252def process_errors (
53- logger : logging .Logger ,
54- result : ClassifyResponse ,
55- current_error_count : int
56- ) -> int :
53+ logger : logging .Logger , result : ClassifyResponse , current_error_count : int
54+ ) -> int :
5755 """Process errors in the result and update the current error count."""
5856 if has_output_errors (result ):
5957 error_summary = get_output_error_summary (result )
@@ -68,14 +66,12 @@ def process_errors(
6866
6967
7068def dump_classifications (
71- logger : logging .Logger ,
72- successful_outputs : list [ClassificationOutput ]
73- ) -> None :
69+ logger : logging .Logger , successful_outputs : list [ClassificationOutput ]
70+ ) -> None :
7471 """Dump classifications from successful outputs to the logger."""
7572 for output in successful_outputs :
7673 classifications = {
77- c .label : round (c .weight , 3 )
78- for c in output .classifications
74+ c .label : round (c .weight , 3 ) for c in output .classifications
7975 }
8076 logger .debug (
8177 "Result [%s]: %s" ,
@@ -114,16 +110,17 @@ async def run_smoke_test(
114110 received_count = 0
115111 error_count = 0
116112
117- img_gen_func = (iter_images if rate_limit_min_interval_ms is None else
118- lambda max_images , sent_ctr :
119- rate_limited_image_iter (rate_limit_min_interval_ms ,
120- max_images , sent_ctr ))
113+ img_gen_func = (
114+ iter_images
115+ if rate_limit_min_interval_ms is None
116+ else lambda max_images , sent_ctr : rate_limited_image_iter (
117+ rate_limit_min_interval_ms , max_images , sent_ctr
118+ )
119+ )
121120
122121 async with AthenaClient (channel , options ) as client :
123122 generated = img_gen_func (max_test_images , sent_counter )
124- results = client .classify_images (
125- generated
126- )
123+ results = client .classify_images (generated )
127124
128125 start_time = time .time ()
129126
@@ -149,12 +146,15 @@ async def run_smoke_test(
149146 result , raise_on_error = False , log_errors = True
150147 )
151148
152- if ( logger .isEnabledFor (logging .DEBUG ) ):
149+ if logger .isEnabledFor (logging .DEBUG ):
153150 dump_classifications (logger , successful_outputs )
154151
155152 if received_count >= max_test_images :
156- logger .info ("Received all %s test images, with %d errors." ,
157- received_count , error_count )
153+ logger .info (
154+ "Received all %s test images, with %d errors." ,
155+ received_count ,
156+ error_count ,
157+ )
158158 break
159159
160160 except Exception :
0 commit comments