File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
+ from vllm .v1 .metrics .stats import IterationStats
4
+
5
+
6
+ def test_iteration_stats_repr ():
7
+ iteration_stats = IterationStats ()
8
+ iteration_stats .iteration_timestamp = 0
9
+ expected_repr = ("IterationStats("
10
+ "iteration_timestamp=0, "
11
+ "num_generation_tokens=0, "
12
+ "num_prompt_tokens=0, "
13
+ "num_preempted_reqs=0, "
14
+ "finished_requests=[], "
15
+ "max_num_generation_tokens_iter=[], "
16
+ "n_params_iter=[], "
17
+ "time_to_first_tokens_iter=[], "
18
+ "inter_token_latencies_iter=[], "
19
+ "waiting_lora_adapters={}, "
20
+ "running_lora_adapters={})" )
21
+ assert repr (iteration_stats ) == expected_repr
Original file line number Diff line number Diff line change @@ -111,6 +111,11 @@ def __init__(self):
111
111
self .waiting_lora_adapters : dict [str , int ] = {}
112
112
self .running_lora_adapters : dict [str , int ] = {}
113
113
114
+ def __repr__ (self ) -> str :
115
+ field_to_value_str = ", " .join (f"{ k } ={ v } "
116
+ for k , v in vars (self ).items ())
117
+ return f"{ self .__class__ .__name__ } ({ field_to_value_str } )"
118
+
114
119
def _time_since (self , start : float ) -> float :
115
120
"""Calculate an interval relative to this iteration's timestamp."""
116
121
return self .iteration_timestamp - start
You can’t perform that action at this time.
0 commit comments