Skip to content

Commit

Permalink
display build URL for changepoint
Browse files Browse the repository at this point in the history
Signed-off-by: Shashank Reddy Boyapally <[email protected]>
  • Loading branch information
shashank-boyapally committed Feb 13, 2024
1 parent 8d7515f commit 7ba5c60
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 15 deletions.
54 changes: 39 additions & 15 deletions orion.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
This is the cli file for orion, tool to detect regressions using hunter
"""

# pylint: disable = import-error
import sys
from functools import reduce
Expand All @@ -11,8 +12,13 @@
import pandas as pd

from fmatch.matcher import Matcher
from utils.orion_funcs import run_hunter_analyze, get_metadata, \
set_logging, load_config, get_metric_data
from utils.orion_funcs import (
run_hunter_analyze,
get_metadata,
set_logging,
load_config,
get_metric_data,
)


@click.group()
Expand All @@ -21,13 +27,14 @@ def cli():
cli function to group commands
"""


# pylint: disable=too-many-locals
@click.command()
@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 ")
@click.option("--hunter-analyze",is_flag=True, help="run hunter analyze")
def orion(config, debug, output,hunter_analyze):
@click.option("--hunter-analyze", is_flag=True, help="run hunter analyze")
def orion(config, debug, output, hunter_analyze):
"""Orion is the cli tool to detect regressions over the runs
Args:
Expand All @@ -38,14 +45,14 @@ def orion(config, debug, output,hunter_analyze):
level = logging.DEBUG if debug else logging.INFO
logger = logging.getLogger("Orion")
logger = set_logging(level, logger)
data = load_config(config,logger)
ES_URL=None
data = load_config(config, logger)
ES_URL = None

if "ES_SERVER" in data.keys():
ES_URL = data['ES_SERVER']
ES_URL = data["ES_SERVER"]
else:
if 'ES_SERVER' in os.environ:
ES_URL=os.environ.get("ES_SERVER")
if "ES_SERVER" in os.environ:
ES_URL = os.environ.get("ES_SERVER")
else:
logger.error("ES_SERVER environment variable/config variable not set")
sys.exit(1)
Expand All @@ -59,10 +66,10 @@ def orion(config, debug, output,hunter_analyze):
print("No UUID present for given metadata")
sys.exit()

if metadata["benchmark"] == "k8s-netperf" :
if metadata["benchmark"] == "k8s-netperf":
index = "k8s-netperf"
ids = uuids
elif metadata["benchmark"] == "ingress-perf" :
elif metadata["benchmark"] == "ingress-perf":
index = "ingress-performance"
ids = uuids
else:
Expand All @@ -77,12 +84,29 @@ def orion(config, debug, output,hunter_analyze):
lambda left, right: pd.merge(left, right, on="uuid", how="inner"),
dataframe_list,
)
match.save_results(merged_df, csv_file_path=output.split(".")[0]+"-"+test['name']+".csv")
match.save_results(
merged_df, csv_file_path=output.split(".")[0] + "-" + test["name"] + ".csv"
)

if hunter_analyze:
run_hunter_analyze(merged_df,test)


change_points = run_hunter_analyze(merged_df, test)
change_uuids = []
for changepoint in change_points:
if changepoint.prev_attributes["uuid"] not in change_uuids:
change_uuids.append(changepoint.prev_attributes["uuid"])
if changepoint.attributes["uuid"] not in change_uuids:
change_uuids.append(changepoint.attributes["uuid"])
change_runs = [
(run, match.get_metadata_by_uuid(run)["buildUrl"])
for run in change_uuids
]
print("\n")
print(
"\n\n".join(
f"{run}=======>\033]8;;{buildUrl}\033\\click here for build URL\033]8;;\033\\"
for run, buildUrl in change_runs
)
)


if __name__ == "__main__":
Expand Down
1 change: 1 addition & 0 deletions utils/orion_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def run_hunter_analyze(merged_df,test):
report=Report(series,change_points)
output = report.produce_report(test_name="test",report_type=ReportType.LOG)
print(output)
return change_points

# pylint: disable=too-many-locals
def get_metric_data(ids, index, metrics, match, logger):
Expand Down

0 comments on commit 7ba5c60

Please sign in to comment.