Skip to content

Commit cd4c34e

Browse files
hunter integration and refactor
Signed-off-by: Shashank Reddy Boyapally <sboyapal@redhat.com>
1 parent d8f933b commit cd4c34e

File tree

6 files changed

+225
-113
lines changed

6 files changed

+225
-113
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,12 @@ Orion provides flexibility in configuring its behavior by allowing users to set
8484

8585
For enhanced troubleshooting and debugging, Orion supports the ```--debug``` flag, enabling the generation of detailed debug logs.
8686

87+
Activate Orion's regression detection tool for performance-scale CPT runs effortlessly with the ```--hunter-analyze``` command. This seamlessly integrates with metadata and hunter, ensuring a robust and efficient regression detection process.
88+
8789
Additionally, users can specify a custom path for the output CSV file using the ```--output``` flag, providing control over the location where the generated CSV will be stored.
8890

91+
92+
8993
Orion's seamless integration with metadata and hunter ensures a robust regression detection tool for perf-scale CPT runs.
9094

9195

orion.py

Lines changed: 20 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
import os
99

1010
import click
11-
import yaml
1211
import pandas as pd
12+
1313
from fmatch.matcher import Matcher
14+
from utils.orion_funcs import run_hunter_analyze, get_metadata, \
15+
set_logging, load_config, get_metric_data
1416

1517

1618
@click.group()
@@ -24,7 +26,8 @@ def cli():
2426
@click.option("--config", default="config.yaml", help="Path to the configuration file")
2527
@click.option("--output", default="output.csv", help="Path to save the output csv file")
2628
@click.option("--debug", is_flag=True, help="log level ")
27-
def orion(config, debug, output):
29+
@click.option("--hunter-analyze",is_flag=True, help="run hunter analyze")
30+
def orion(config, debug, output,hunter_analyze):
2831
"""Orion is the cli tool to detect regressions over the runs
2932
3033
Args:
@@ -35,25 +38,22 @@ def orion(config, debug, output):
3538
level = logging.DEBUG if debug else logging.INFO
3639
logger = logging.getLogger("Orion")
3740
logger = set_logging(level, logger)
41+
data = load_config(config,logger)
42+
ES_URL=None
43+
44+
if "ES_SERVER" in data.keys():
45+
ES_URL = data['ES_SERVER']
46+
else:
47+
if 'ES_SERVER' in os.environ:
48+
ES_URL=os.environ.get("ES_SERVER")
49+
else:
50+
logger.error("ES_SERVER environment variable/config variable not set")
51+
sys.exit(1)
3852

39-
if "ES_SERVER" not in os.environ:
40-
logger.error("ES_SERVER environment variable not set")
41-
sys.exit(1)
42-
43-
try:
44-
with open(config, "r", encoding="utf-8") as file:
45-
data = yaml.safe_load(file)
46-
logger.debug("The %s file has successfully loaded", config)
47-
except FileNotFoundError as e:
48-
logger.error("Config file not found: %s", e)
49-
sys.exit(1)
50-
except Exception as e: # pylint: disable=broad-exception-caught
51-
logger.error("An error occurred: %s", e)
52-
sys.exit(1)
5353
for test in data["tests"]:
5454
metadata = get_metadata(test, logger)
5555
logger.info("The test %s has started", test["name"])
56-
match = Matcher(index="perf_scale_ci", level=level)
56+
match = Matcher(index="perf_scale_ci", level=level, ES_URL=ES_URL)
5757
uuids = match.get_uuid_by_metadata(metadata)
5858
if len(uuids) == 0:
5959
print("No UUID present for given metadata")
@@ -77,103 +77,12 @@ def orion(config, debug, output):
7777
lambda left, right: pd.merge(left, right, on="uuid", how="inner"),
7878
dataframe_list,
7979
)
80-
match.save_results(merged_df, csv_file_path=output)
81-
82-
83-
def get_metric_data(ids, index, metrics, match, logger):
84-
"""Gets details metrics basked on metric yaml list
80+
match.save_results(merged_df, csv_file_path=output.split(".")[0]+"-"+test['name']+".csv")
8581

