Skip to content

Commit

Permalink
readme and requirements update
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 Mar 28, 2024
1 parent 5f31cd6 commit 67c5a2d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 19 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,31 @@ The core purpose of Daemon mode is to operate Orion as a self-contained server,
```
>> orion daemon-mode
```
**Querying a Request to the Daemon Service**

To interact with the Daemon Service, you can send a POST request using `curl` with specific parameters. This allows you to submit a file along with additional information for processing.

*Request URL*

```
POST http://127.0.0.1:8000/daemon
```

*Parameters*

- uuid (optional): The uuid of the run you want to compare with similar runs.
- baseline (optional): The runs you want to compare.

*Request Body*

The request body should contain the file you want to submit for processing. Ensure that the file is in the proper format (e.g., YAML).

Example
```
curl -X POST 'http://127.0.0.1:8000/daemon?uuid=4cb3efec-609a-4ac5-985d-4cbbcbb11625' \
--form 'file=@"/path/to/your/config.yaml"'
```


Below is a sample output structure: the top level of the JSON contains the test name, while within each test, runs are organized into arrays. Each run includes succinct metadata alongside corresponding metrics for comprehensive analysis.
```
Expand Down
1 change: 1 addition & 0 deletions pkg/runTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ def run(**kwargs):
result, test, output=kwargs["output_format"], matcher=match
)
result_output[testname] = result_data
del match
return result_output
38 changes: 19 additions & 19 deletions pkg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ def get_metric_data(ids, index, metrics, match):
Returns:
dataframe_list: dataframe of the all metrics
"""
logger= SingletonLogger(debug=logging.INFO).logger
logger_instance= SingletonLogger(debug=logging.INFO).logger
dataframe_list = []
for metric in metrics:
metric_name = metric["name"]
logger.info("Collecting %s", metric_name)
logger_instance.info("Collecting %s", metric_name)
metric_of_interest = metric["metric_of_interest"]

if "agg" in metric.keys():
Expand All @@ -134,10 +134,10 @@ def get_metric_data(ids, index, metrics, match):
cpu_df = match.convert_to_df(cpu, columns=["uuid", agg_name])
cpu_df = cpu_df.rename(columns={agg_name: metric_name + "_" + agg_name})
dataframe_list.append(cpu_df)
logger.debug(cpu_df)
logger_instance.debug(cpu_df)

except Exception as e: # pylint: disable=broad-exception-caught
logger.error(
logger_instance.error(
"Couldn't get agg metrics %s, exception %s",
metric_name,
e,
Expand All @@ -149,9 +149,9 @@ def get_metric_data(ids, index, metrics, match):
podl, columns=["uuid", "timestamp", metric_of_interest]
)
dataframe_list.append(podl_df)
logger.debug(podl_df)
logger_instance.debug(podl_df)
except Exception as e: # pylint: disable=broad-exception-caught
logger.error(
logger_instance.error(
"Couldn't get metrics %s, exception %s",
metric_name,
e,
Expand All @@ -168,10 +168,10 @@ def get_metadata(test):
Returns:
dict: dictionary of the metadata
"""
logger= SingletonLogger(debug=logging.INFO).logger
logger_instance= SingletonLogger(debug=logging.INFO).logger
metadata = test["metadata"]
metadata["ocpVersion"] = str(metadata["ocpVersion"])
logger.debug("metadata" + str(metadata))
logger_instance.debug("metadata" + str(metadata))
return metadata


Expand All @@ -185,16 +185,16 @@ def load_config(config):
Returns:
dict: dictionary of the config file
"""
logger= SingletonLogger(debug=logging.INFO).logger
logger_instance= SingletonLogger(debug=logging.INFO).logger
try:
with open(config, "r", encoding="utf-8") as file:
data = yaml.safe_load(file)
logger.debug("The %s file has successfully loaded", config)
logger_instance.debug("The %s file has successfully loaded", config)
except FileNotFoundError as e:
logger.error("Config file not found: %s", e)
logger_instance.error("Config file not found: %s", e)
sys.exit(1)
except Exception as e: # pylint: disable=broad-exception-caught
logger.error("An error occurred: %s", e)
logger_instance.error("An error occurred: %s", e)
sys.exit(1)
return data

Expand All @@ -209,12 +209,12 @@ def get_es_url(data):
Returns:
str: es url
"""
logger= SingletonLogger(debug=logging.INFO).logger
logger_instance= SingletonLogger(debug=logging.INFO).logger
if "ES_SERVER" in data.keys():
return data["ES_SERVER"]
if "ES_SERVER" in os.environ:
return os.environ.get("ES_SERVER")
logger.error("ES_SERVER environment variable/config variable not set")
logger_instance.error("ES_SERVER environment variable/config variable not set")
sys.exit(1)


Expand Down Expand Up @@ -254,17 +254,17 @@ def process_test(test, match, output, uuid, baseline):
Returns:
_type_: merged dataframe
"""
logger= SingletonLogger(debug=logging.INFO).logger
logger_instance= SingletonLogger(debug=logging.INFO).logger
if uuid in ('', None):
metadata = get_metadata(test)
else:
metadata = filter_metadata(uuid,match)
logger.info("The test %s has started", test["name"])
logger_instance.info("The test %s has started", test["name"])
uuids = match.get_uuid_by_metadata(metadata)
if baseline in ('', None):
uuids = match.get_uuid_by_metadata(metadata)
if len(uuids) == 0:
logger.error("No UUID present for given metadata")
logger_instance.error("No UUID present for given metadata")
sys.exit()
else:
uuids = re.split(' |,',baseline)
Expand Down Expand Up @@ -294,7 +294,7 @@ def filter_metadata(uuid,match):
Returns:
dict: dictionary of the metadata
"""
logger= SingletonLogger(debug=logging.INFO).logger
logger_instance= SingletonLogger(debug=logging.INFO).logger
test = match.get_metadata_by_uuid(uuid)
metadata = {
'platform': '',
Expand Down Expand Up @@ -324,5 +324,5 @@ def filter_metadata(uuid,match):

#Remove any keys that have blank values
no_blank_meta = {k: v for k, v in metadata.items() if v}
logger.debug('No blank metadata dict: ' + str(no_blank_meta))
logger_instance.debug('No blank metadata dict: ' + str(no_blank_meta))
return no_blank_meta
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ tzdata==2023.4
urllib3==1.26.18
fastapi==0.110.0
python-multipart==0.0.9
uvicorn==0.28.0

0 comments on commit 67c5a2d

Please sign in to comment.