-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Date filter, logging and types #26
Changes from all commits
d315a8a
9d805f0
4836266
d2fa1c0
c1f7f68
24a9497
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
name: Run pytest on Pull Request | ||
|
||
on: [push] | ||
on: | ||
push: | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
""" | ||
Logger as a common package | ||
""" | ||
|
||
import logging | ||
import sys | ||
|
||
|
||
class SingletonLogger: | ||
"""Singleton logger to set logging at one single place | ||
|
||
Returns: | ||
_type_: _description_ | ||
""" | ||
|
||
instance = {} | ||
|
||
def __new__(cls, debug: int, name: str): | ||
if (not cls.instance) or name not in cls.instance: | ||
cls.instance[name] = cls._initialize_logger(debug,name) | ||
return cls.instance[name] | ||
|
||
@staticmethod | ||
def _initialize_logger(debug: int, name: str) -> logging.Logger: | ||
level = debug # if debug else logging.INFO | ||
logger = logging.getLogger(name) | ||
logger.propagate=False | ||
if not logger.hasHandlers(): | ||
logger.setLevel(level) | ||
handler = logging.StreamHandler(sys.stdout) | ||
handler.setLevel(level) | ||
formatter = logging.Formatter( | ||
"%(asctime)s - %(name)-10s - %(levelname)s - file: %(filename)s - line: %(lineno)d - %(message)s" # pylint: disable = line-too-long | ||
) | ||
handler.setFormatter(formatter) | ||
logger.addHandler(handler) | ||
return logger | ||
|
||
@classmethod | ||
def getLogger(cls, name:str) -> logging.Logger: | ||
"""Return logger in instance | ||
|
||
Args: | ||
name (str): name of the logger | ||
|
||
Returns: | ||
logging.Logger: logger | ||
""" | ||
return cls.instance.get(name, None) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,35 +2,47 @@ | |
test_fmatch | ||
""" | ||
|
||
from datetime import datetime | ||
import sys | ||
import warnings | ||
# pylint: disable=import-error | ||
import pandas as pd | ||
|
||
# pylint: disable=import-error | ||
from matcher import Matcher | ||
|
||
match = Matcher(index="perf_scale_ci") | ||
res=match.get_metadata_by_uuid("b4afc724-f175-44d1-81ff-a8255fea034f",'perf_scale_ci') | ||
warnings.filterwarnings("ignore", message="Unverified HTTPS request.*") | ||
warnings.filterwarnings( | ||
"ignore", category=UserWarning, message=".*Connecting to.*verify_certs=False.*" | ||
) | ||
|
||
match = Matcher(index="perf_scale_ci*", verify_certs=False) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to change it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently this utility works on the qe instance... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope - as that would require having access to internal resources. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okay. Understood. |
||
res=match.get_metadata_by_uuid("b4afc724-f175-44d1-81ff-a8255fea034f",'perf_scale_ci*') | ||
|
||
meta = {} | ||
meta["masterNodesType"] = "m6a.xlarge" | ||
meta["workerNodesType"] = "m6a.xlarge" | ||
meta["platform"] = "AWS" | ||
meta["masterNodesCount"] = 3 | ||
meta["workerNodesCount"] = 24 | ||
meta["workerNodesCount"] = 6 | ||
meta["jobStatus"] = "success" | ||
meta["ocpVersion"] = "4.15" | ||
meta["ocpVersion"] = "4.17" | ||
meta["networkType"] = "OVNKubernetes" | ||
meta["benchmark.keyword"] = "cluster-density-v2" | ||
# meta['encrypted'] = "true" | ||
# meta['ipsec'] = "false" | ||
# meta['fips'] = "false" | ||
|
||
uuids = match.get_uuid_by_metadata(meta) | ||
print("All uuids",len(uuids)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these just debugs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yep this is just a utility for functionality testing. |
||
date= datetime.strptime("2024-07-01T13:46:24Z","%Y-%m-%dT%H:%M:%SZ") | ||
uuids2= match.get_uuid_by_metadata(meta,lookback_date=date) | ||
print("lookback uuids",len(uuids2)) | ||
uuids2 = match.get_uuid_by_metadata(meta) | ||
if len(uuids) == 0: | ||
print("No UUID present for given metadata") | ||
sys.exit() | ||
runs = match.match_kube_burner(uuids) | ||
runs = match.match_kube_burner(uuids,"ripsaw-kube-burner*") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here as well |
||
|
||
ids = match.filter_runs(runs, runs) | ||
podl_metrics = { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a singleton class here. It just as simple as updating a config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the suggestion. The thought behind this was as follows: having a logger setup in Matcher class created duplicate logs of the same log-output, especially in daemon mode where multiple Matcher objects would be created as when the request would come in and multiple formatters were being attached to the logger which led to duplicate logs. To mitigate this a temporary solution was to check if the logger existed previously. I transferred this logic to a class so that it can be used in Orion as well. The SingletonLogger here also updates the config using methods and also keeps track of only having a single logger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logging is singleton by default. All I am saying is, I think we need not write a custom logging class instead of just using the existing ones.