Skip to content

Commit

Permalink
Merge pull request #7 from shashank-boyapally/fmatch
Browse files Browse the repository at this point in the history
added login details to config
  • Loading branch information
shashank-boyapally authored Jan 15, 2024
2 parents 411ff71 + c01a7cc commit c0f55ab
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,5 @@ cython_debug/

.DS_Store
fmatch/main.py
*.csv
*.yaml
3 changes: 3 additions & 0 deletions fmatch/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""This file is the init file of the matcher package
which is used as to match and query data from elastic server"""
from fmatch.matcher import Matcher
11 changes: 8 additions & 3 deletions fmatch/matcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@
from elasticsearch.exceptions import NotFoundError
# pylint: disable=import-error
import pandas as pd
import yaml



ES_URL = os.getenv("ES_SERVER")

class Matcher:
""" Matcher
"""
def __init__(self, index="perf_scale_ci"):
def __init__(self, configpath="config.yaml", index="perf_scale_ci"):
self.index = index
self.es_url = ES_URL
with open(configpath, 'r',encoding='UTF-8') as file:
data = yaml.safe_load(file)
self.es = Elasticsearch([self.es_url], http_auth=[
"username", "password"])
data['username'], data['password']], timeout=30)
self.data = None

def get_metadata_by_uuid(self, uuid, index=None):
Expand Down Expand Up @@ -229,9 +234,9 @@ def convert_to_df(self, data, columns=None):
_type_: _description_
"""
odf = pd.json_normalize(data)
odf = odf.sort_values(by=['timestamp'])
if columns is not None:
odf = pd.DataFrame(odf, columns=columns)
odf = odf.sort_values(by=['timestamp'])
return odf

def save_results(self, df, csv_file_path="output.csv", columns=None):
Expand Down

0 comments on commit c0f55ab

Please sign in to comment.