86-
Args:
87-
ids (list): list of all uuids
88-
index (dict): index in es of where to find data
89-
metrics (dict): metrics to gather data on
90-
match (Matcher): current matcher instance
91-
logger (logger): log data to one output
92-
93-
Returns:
94-
dataframe_list: dataframe of the all metrics
95-
"""
96-
dataframe_list = []
97-
for metric in metrics:
98-
metric_name = metric['name']
99-
logger.info("Collecting %s", metric_name)
100-
metric_of_interest = metric['metric_of_interest']
101-
102-
if "agg" in metric.keys():
103-
try:
104-
cpu = match.get_agg_metric_query(
105-
ids, index, metric
106-
)
107-
agg_value = metric['agg']['value']
108-
agg_type = metric['agg']['agg_type']
109-
agg_name = agg_value + "_" + agg_type
110-
cpu_df = match.convert_to_df(cpu, columns=["uuid", agg_name])
111-
cpu_df = cpu_df.rename(
112-
columns={agg_name: metric_name+ "_" + agg_name}
113-
)
114-
dataframe_list.append(cpu_df)
115-
logger.debug(cpu_df)
116-
117-
except Exception as e: # pylint: disable=broad-exception-caught
118-
logger.error(
119-
"Couldn't get agg metrics %s, exception %s",
120-
metric_name,
121-
e,
122-
)
123-
else:
124-
try:
125-
podl = match.getResults("", ids, index, metric)
126-
podl_df = match.convert_to_df(
127-
podl, columns=["uuid", "timestamp", metric_of_interest]
128-
)
129-
dataframe_list.append(podl_df)
130-
logger.debug(podl_df)
131-
except Exception as e: # pylint: disable=broad-exception-caught
132-
logger.error(
133-
"Couldn't get metrics %s, exception %s",
134-
metric_name,
135-
e,
136-
)
137-
return dataframe_list
138-
139-
def get_metadata(test,logger):
140-
"""Gets metadata of the run from each test
82+
if hunter_analyze:
83+
run_hunter_analyze(merged_df,test)
14184

142-
Args:
143-
test (dict): test dictionary
14485

145-
Returns:
146-
dict: dictionary of the metadata
147-
"""
148-
metadata = {}
149-
for k,v in test.items():
150-
if k in ["metrics","name"]:
151-
continue
152-
metadata[k] = v
153-
metadata["ocpVersion"] = str(metadata["ocpVersion"])
154-
logger.debug('metadata' + str(metadata))
155-
return metadata
156-
157-
158-
def set_logging(level, logger):
159-
"""sets log level and format
160-
161-
Args:
162-
level (_type_): level of the log
163-
logger (_type_): logger object
164-
165-
Returns:
166-
logging.Logger: a formatted and level set logger
167-
"""
168-
logger.setLevel(level)
169-
handler = logging.StreamHandler(sys.stdout)
170-
handler.setLevel(level)
171-
formatter = logging.Formatter(
172-
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
173-
)
174-
handler.setFormatter(formatter)
175-
logger.addHandler(handler)
176-
return logger
17786

17887

17988
if __name__ == "__main__":

requirements.txt

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,47 @@
1+
astroid==3.0.2
12
certifi==2023.11.17
3+
charset-normalizer==3.3.2
24
click==8.1.7
5+
dateparser==1.2.0
6+
DateTime==5.4
7+
decorator==5.1.1
8+
dill==0.3.7
39
elastic-transport==8.11.0
410
elasticsearch==8.11.1
511
elasticsearch7==7.13.0
12+
expandvars==0.6.5
13+
gevent==23.9.1
14+
greenlet==3.0.3
15+
hunter @ git+https://github.com/datastax-labs/hunter.git@8ff166979d000780ad548e49f006ef2a15d54123
16+
idna==3.6
17+
isort==5.13.2
18+
mccabe==0.7.0
19+
more-itertools==8.14.0
20+
numpy==1.24.0
621
fmatch==0.0.4
7-
numpy==1.26.3
822
pandas==2.1.4
23+
platformdirs==4.1.0
24+
pylint==3.0.3
25+
pystache==0.6.5
926
python-dateutil==2.8.2
1027
pytz==2023.3.post1
1128
PyYAML==6.0.1
29+
regex==2023.12.25
30+
requests==2.31.0
31+
ruamel.yaml==0.17.21
32+
ruamel.yaml.clib==0.2.8
33+
scipy==1.12.0
34+
signal-processing-algorithms==1.3.5
1235
six==1.16.0
36+
slack_sdk==3.26.2
37+
structlog==19.2.0
38+
tabulate==0.8.10
39+
tomlkit==0.12.3
40+
typed-ast==1.5.5
41+
typing-extensions==3.10.0.2
1342
tzdata==2023.4
43+
tzlocal==5.2
1444
urllib3==1.26.18
45+
validators==0.18.2
46+
zope.event==5.0
47+
zope.interface==6.1

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"""
33
setup.py for orion cli tool
44
"""
5-
from setuptools import setup
5+
from setuptools import setup, find_packages
66

77
setup(
88
name='orion',
@@ -17,6 +17,8 @@
1717
'orion = orion:orion',
1818
],
1919
},
20+
packages=find_packages(),
21+
package_data={'utils': ['utils.py'],'hunter': ['*.py']},
2022
classifiers=[
2123
'Programming Language :: Python :: 3',
2224
'License :: OSI Approved :: MIT License',

utils/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)