Skip to content

Commit

Permalink
adding no match when uuid/baseline is set
Browse files Browse the repository at this point in the history
  • Loading branch information
paigerube14 committed Feb 13, 2024
1 parent 2bfb38a commit fa41f02
Showing 1 changed file with 99 additions and 8 deletions.
107 changes: 99 additions & 8 deletions orion.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ def cli():

# pylint: disable=too-many-locals
@click.command()
@click.option("--cmr", is_flag=True, help="Compare regression")
@click.option("--uuid", default="", help="UUID to use as base for comparisons")
@click.option("--baseline", default="", help="UUID to use as base for comparisons")
@click.option("--config", default="config.yaml", help="Path to the configuration file")
@click.option("--output", default="output.csv", help="Path to save the output csv file")
@click.option("--debug", is_flag=True, help="log level ")
def orion(uuid, baseline, config, debug, output):
def orion(cmr,uuid, baseline, config, debug, output):
"""Orion is the cli tool to detect regressions over the runs
Args:
Expand Down Expand Up @@ -77,16 +78,24 @@ def orion(uuid, baseline, config, debug, output):
ids = uuids
else:
index = "ripsaw-kube-burner"
runs = match.match_kube_burner(uuids)
ids = match.filter_runs(runs, runs)
if baseline == "":
runs = match.match_kube_burner(uuids)
ids = match.filter_runs(runs, runs)
else:
ids = uuids

metrics = test["metrics"]
dataframe_list = get_metric_data(ids, index, metrics, match, logger)

merged_df = reduce(
lambda left, right: pd.merge(left, right, on="uuid", how="inner"),
dataframe_list,
)
print('data frame list'+ str(dataframe_list))
if not cmr:
merged_df = reduce(
lambda left, right: pd.merge(left, right, on="uuid", how="inner"),
dataframe_list,
)
else:
# average all data points but last one
# combine data into 1 line per metric
merged_df = pd_merge(dataframe_list)
match.save_results(merged_df, csv_file_path=output)


Expand Down Expand Up @@ -195,6 +204,88 @@ def get_uuid_metadata(uuid, match):
return metadata


def pd_merge(dataframe_list):
"""
Merge the previous data frame with current data frame by last column
Args:
previous_data DataFrame: Previous data, dataframe
current_data DataFrame: Current data, dataframe
columns list[str]: Column titles
Returns:
DataFrame: Merged previous and current data frame
"""
#pd_merged = current_data.merge(previous_data, how="outer", on=columns[:-1])
for df in dataframe_list:
print('df ' + str((df)))

print('gropu ' + str(df.groupby("uuid")))
pd.merge(df, on=df.columns[-1], how="outer")
pd_merged = reduce(
lambda left, right: pd.merge(left, right, how="outer"),
dataframe_list,
)
print("pd merged" + str(pd_merged))
return pd_merged


def average_all_results(df):

df.mean()

def find_result(row, tolerancy):
"""
Find if row difference is higher or lower than given tolerancy
Fail if difference is more negative than tolerany and
if difference is higher than tolerancy
Args:
row: Row of data frame to give pass/fail value of difference
tolerancy: amount difference we want to pass/fail on
Returns:
Pass or Fail: if difference is greater than tolerancy
"""

print('row difference' + str(row['difference']))
print('tolerancy' + str(tolerancy))
# Fail if value is a more negative than tolerancy
if row["difference"] < 0 and tolerancy < abs(row["difference"]):
return "Fail"
elif row["difference"] > 0 and tolerancy < row["difference"]:
return "Fail"
else:
return "Pass"


def tolerancy(all_data_points, tolerancy_percent):
"""
Find the percent difference in last 2 columns of each row
Give this number as a percent change and generate pass/fail on value
Args:
all_data_points DataFrame: Data frame of all previous and current data points
tolerancy_percent int: number to determine pass/fail rate on
Returns:
DataFrame: All data points with percent difference and pass/fail column
"""
print("tolerancy " + str(all_data_points))
all_data_points.fillna(method="ffill")

result = all_data_points.iloc[:, [-2, -1]].pct_change(axis=1).iloc[:, 1] * 100

all_with_result = all_data_points.assign(difference=result)

all_with_result["result"] = all_with_result.apply(
lambda row: find_result(row, tolerancy_percent), axis=1
)

return all_with_result



def set_logging(level, logger):
"""sets log level and format
Expand Down

0 comments on commit fa41f02

Please sign in to comment.