Skip to content

Commit

Permalink
fixed crashes
Browse files Browse the repository at this point in the history
Signed-off-by: Elad Gershon <egershon@nvidia.com>
  • Loading branch information
egershonNvidia committed Sep 10, 2024
1 parent 8eb2577 commit 0e7c507
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from os.path import join,exists
from os import remove
from os import remove,makedirs
from pathlib import Path
from datetime import datetime
import pandas as pd
Expand All @@ -10,13 +10,16 @@ class DataStore:
"""
OUTPUT_FILE_FORMAT = "%Y_%m_%d_%H_%M_%S.csv"
AMOUNT_FILES_TO_KEEP = 10
BASE_PATH = "/opt/ufm/PDR/datastore"
BASE_PATH = "/opt/ufm/ufm_plugin_pdr_deterministic/datastore"
ABS_PATH = "abs"
DELTA_PATH = "delta"
TAR_SUFFIX = "*.tar.gz"

def __init__(self,logger) -> None:
self.logger = logger
if not exists(self.BASE_PATH):
makedirs(self._folder_abs())
makedirs(self._folder_delta())

def _folder_abs(self) -> str:
return join(self.BASE_PATH,self.ABS_PATH)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def analyze_telemetry_data(self, ports_data, ports_counters):
issues[port_name] = ber_issue
# If out of operating conditions we'll overwrite the cause
if self.temp_check and self.is_out_of_operating_conf(port_name):
issues[port_name] = Constants.ISSUE_OONOC
issues[port_name].cause = Constants.ISSUE_OONOC
return list(issues.values())

def check_deisolation_conditions(self, isolated_port):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class TelemetryCollector:
Represent Telemetry collector which send DataFrame once telemetry is called.
Calls data store class for save the abs or delta data.
"""
BASED_COLUMNS = ["node_guid", "port_guid", "port_num"]
BASED_COLUMNS = ["Node_GUID", "port_guid", "Port_Number"]
KEY = BASED_COLUMNS + ["timestamp","tag"]

def __init__(self,test_mode:bool,logger,data_store:DataStore) -> None:
Expand All @@ -32,7 +32,7 @@ def get_telemetry(self):
except (pd.errors.ParserError, pd.errors.EmptyDataError, urllib.error.URLError) as connection_error:
self.logger.error("failed to get telemetry data from UFM, fetched url=%s. Error: %s",url,connection_error)
telemetry_data = None
if self.previous_telemetry_data and telemetry_data:
if self.previous_telemetry_data is not None and telemetry_data is not None:
delta = self._get_delta(self.previous_telemetry_data,telemetry_data)
# when we want to keep only delta
if len(delta) > 0:
Expand All @@ -44,11 +44,10 @@ def get_telemetry(self):
return telemetry_data

def _get_delta(self, first_df: pd.DataFrame, second_df:pd.DataFrame):
self.logger.info("%s._delta", self.__class__.__name__)
merged_df = pd.merge(second_df, first_df, on=self.BASED_COLUMNS, how='inner', suffixes=('', '_x'))
delta_dataframe = pd.DataFrame()
for col in second_df.columns:
if col not in self.KEY:
for index,col in enumerate(second_df.columns):
if col not in self.KEY and not isinstance(merged_df.iat[0,index],str):
col_x = col + "_x"
delta_dataframe[col] = merged_df[col] - merged_df[col_x]
else:
Expand Down

0 comments on commit 0e7c507

Please sign in to comment.