4
4
from typing import List , Optional
5
5
6
6
from src .metrics import Metrics
7
- from src .utils import parse_config_args
7
+ from src .utils import parse_config_args , parse_config_arg
8
8
9
9
10
10
def get_arg_parser () -> ArgumentParser :
@@ -25,9 +25,9 @@ def get_arg_parser() -> ArgumentParser:
25
25
26
26
DEFAULT_COLUMNS = (
27
27
"Setting" ,
28
- Metrics .BATCH_SIZE ,
29
28
Metrics .INPUT_LENGTH ,
30
29
Metrics .TOKENS_SAMPLE ,
30
+ Metrics .BATCH_SIZE ,
31
31
Metrics .THROUGHPUT_E2E ,
32
32
Metrics .LATENCY_E2E ,
33
33
)
@@ -54,19 +54,19 @@ def read_data(input_file: Path):
54
54
return data
55
55
56
56
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
+
57
63
def make_table (data , cols ):
58
64
from markdownTable import markdownTable
59
65
60
66
data = [Metrics .format_metrics ({col : x [col ] for col in cols }) for x in data ]
61
67
return markdownTable (data ).getMarkdown ()
62
68
63
69
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
-
70
70
def make_compare_table (data , cols , compare_value , compare_col ):
71
71
from markdownTable import markdownTable
72
72
@@ -104,13 +104,20 @@ def make_compare_table(data, cols, compare_value, compare_col):
104
104
def filter_data (data , filters ):
105
105
if filters is None :
106
106
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
+
109
116
filtered_data = []
110
117
for x in data :
111
118
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
114
121
if filter :
115
122
filtered_data .append (x )
116
123
return filtered_data
0 commit comments