@@ -17,23 +17,29 @@ def compare_command_logic(args):
17
17
max_negative_pct_change = max_pct_change * - 1.0
18
18
enabled_fail = args .enable_fail_above
19
19
20
- baseline_json = retrieve_local_or_remote_input_json (baseline_file , local_path , "--baseline-file" )
20
+ baseline_json = retrieve_local_or_remote_input_json (
21
+ baseline_file , local_path , "--baseline-file"
22
+ )
21
23
if baseline_json is None :
22
- print (' Error while retrieving {}! Exiting..' .format (baseline_file ))
24
+ print (" Error while retrieving {}! Exiting.." .format (baseline_file ))
23
25
sys .exit (1 )
24
26
25
- comparison_json = retrieve_local_or_remote_input_json (comparison_file , local_path , "--comparison-file" )
27
+ comparison_json = retrieve_local_or_remote_input_json (
28
+ comparison_file , local_path , "--comparison-file"
29
+ )
26
30
if comparison_json is None :
27
- print (' Error while retrieving {}! Exiting..' .format (comparison_file ))
31
+ print (" Error while retrieving {}! Exiting.." .format (comparison_file ))
28
32
sys .exit (1 )
29
33
30
34
##### Comparison starts here #####
31
35
baseline_key_results_steps = baseline_json ["key-results" ].keys ()
32
36
comparison_key_results_steps = comparison_json ["key-results" ].keys ()
33
- baseline_df_config = generate_comparison_dataframe_configs (baseline_json ["benchmark-config" ],
34
- baseline_key_results_steps )
35
- comparison_df_config = generate_comparison_dataframe_configs (comparison_json ["benchmark-config" ],
36
- comparison_key_results_steps )
37
+ baseline_df_config = generate_comparison_dataframe_configs (
38
+ baseline_json ["benchmark-config" ], baseline_key_results_steps
39
+ )
40
+ comparison_df_config = generate_comparison_dataframe_configs (
41
+ comparison_json ["benchmark-config" ], comparison_key_results_steps
42
+ )
37
43
38
44
percentange_change_map = {}
39
45
for step in baseline_key_results_steps :
@@ -42,49 +48,70 @@ def compare_command_logic(args):
42
48
percentange_change_map [step ] = {}
43
49
print ("##############################" )
44
50
print ("Comparing {} step" .format (step ))
45
- key_result_run_name , baseline_metrics = get_key_results_and_values (baseline_json , step , use_result )
46
- key_result_run_name , comparison_metrics = get_key_results_and_values (comparison_json , step , use_result )
51
+ key_result_run_name , baseline_metrics = get_key_results_and_values (
52
+ baseline_json , step , use_result
53
+ )
54
+ key_result_run_name , comparison_metrics = get_key_results_and_values (
55
+ comparison_json , step , use_result
56
+ )
47
57
for baseline_metric_name , baseline_metric_value in baseline_metrics .items ():
48
58
comparison_metric_value = None
49
59
if baseline_metric_name in comparison_metrics :
50
60
comparison_metric_value = comparison_metrics [baseline_metric_name ]
51
- df_dict [baseline_metric_name ] = [baseline_metric_value , comparison_metric_value ]
61
+ df_dict [baseline_metric_name ] = [
62
+ baseline_metric_value ,
63
+ comparison_metric_value ,
64
+ ]
52
65
df = pd .DataFrame (df_dict , index = ["baseline" , "comparison" ])
53
66
print ("Percentage of change for comparison on {}" .format (step ))
54
- df = df .append (df .pct_change ().rename (index = {'comparison' : 'pct_change' }).loc ['pct_change' ] * 100.0 )
67
+ df = df .append (
68
+ df .pct_change ()
69
+ .rename (index = {"comparison" : "pct_change" })
70
+ .loc ["pct_change" ]
71
+ * 100.0
72
+ )
55
73
56
74
for metric_name , items in df .iteritems ():
57
75
58
- lower_is_better = baseline_df_config [step ]["sorting_metric_sorting_direction_map" ][metric_name ]
76
+ lower_is_better = baseline_df_config [step ][
77
+ "sorting_metric_sorting_direction_map"
78
+ ][metric_name ]
59
79
60
80
multiplier = 1.0
61
81
# if lower is better than negative changes are and performance improvement
62
82
if lower_is_better :
63
83
multiplier = - 1.0
64
84
65
85
pct_change = items .get ("pct_change" ) * multiplier
66
- df .at [' pct_change' , metric_name ] = pct_change
86
+ df .at [" pct_change" , metric_name ] = pct_change
67
87
percentange_change_map [step ][metric_name ] = pct_change
68
88
69
89
print (df )
70
90
if enabled_fail :
71
- failing_metrics_serie = df .loc [' pct_change' ] <= max_negative_pct_change
72
- failing_metrics = df .loc [' pct_change' ][failing_metrics_serie ]
91
+ failing_metrics_serie = df .loc [" pct_change" ] <= max_negative_pct_change
92
+ failing_metrics = df .loc [" pct_change" ][failing_metrics_serie ]
73
93
ammount_of_failing_metrics = len (failing_metrics )
74
94
if ammount_of_failing_metrics > 0 :
75
95
df_keys = df .keys ()
76
- print ("There was a total of {} metrics that presented a regression above {} %" .format (
77
- ammount_of_failing_metrics , max_pct_change ))
96
+ print (
97
+ "There was a total of {} metrics that presented a regression above {} %" .format (
98
+ ammount_of_failing_metrics , max_pct_change
99
+ )
100
+ )
78
101
for pos , failed in enumerate (failing_metrics_serie ):
79
102
if failed :
80
- print ("\t Metric '{}' failed. with an percentage of change of {:.2f} %" .format (df_keys [pos ],
81
- df .loc [
82
- 'pct_change' ][
83
- pos ]))
103
+ print (
104
+ "\t Metric '{}' failed. with an percentage of change of {:.2f} %" .format (
105
+ df_keys [pos ], df .loc ["pct_change" ][pos ]
106
+ )
107
+ )
84
108
sys .exit (1 )
85
109
else :
86
- print ("Skipping step: {} due to command line argument --steps not containing it ({})" .format (step , "," .join (
87
- included_steps )))
110
+ print (
111
+ "Skipping step: {} due to command line argument --steps not containing it ({})" .format (
112
+ step , "," .join (included_steps )
113
+ )
114
+ )
88
115
89
116
90
117
def generate_comparison_dataframe_configs (benchmark_config , steps ):
@@ -104,7 +131,9 @@ def generate_comparison_dataframe_configs(benchmark_config, steps):
104
131
step_df_dict [step ]["metric_json_path" ].append (metric_json_path )
105
132
step_df_dict [step ]["df_dict" ][metric_name ] = []
106
133
step_df_dict [step ]["sorting_metric_sorting_direction" ].append (
107
- False if metric ["comparison" ] == "higher-better" else True )
108
- step_df_dict [step ]["sorting_metric_sorting_direction_map" ][metric_name ] = False if metric [
109
- "comparison" ] == "higher-better" else True
134
+ False if metric ["comparison" ] == "higher-better" else True
135
+ )
136
+ step_df_dict [step ]["sorting_metric_sorting_direction_map" ][metric_name ] = (
137
+ False if metric ["comparison" ] == "higher-better" else True
138
+ )
110
139
return step_df_dict
0 commit comments