From 383b9fd2fb1ac6a669f91c36fbc256d3113075de Mon Sep 17 00:00:00 2001 From: Kuhu Shukla Date: Fri, 27 Oct 2023 14:23:58 -0500 Subject: [PATCH] Qualification tool: qualification tool can error out from a divide by zero --- user_tools/src/spark_rapids_pytools/rapids/qualification.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/user_tools/src/spark_rapids_pytools/rapids/qualification.py b/user_tools/src/spark_rapids_pytools/rapids/qualification.py index 7b5ed96b1..9bd0ca7b6 100644 --- a/user_tools/src/spark_rapids_pytools/rapids/qualification.py +++ b/user_tools/src/spark_rapids_pytools/rapids/qualification.py @@ -572,9 +572,9 @@ def __calc_apps_cost(self, def get_costs_for_single_app(df_row, estimator: SavingsEstimator) -> pd.Series: raw_cpu_cost, raw_gpu_cost, _ = estimator.get_costs_and_savings(df_row['App Duration'], df_row['Estimated GPU Duration']) - cpu_cost = (100 - self.ctxt.get_ctxt('cpu_discount')) / 100 * raw_cpu_cost - gpu_cost = (100 - self.ctxt.get_ctxt('gpu_discount')) / 100 * raw_gpu_cost - est_savings = 100.0 - ((100.0 * gpu_cost) / cpu_cost) + cpu_cost = (100 - self.ctxt.get_ctxt('cpu_discount')) / 100 * raw_cpu_cost if raw_cpu_cost > 0 else 0 + gpu_cost = (100 - self.ctxt.get_ctxt('gpu_discount')) / 100 * raw_gpu_cost if raw_gpu_cost > 0 else 0 + est_savings = 100.0 - ((100.0 * gpu_cost) / cpu_cost) if cpu_cost > 0 else 0 # We do not want to mistakenly mark a Not-applicable app as Recommended in the savings column if df_row[speedup_rec_col] == 'Not Applicable': savings_recommendations = 'Not Applicable'