def _report_sli(self, sli: Dict[str, Any]) -> str: """Create report for workflow quality SLI. @param sli: It's a dict of SLI associated with the SLI type. """ html_inputs = self._evaluate_sli(sli=sli) last_week_data = pd.DataFrame() if not self.configuration.dry_run: sli_path = f"{self._SLI_NAME}/{self._SLI_NAME}-{self.configuration.last_week_time}.csv" last_week_data = retrieve_thoth_sli_from_ceph( self.configuration.ceph_sli, sli_path, self.total_columns) for component in self.configuration.registered_workflows: if not last_week_data.empty: old_value = last_week_data[component].values[0] change = evaluate_change( old_value=old_value, new_value=html_inputs[component]["value"]) # type: ignore html_inputs[component]["change"] = change # type: ignore report = HTMLTemplates.thoth_workflows_quality_template( html_inputs=html_inputs) return report
def _evaluate_sli(self, sli: Dict[str, Any]) -> Dict[str, Any]: """Evaluate SLI for report for Thoth Integrations Users SLI. @param sli: It's a dict of SLI associated with the SLI type. """ html_inputs: Dict[str, Any] = {} last_week_data = pd.DataFrame() if not self.configuration.dry_run: sli_path = f"{self._SLI_NAME}/{self._SLI_NAME}-{self.configuration.last_week_time}.csv" last_week_data = retrieve_thoth_sli_from_ceph(self.configuration.ceph_sli, sli_path, self.total_columns) for thoth_integration in ["KEBECHET"]: name = thoth_integration.lower() html_inputs[name] = {} thoth_integration_counts_total = sli[f"{thoth_integration}_counts_users_total"] if thoth_integration_counts_total != "ErrorMetricRetrieval": html_inputs[name]["total_users"] = thoth_integration_counts_total else: html_inputs[name]["total_users"] = "N/A" if not last_week_data.empty and thoth_integration_counts_total != "ErrorMetricRetrieval": old_value = last_week_data[last_week_data["integration"] == name]["total_users"].values[0] change = evaluate_change(old_value=old_value, new_value=thoth_integration_counts_total) html_inputs[name]["new"] = change else: html_inputs[name]["new"] = "N/A" return html_inputs
def _evaluate_sli(self) -> List[Dict[str, Any]]: """Evaluate SLI for report for Thoth Adviser Justifications Errors SLI. @param sli: It's a dict of SLI associated with the SLI type. """ html_inputs = [] total_justifications: Dict[str, Any] = {} days = self.configuration.adviser_inputs_analysis_days delta = datetime.timedelta(days=1) if not self.configuration.dry_run: e_time = self.configuration.start_time.strftime('%Y-%m-%d').split( "-") current_end_time = datetime.date( year=int(e_time[0]), month=int(e_time[1]), day=int(e_time[2]), ) + datetime.timedelta(days=1) current_initial_date = current_end_time - datetime.timedelta( days=days) while current_initial_date < current_end_time: _LOGGER.info( f"Analyzing for start date: {current_initial_date}") sli_path = f"{self._SLI_NAME}/{self._SLI_NAME}-{current_initial_date}.csv" daily_justifications_df = retrieve_thoth_sli_from_ceph( self.configuration.ceph_sli, sli_path, [c for c in self.total_columns if c != "timestamp"], ) for message in daily_justifications_df["message"].unique(): for adviser_version in daily_justifications_df[ "adviser_version"].unique(): subset_df = daily_justifications_df[ (daily_justifications_df["message"] == message) & (daily_justifications_df["adviser_version"] == adviser_version)] if subset_df.shape[0] < 1: continue counts = subset_df["total"].values[0] message_type = subset_df["type"].values[0] if message_type != "ERROR": continue if adviser_version not in total_justifications: total_justifications[adviser_version] = {} total_justifications[adviser_version][ message] = counts else: if message not in total_justifications[ adviser_version]: total_justifications[adviser_version][ message] = counts else: total_justifications[adviser_version][ message] += counts current_initial_date += delta for adviser_version, justifications_info in total_justifications.items( ): total_errors = 0 for _, errors_counts in justifications_info.items(): total_errors += errors_counts for justification, counts in justifications_info.items(): if not counts: total = "0" percentage = 0 else: total = "+" + "{}".format(int(counts)) percentage = counts / total_errors html_inputs.append( { "adviser_version": adviser_version, "justification": justification, "total": total, "percentage": abs(round(percentage * 100, 3)), }, ) return html_inputs
def _evaluate_sli(self) -> Dict[str, Any]: """Evaluate SLI for report for Thoth Hardware SLI. @param sli: It's a dict of SLI associated with the SLI type. """ html_inputs: Dict[str, Any] = {} total_quantity: Dict[str, Any] = {} days = self.configuration.adviser_inputs_analysis_days delta = datetime.timedelta(days=1) if not self.configuration.dry_run: e_time = self.configuration.start_time.strftime('%Y-%m-%d').split("-") current_end_time = datetime.date( year=int(e_time[0]), month=int(e_time[1]), day=int(e_time[2]), ) + datetime.timedelta(days=1) current_initial_date = current_end_time - datetime.timedelta(days=days) while current_initial_date < current_end_time: _LOGGER.info(f"Analyzing for start date: {current_initial_date}") sli_path = f"{self._SLI_NAME}/{self._SLI_NAME}-{current_initial_date}.csv" daily_quantity_df = retrieve_thoth_sli_from_ceph( self.configuration.ceph_sli, sli_path, [c for c in self.total_columns if c != "timestamp"], ) for cpu_model in daily_quantity_df["cpu_model"].unique(): subset_df = daily_quantity_df[daily_quantity_df["cpu_model"] == cpu_model] hardware = f"{subset_df['cpu_model'].values[0]}-{subset_df['cpu_family'].values[0]}" if hardware not in total_quantity: total_quantity[hardware] = { "cpu_model": subset_df['cpu_model'].values[0], "cpu_family": subset_df['cpu_family'].values[0], "counts": subset_df["total"].values[0], } else: total_quantity[hardware]["counts"] += subset_df["total"].values[0] current_initial_date += delta total_ = 0 for _, total_counts in total_quantity.items(): total_ += total_counts["counts"] for hardware_, hardware_info in total_quantity.items(): html_inputs[hardware_] = {} html_inputs[hardware_]["cpu_model"] = int(hardware_info["cpu_model"]) html_inputs[hardware_]["cpu_family"] = int(hardware_info["cpu_family"]) if not hardware_info["counts"]: html_inputs[hardware_]["new"] = 0 html_inputs[hardware_]["percentage"] = 0 else: percentage = hardware_info["counts"] / total_ html_inputs[hardware_]["new"] = "+" + "{}".format(int(hardware_info["counts"])) html_inputs[hardware_]["percentage"] = abs(round(percentage * 100, 3)) return html_inputs
def _evaluate_sli(self) -> List[Dict[str, Any]]: """Evaluate SLI for report for Thoth Adviser Reports Statistics SLI. @param sli: It's a dict of SLI associated with the SLI type. """ html_inputs = [] total_statistics: Dict[str, Any] = {} days = self.configuration.adviser_inputs_analysis_days delta = datetime.timedelta(days=1) if not self.configuration.dry_run: e_time = self.configuration.start_time.strftime('%Y-%m-%d').split( "-") current_end_time = datetime.date( year=int(e_time[0]), month=int(e_time[1]), day=int(e_time[2]), ) + datetime.timedelta(days=1) current_initial_date = current_end_time - datetime.timedelta( days=days) while current_initial_date < current_end_time: _LOGGER.info( f"Analyzing for start date: {current_initial_date}") sli_path = f"{self._SLI_NAME}/{self._SLI_NAME}-{current_initial_date}.csv" daily_statistics_df = retrieve_thoth_sli_from_ceph( self.configuration.ceph_sli, sli_path, [ c for c in self.total_columns if c not in ["timestamp", "datetime"] ], ) for adviser_version in daily_statistics_df[ "adviser_version"].unique(): subset_df = daily_statistics_df[ daily_statistics_df["adviser_version"] == adviser_version] s_counts = 0 f_counts = 0 if not subset_df.empty: s_counts = subset_df[ subset_df["adviser_version"] == adviser_version]["success"].values[0] f_counts = subset_df[ subset_df["adviser_version"] == adviser_version]["failure"].values[0] if adviser_version not in total_statistics: total_statistics[adviser_version] = {} total_statistics[adviser_version]["success"] = s_counts total_statistics[adviser_version]["failure"] = f_counts else: total_statistics[adviser_version][ "success"] += s_counts total_statistics[adviser_version][ "failure"] += f_counts current_initial_date += delta for adviser_version, statistics_info in total_statistics.items(): total = statistics_info["success"] + statistics_info["failure"] success_p = statistics_info["success"] / total failure_p = statistics_info["failure"] / total html_inputs.append( { "adviser_version": adviser_version, "success_p": abs(round(success_p * 100, 3)), "failure_p": abs(round(failure_p * 100, 3)), }, ) return html_inputs