Skip to content

Commit c598081

Browse files
hunter integration and refactor (#11)
* hunter integration and refactor Signed-off-by: Shashank Reddy Boyapally <sboyapal@redhat.com> * updated version windows for requirements and updated pylint workflow Signed-off-by: Shashank Reddy Boyapally <sboyapal@redhat.com> * added compatibilty notes to Readme Signed-off-by: Shashank Reddy Boyapally <sboyapal@redhat.com> * reduced requirements.txt Signed-off-by: Shashank Reddy Boyapally <sboyapal@redhat.com> * pylinting only 3.11 Signed-off-by: Shashank Reddy Boyapally <sboyapal@redhat.com> --------- Signed-off-by: Shashank Reddy Boyapally <sboyapal@redhat.com>
1 parent d8f933b commit c598081

File tree

7 files changed

+200
-116
lines changed

7 files changed

+200
-116
lines changed

.github/workflows/pylint.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
runs-on: ubuntu-latest
88
strategy:
99
matrix:
10-
python-version: ["3.8", "3.9", "3.10", "3.11"]
10+
python-version: ["3.11"]
1111
steps:
1212
- uses: actions/checkout@v3
1313
- name: Set up Python ${{ matrix.python-version }}
@@ -18,6 +18,8 @@ jobs:
1818
run: |
1919
python -m pip install --upgrade pip
2020
pip install pylint
21+
pip install -r requirements.txt
22+
pip install .
2123
- name: Analysing the code with pylint
2224
run: |
2325
pylint -d C0103 $(git ls-files '*.py')

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ tests :
6363
## Build Orion
6464
Building Orion is a straightforward process. Follow these commands:
6565

66+
**Note: Orion Compatibility**
67+
68+
Orion currently supports Python versions `3.8.x`, `3.9.x`, `3.10.x`, and `3.11.x`. Please be aware that using other Python versions might lead to dependency conflicts caused by hunter, creating a challenging situation known as "dependency hell." It's crucial to highlight that Python `3.12.x` may result in errors due to the removal of distutils, a dependency used by numpy. This information is essential to ensure a smooth experience with Orion and avoid potential compatibility issues.
69+
6670
Clone the current repository using git clone.
6771

6872
```
@@ -84,8 +88,12 @@ Orion provides flexibility in configuring its behavior by allowing users to set
8488

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

91+
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.
92+
8793
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.
8894

95+
96+
8997
Orion's seamless integration with metadata and hunter ensures a robust regression detection tool for perf-scale CPT runs.
9098

9199

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: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1+
hunter @ git+https://github.com/datastax-labs/hunter.git@8ff166979d000780ad548e49f006ef2a15d54123
12
certifi==2023.11.17
23
click==8.1.7
34
elastic-transport==8.11.0
45
elasticsearch==8.11.1
56
elasticsearch7==7.13.0
67
fmatch==0.0.4
7-
numpy==1.26.3
8-
pandas==2.1.4
98
python-dateutil==2.8.2
109
pytz==2023.3.post1
1110
PyYAML==6.0.1
1211
six==1.16.0
1312
tzdata==2023.4
14-
urllib3==1.26.18
13+
urllib3==1.26.18

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)