From ee85a1dc18d61450298897d04af637de0c4f2051 Mon Sep 17 00:00:00 2001 From: rafabailon Date: Wed, 19 Jun 2024 14:52:22 +0200 Subject: [PATCH] feat: change conditional, argument and docstring --- .../wazuh_testing/scripts/data_visualizations.py | 4 ++-- .../tools/performance/visualization.py | 13 +++++++++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/deps/wazuh_testing/wazuh_testing/scripts/data_visualizations.py b/deps/wazuh_testing/wazuh_testing/scripts/data_visualizations.py index 895f768f09..8ba897af7b 100644 --- a/deps/wazuh_testing/wazuh_testing/scripts/data_visualizations.py +++ b/deps/wazuh_testing/wazuh_testing/scripts/data_visualizations.py @@ -20,8 +20,8 @@ def get_script_arguments(): help=f'Base name for the images. Default {None}.') parser.add_argument('-c', '--columns', dest='columns', default=None, help=f'Path to Json with Columns to Plot. Default {None}.') - parser.add_argument('-u', '--unify', dest='unify', default=False, - help=f'Unify data of the binary processes with their subprocesses to plot. Default {False}.') + parser.add_argument('-u', '--unify', dest='unify', action='store_true', + help=f'Unify data of the binary processes with their subprocesses to plot.') return parser.parse_args() diff --git a/deps/wazuh_testing/wazuh_testing/tools/performance/visualization.py b/deps/wazuh_testing/wazuh_testing/tools/performance/visualization.py index 85acb60fdc..31ead4be57 100644 --- a/deps/wazuh_testing/wazuh_testing/tools/performance/visualization.py +++ b/deps/wazuh_testing/wazuh_testing/tools/performance/visualization.py @@ -4,6 +4,7 @@ from matplotlib.ticker import LinearLocator import json +import logging import matplotlib.dates as mdates import matplotlib.pyplot as plt import pandas as pd @@ -48,9 +49,12 @@ def __init__(self, dataframes, target, compare=False, store_path=gettempdir(), x if target in ['binary', 'analysis', 'remote', 'agent', 'logcollector', 'wazuhdb']: self.columns_to_plot = self._load_columns_to_plot(columns_path) - if unify_child_daemon_metrics.lower() in ["true"] and target in ['binary']: - self.dataframe = self.dataframe.reset_index(drop=False) - self._unify_dataframes() + if unify_child_daemon_metrics: + if target == 'binary': + self.dataframe = self.dataframe.reset_index(drop=False) + self._unify_dataframes() + else: + logging.warning("Enabled unify is only available for binary data. Ignoring") @staticmethod def _color_palette(size): @@ -92,7 +96,8 @@ def _load_dataframes(self): self.dataframe = pd.concat([self.dataframe, new_csv]) def _unify_dataframes(self): - """Unify dataframe values.""" + """Unify the data of each process with their respective sub-processes. + """ pids = self.dataframe[['Daemon', 'PID']].drop_duplicates() versions = self.dataframe[['Daemon', 'Version']].drop_duplicates()