Skip to content

Commit

Permalink
taking out extra percent changes
Browse files Browse the repository at this point in the history
rh-pre-commit.version: 2.2.0
rh-pre-commit.check-secrets: ENABLED
  • Loading branch information
Auto User committed Sep 19, 2024
1 parent ee83322 commit 351664e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
19 changes: 3 additions & 16 deletions pkg/algorithms/cmr/cmr.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def _analyze(self):
series: data series that contains attributes and full dataframe
change_points_by_metric: list of ChangePoints
"""
logger_instance = SingletonLogger.getLogger("Orion")
logger_instance.info("Starting analysis using CMR")
self.logger_instance = SingletonLogger.getLogger("Orion")
self.logger_instance.info("Starting analysis using CMR")
self.dataframe["timestamp"] = pd.to_datetime(self.dataframe["timestamp"])
self.dataframe["timestamp"] = self.dataframe["timestamp"].astype(int) // 10**9

Expand Down Expand Up @@ -62,14 +62,8 @@ def run_cmr(self, tolerancy: int, dataframe_list: pd.DataFrame):
change_points_by_metric={ k:[] for k in metric_columns }
max_date_time = pd.Timestamp.max.to_pydatetime()
max_time = max_date_time.timestamp()
# difference = ["difference", max_time]
# pass_fail_list = ["Pass/Fail", max_time]

for column in metric_columns:
pct_change_result = dataframe_list[column].pct_change()
single_pct_diff = round(pct_change_result.iloc[[-1]].values[0] * 100)
pass_fail = "Pass"
if single_pct_diff > tolerancy:
pass_fail = "Fail"

change_point = ChangePoint(metric=column,
index=1,
Expand All @@ -82,13 +76,6 @@ def run_cmr(self, tolerancy: int, dataframe_list: pd.DataFrame):
pvalue=1
))
change_points_by_metric[column].append(change_point)
# difference.append(single_pct_diff)
# pass_fail_list.append(pass_fail)
# difference.append("none")
# pass_fail_list.append("none")
# dataframe_list.loc[len(dataframe_list.index)] = difference
#dataframe_list.loc[len(dataframe_list.index)] = pass_fail_list
# logger_instance.info("final data frame " + str(dataframe_list))

# based on change point generate pass/fail
return dataframe_list, change_points_by_metric
Expand Down
20 changes: 12 additions & 8 deletions pkg/runTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,16 @@
import pkg.constants as cnsts
from pkg.utils import get_datasource, process_test, get_subtracted_timestamp


def get_algorithm_type(kwargs):
if kwargs["hunter_analyze"]:
algorithm_name = cnsts.EDIVISIVE
elif kwargs["anomaly_detection"]:
algorithm_name = cnsts.ISOLATION_FOREST
elif kwargs['cmr']:
algorithm_name = cnsts.CMR
else:
algorithm_name = None
return algorithm_name

def run(**kwargs: dict[str, Any]) -> dict[str, Any]: #pylint: disable = R0914
"""run method to start the tests
Expand Down Expand Up @@ -48,13 +57,8 @@ def run(**kwargs: dict[str, Any]) -> dict[str, Any]: #pylint: disable = R0914
if fingerprint_matched_df is None:
sys.exit(3) # No data present

if kwargs["hunter_analyze"]:
algorithm_name = cnsts.EDIVISIVE
elif kwargs["anomaly_detection"]:
algorithm_name = cnsts.ISOLATION_FOREST
elif kwargs['cmr']:
algorithm_name = cnsts.CMR
else:
algorithm_name = get_algorithm_type(kwargs)
if algorithm_name is None:
return None, None

algorithmFactory = AlgorithmFactory()
Expand Down

0 comments on commit 351664e

Please sign in to comment.