44from typing import List , Optional
55
66from src .metrics import Metrics
7- from src .utils import parse_config_args
7+ from src .utils import parse_config_args , parse_config_arg
88
99
1010def get_arg_parser () -> ArgumentParser :
@@ -25,9 +25,9 @@ def get_arg_parser() -> ArgumentParser:
2525
2626DEFAULT_COLUMNS = (
2727 "Setting" ,
28- Metrics .BATCH_SIZE ,
2928 Metrics .INPUT_LENGTH ,
3029 Metrics .TOKENS_SAMPLE ,
30+ Metrics .BATCH_SIZE ,
3131 Metrics .THROUGHPUT_E2E ,
3232 Metrics .LATENCY_E2E ,
3333)
@@ -54,19 +54,19 @@ def read_data(input_file: Path):
5454 return data
5555
5656
57+ def parse_key (key : Optional [str ]) -> Optional [str ]:
58+ if key is None :
59+ return key
60+ return getattr (Metrics , key .upper (), key )
61+ 62+ 5763def make_table (data , cols ):
5864 from markdownTable import markdownTable
5965
6066 data = [Metrics .format_metrics ({col : x [col ] for col in cols }) for x in data ]
6167 return markdownTable (data ).getMarkdown ()
6268
6369
64- def parse_key (key : Optional [str ]) -> Optional [str ]:
65- if key is None :
66- return key
67- return getattr (Metrics , key .upper (), key )
68- 69- 7070def make_compare_table (data , cols , compare_value , compare_col ):
7171 from markdownTable import markdownTable
7272
@@ -104,13 +104,20 @@ def make_compare_table(data, cols, compare_value, compare_col):
104104def filter_data (data , filters ):
105105 if filters is None :
106106 return data
107- filters = parse_config_args (filters )
108- filters = {parse_key (key ): value for key , value in filters .items ()}
107+ 108+ parsed_filters = {}
109+ for filter in filters :
110+ key , value = parse_config_arg (filter )
111+ key = parse_key (key )
112+ if key not in parsed_filters :
113+ parsed_filters [key ] = []
114+ parsed_filters [key ].append (value )
115+ 109116 filtered_data = []
110117 for x in data :
111118 filter = True
112- for key , value in filters .items ():
113- filter = filter and x [key ] == value
119+ for key , value in parsed_filters .items ():
120+ filter = filter and x [key ] in value
114121 if filter :
115122 filtered_data .append (x )
116123 return filtered_data
0 commit comments