Skip to content

Commit 3352126

Browse files
author
Auto User
committed
spacing and doc chagnes
rh-pre-commit.version: 2.2.0 rh-pre-commit.check-secrets: ENABLED
1 parent 49595d2 commit 3352126

File tree

6 files changed

+54
-26
lines changed

6 files changed

+54
-26
lines changed

README.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,9 @@ Additionally, users can specify a custom path for the output CSV file using the
124124
Orion now supports anomaly detection for your data. Use the ```--anomaly-detection``` command to start the anomaly detection process.
125125

126126

127-
To be able to find significant percent differences in workload runs, use the ```--cmr``` command. This will compare the most recent run with any previous matching runs or baseline UUIDs. If more than 1 other run is found from the most recent, the values will be meaned together and then compared with the previous run. Use with *direction: 0* (set in the config) when using ```-o json``` format to see percent differences
128-
```
129-
time uuid buildUrl timestamp podReadyLatency_P99 apiserverCPU_avg ovnCPU_avg etcdCPU_avg kubelet_avg
130-
------------------------- ----------------------------- ----------- --------------------- ------------------ ------------ ------------- -------------
131-
2024-05-20 00:47:53 +0000 0ed676a0-6e23-498e-b33e-fe520636e459,e752c921-6b93-42d8-b262-0bcc219bfc2b https://prow....... 1.71617e+09 132000 15.5236 6.18368 14.711 24.4395
132-
····················· ·················· ············ ············· ·············
133-
-8.3% +1.3% -6.7% -0.6% -19.0%
134-
····················· ·················· ············ ············· ·············
135-
2024-08-14 17:07:33 +0000 e9e1f71c-9457-4a82-b561-e2158c8eae7c https://prow....... 1.72366e+09 121000 15.7236 5.77077 14.627 19.7842
127+
To be able to find significant percent differences in workload runs, use the ```--cmr``` command. This will compare the most recent run with any previous matching runs or baseline UUIDs. If more than 1 other run is found from the most recent, the values will be meaned together and then compared with the previous run. Use with *direction: 0* (set in the config) when using ```-o json``` format to see percent differences
136128

137-
```
129+
![cmr percent difference](https://private-user-images.githubusercontent.com/64206430/359942919-fcf0ba90-5571-4afd-bc64-a7f4accffe6a.jpg?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQyNTAxMDIsIm5iZiI6MTcyNDI0OTgwMiwicGF0aCI6Ii82NDIwNjQzMC8zNTk5NDI5MTktZmNmMGJhOTAtNTU3MS00YWZkLWJjNjQtYTdmNGFjY2ZmZTZhLmpwZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MjElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODIxVDE0MTY0MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTI2YTk0ZmU0OWVlODJmNDhlNTU0ZGI0YWFlNTdhYTZjNzE4ZjRjMGNjNzIzMjdkZmM1ODdlMTU3NjQ3MTk4MGQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.-3p6Muzv0EmGfcxiYMym1vprqSAkklYGmJP54nQNF5g)
138130

139131
You can now constrain your look-back period using the ```--lookback``` option. The format for look-back is ```XdYh```, where X represents the number of days and Y represents the number of hours.
140132

orion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def cli(max_content_width=120): # pylint: disable=unused-argument
7171
@cli.command(name="cmd")
7272
@click.option(
7373
"--cmr",
74-
is_flag=True,
74+
is_flag=True,
7575
help="Generate percent difference in comparison",
7676
cls=MutuallyExclusiveOption,
7777
mutually_exclusive=["anomaly_detection","hunter_analyze"],

pkg/algorithms/algorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,5 +173,5 @@ def output(self, output_format) -> Union[Any,None]:
173173
return self.output_text()
174174
if output_format == cnsts.JUNIT:
175175
return self.output_junit()
176-
176+
177177
raise ValueError("Unsupported output format {output_format} selected")

pkg/algorithms/cmr/cmr.py

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,38 @@
11
"""EDivisive Algorithm from hunter"""
22

33
# pylint: disable = line-too-long
4+
from typing import List
45
import pandas as pd
56
import numpy
6-
from pkg.algorithms.algorithm import Algorithm
7-
from hunter.series import ChangePoint, ComparativeStats
87

98
from fmatch.logrus import SingletonLogger
9+
from hunter.series import ChangePoint, ComparativeStats
10+
from pkg.algorithms.algorithm import Algorithm
11+
1012

1113
class CMR(Algorithm):
1214
"""Implementation of the CMR algorithm
13-
Will Combine metrics into 2 lines and compare with a tolerancy to logger_instance.info pass fail
15+
Will Combine metrics into 2 lines and compare with a tolerancy to set pass fail
1416
1517
Args:
1618
Algorithm (Algorithm): Inherits
1719
"""
1820

1921

2022
def _analyze(self):
23+
"""Analyze the dataframe with meaning any previous data and generate percent change with a current uuid
2124
25+
Returns:
26+
series: data series that contains attributes and full dataframe
27+
change_points_by_metric: list of ChangePoints
28+
"""
2229
logger_instance = SingletonLogger.getLogger("Orion")
2330
logger_instance.info("Starting analysis using Isolation Forest")
2431
self.dataframe["timestamp"] = pd.to_datetime(self.dataframe["timestamp"])
2532
self.dataframe["timestamp"] = self.dataframe["timestamp"].astype(int) // 10**9
2633

2734
logger_instance.info('data frame ' + str(self.dataframe))
28-
35+
2936
# if larger than 2 rows, need to get the mean of 0 through -2
3037
self.dataframe = self.combine_data_frames( self.dataframe)
3138

@@ -37,13 +44,24 @@ def _analyze(self):
3744
return series, change_points_by_metric
3845

3946

40-
def run_cmr(self, tolerancy,metric_columns, dataframe_list):
47+
def run_cmr(self, tolerancy: int,metric_columns: List[str], dataframe_list: pd.DataFrame):
48+
"""
49+
Generate the percent difference in a 2 row dataframe
50+
51+
Args:
52+
tolerancy (int): tolerancy to compare on
53+
metric_columns (List[str]): string list of metric column names
54+
dataframe_list (pd.DataFrame): data frame of all data to compare on
55+
56+
Returns:
57+
pd.Dataframe, dict[metric_name, ChangePoint]: Returned data frame and change points
58+
"""
4159
change_points_by_metric={ k:[] for k in metric_columns }
4260
max_date_time = pd.Timestamp.max.to_pydatetime()
4361
max_time = max_date_time.timestamp()
4462
difference = ["difference", max_time]
4563
pass_fail_list = ["Pass/Fail", max_time]
46-
for column in metric_columns:
64+
for column in metric_columns:
4765
pct_change_result = dataframe_list[column].pct_change()
4866
single_pct_diff = round(pct_change_result.iloc[[-1]].values[0] * 100)
4967
pass_fail = "Pass"
@@ -71,9 +89,18 @@ def run_cmr(self, tolerancy,metric_columns, dataframe_list):
7189

7290
# based on change point generate pass/fail
7391
return dataframe_list, change_points_by_metric
74-
75-
def combine_data_frames(self, dataFrame):
76-
# https://stackoverflow.com/questions/63037612/how-to-combine-two-dataframes-and-average-like-values
92+
93+
def combine_data_frames(self, dataFrame: pd.DataFrame):
94+
"""
95+
If more than 1 previous run, mean data together into 1 single row
96+
Combine with current run into 1 data frame (current run being -1 index)
97+
98+
Args:
99+
dataFrame (pd.DataFrame): data to combine into 2 rows
100+
101+
Returns:
102+
pd.Dataframe: data frame of most recent run and averaged previous runs
103+
"""
77104
i = 0
78105

79106
last_row = dataFrame.tail(1)
@@ -83,14 +110,14 @@ def combine_data_frames(self, dataFrame):
83110
metric_columns = list(dataFrame.columns)
84111
for column in metric_columns:
85112

86-
if type(dF.loc[0, column]) is numpy.float64 or type(dF.loc[0, column]) is numpy.int64:
113+
if isinstance(dF.loc[0, column], (numpy.float64, numpy.int64)):
87114
mean = dF[column].mean()
88-
else:
115+
else:
89116
column_list = dF[column].tolist()
90117
mean = ','.join(column_list)
91118
data2[column] = [mean]
92119
i += 1
93120
df2 = pd.DataFrame(data2)
94121

95122
result = pd.concat([df2, last_row], ignore_index=True)
96-
return result
123+
return result

pkg/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
JSON="json"
77
TEXT="text"
88
JUNIT="junit"
9-
CMR="cmr"
9+
CMR="cmr"

pkg/utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def process_test(
262262
if options["convert_tinyurl"]
263263
else buildUrls[uuid]
264264
)
265-
265+
266266
# pylint: disable = cell-var-from-loop
267267
)
268268
#save the dataframe
@@ -271,6 +271,15 @@ def process_test(
271271
return merged_df, metrics_config
272272

273273
def shorten_url(shortener: any, uuids: List[str]) -> str:
274+
"""Shorten url if there is a list of buildUrls
275+
276+
Args:
277+
shortener (any): shortener object to use tinyrl.short on
278+
uuids (List[str]): List of uuids to shorten
279+
280+
Returns:
281+
str: a combined string of shortened urls
282+
"""
274283
short_url_list = []
275284
for buildUrl in uuids.split(","):
276285
short_url_list.append(shortener.tinyurl.short(buildUrl))

0 commit comments

Comments
 (0)