From 6b3b248cde3253beb77be1277cc7d914e47d00b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rebollo=20P=C3=A9rez?= Date: Tue, 25 Jun 2024 10:16:03 +0100 Subject: [PATCH] style: pep8 fixes --- .../scripts/data_visualizations.py | 2 +- .../tools/performance/visualization.py | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/deps/wazuh_testing/wazuh_testing/scripts/data_visualizations.py b/deps/wazuh_testing/wazuh_testing/scripts/data_visualizations.py index 0c1c81015a..1b44453732 100644 --- a/deps/wazuh_testing/wazuh_testing/scripts/data_visualizations.py +++ b/deps/wazuh_testing/wazuh_testing/scripts/data_visualizations.py @@ -12,7 +12,6 @@ LogcollectorStatisticsVisualizer, ) - supported_targets = ['binary', 'analysis', 'remote', 'wazuhdb', 'logcollector', 'cluster', 'indexer-alerts', 'indexer-vulnerabilities'] @@ -26,6 +25,7 @@ 'indexer-vulnerabilities': IndexerVulnerabilities } + def create_destination_directory(destination_directory): if not exists(destination_directory): makedirs(destination_directory) diff --git a/deps/wazuh_testing/wazuh_testing/tools/performance/visualization.py b/deps/wazuh_testing/wazuh_testing/tools/performance/visualization.py index 0611ce262f..222cb8793e 100644 --- a/deps/wazuh_testing/wazuh_testing/tools/performance/visualization.py +++ b/deps/wazuh_testing/wazuh_testing/tools/performance/visualization.py @@ -21,6 +21,7 @@ class DataVisualizer(ABC): store_path (str): path to store the CSV images. Defaults to the temp directory. base_name (str, optional): base name used to store the images. """ + def __init__(self, dataframes_paths, store_path=gettempdir(), base_name=None): """Initializes the DataVisualizer. @@ -202,9 +203,9 @@ class BinaryDatavisualizer(DataVisualizer): binary_metrics_fields (list): Combined list of binary metrics fields. """ binary_metrics_fields_to_plot = ["CPU", "VMS", "RSS", "USS", - "PSS", "SWAP", "FD", "Read_Ops", - "Write_Ops", "Disk_Read", "Disk_Written", - "Disk_Read_Speed", "Disk_Write_Speed"] + "PSS", "SWAP", "FD", "Read_Ops", + "Write_Ops", "Disk_Read", "Disk_Written", + "Disk_Read_Speed", "Disk_Write_Speed"] binary_metrics_extra_fields = ["Daemon", "Version", "PID"] binary_metrics_fields = binary_metrics_fields_to_plot + binary_metrics_extra_fields @@ -308,7 +309,7 @@ def plot(self): colors = self._color_palette(len(daemons)) for daemon, color in zip(daemons, colors): self._basic_plot(ax, self.dataframe[self.dataframe.Daemon == daemon][element], - label=daemon, color=color) + label=daemon, color=color) self._save_custom_plot(ax, element, element) @@ -392,6 +393,7 @@ def plot(self): self._basic_plot(ax, self.dataframe[column], label=column, color=color) self._save_custom_plot(ax, title, title) + class LogcollectorStatisticsVisualizer(DaemonStatisticsVisualizer): """A class for visualizing logcollector statistics data. @@ -441,10 +443,11 @@ def plot(self): colors = self._color_palette(len(targets)) for target, color in zip(targets, colors): self._basic_plot(ax, self.dataframe[self.dataframe.Location == target][element['columns']], - label=target, color=color) + label=target, color=color) self._save_custom_plot(ax, element['title'], element['title']) + class ClusterStatisticsVisualizer(DataVisualizer): """A class for visualizing cluster statistics data. @@ -455,7 +458,7 @@ class ClusterStatisticsVisualizer(DataVisualizer): base_name (str, optional): base name used to store the images. expected_cluster_fields (list): List of expected fields for cluster statistics. """ - expected_cluster_fields= ['node_name', 'activity', 'time_spent(s)'] + expected_cluster_fields = ['node_name', 'activity', 'time_spent(s)'] def __init__(self, dataframes_paths, store_path=gettempdir(), base_name=None): """Initialize the ClusterStatisticsVisualizer. @@ -490,9 +493,9 @@ def plot(self): current_df.reset_index(drop=True, inplace=True) for node, color in zip(nodes, self._color_palette(len(nodes))): self._basic_plot(ax=ax, dataframe=current_df[current_df.node_name == node]['time_spent(s)'], - label=node, color=color) + label=node, color=color) self._save_custom_plot(ax, 'time_spent(s)', element.replace(' ', '_').lower(), disable_x_labels=True, - statistics=DataVisualizer._get_statistics( + statistics=DataVisualizer._get_statistics( current_df['time_spent(s)'], calculate_mean=True, calculate_median=True)) @@ -597,7 +600,6 @@ def _get_expected_fields(self): """ return self.expected_fields - def plot(self): """Plot the indexer vulnerabilities data.