Skip to content
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

Previous version comparison and baseline updates #86

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ Clone the current repository using git clone.
>> source venv/bin/activate
>> pip install -r requirements.txt
>> export ES_SERVER = <es_server_url>
>> export version=<ocp version>
>> pip install .
```
## Run Orion
Expand Down Expand Up @@ -198,10 +199,9 @@ POST http://127.0.0.1:8080/daemon/changepoint

- uuid (optional): The uuid of the run you want to compare with similar runs.
- baseline (optional): The runs you want to compare with.
- version (optional): The ocpVersion you want to use for metadata defaults to `4.15`
- filter_changepoints (optional): set to `true` if you only want changepoints to show up in the response
- test_name (optional): name of the test you want to perform defaults to `small-scale-cluster-density`

- previous-version (optional): Compare most recent run or given UUID with previous versions

Example
```
Expand Down
1 change: 1 addition & 0 deletions orion.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def cli(max_content_width=120): # pylint: disable=unused-argument
@click.option("--collapse", is_flag=True, help="Only outputs changepoints, previous and later runs in the xml format")
@click.option("--node-count", default=False, help="Match any node iterations count")
@click.option("--lookback-size", type=int, default=10000, help="Maximum number of entries to be looked back")
@click.option("--previous-version", is_flag=True, default=False, help="Match with previous version from metadata")
def cmd_analysis(**kwargs):
"""
Orion runs on command line mode, and helps in detecting regressions
Expand Down
50 changes: 31 additions & 19 deletions pkg/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,16 @@ def extract_metadata_from_test(test: Dict[str, Any]) -> Dict[Any, Any]:
dict: dictionary of the metadata
"""
logger_instance = SingletonLogger.getLogger("Orion")
metadata = test["metadata"]
metadata["ocpVersion"] = str(metadata["ocpVersion"])
if "metadata" in test:
metadata = test["metadata"]
if "ocpVersion" in metadata:
metadata["ocpVersion"] = str(metadata["ocpVersion"])
else:
metadata = test
logger_instance.debug("metadata" + str(metadata))
return metadata





def get_datasource(data: Dict[Any, Any]) -> str:
"""Gets es url from config or env

Expand Down Expand Up @@ -178,16 +179,12 @@ def filter_uuids_on_index(
ids = uuids
return ids


def get_build_urls(index: str, uuids: List[str], match: Matcher):
"""Gets metadata of the run from each test
to get the build url

Args:
uuids (list): str list of uuid to find build urls of
match: the fmatch instance


Returns:
dict: dictionary of the metadata
"""
Expand Down Expand Up @@ -218,23 +215,38 @@ def process_test(
logger.info("The test %s has started", test["name"])
fingerprint_index = test["index"]

# getting metadata
metadata = extract_metadata_from_test(test) if options["uuid"] in ("", None) else get_metadata_with_uuid(options["uuid"], match)
# get uuids, buildUrls matching with the metadata
runs = match.get_uuid_by_metadata(metadata, fingerprint_index, lookback_date=start_timestamp, lookback_size=options['lookback_size'])
uuids = [run["uuid"] for run in runs]
buildUrls = {run["uuid"]: run["buildUrl"] for run in runs}
# get uuids if there is a baseline
# get uuids if there is a baseline and uuid set
if options["baseline"] not in ("", None):
# if baseline is set, set uuids
uuids = [uuid for uuid in re.split(r" |,", options["baseline"]) if uuid]
uuids.append(options["uuid"])
buildUrls = get_build_urls(fingerprint_index, uuids, match)
elif not uuids:
runs = match.getResults("", uuids, fingerprint_index, {})
# get metadata of one run
metadata = get_metadata_with_uuid(options["uuid"], match)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if uuid is not specified in the options? We have a null check for this in the below code block but not here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if baseline is specified uuid has to be specified. Its required from the variable options

else:
# getting metadata
metadata = extract_metadata_from_test(test) if options["uuid"] in ("", None) else get_metadata_with_uuid(options["uuid"], match)
# get uuids, buildUrls matching with the metadata
# this match might not always work if UUID failed run, we still want to analyze
runs = match.get_uuid_by_metadata(metadata, fingerprint_index, lookback_date=start_timestamp, lookback_size=options['lookback_size'])

if options['previous_version']:
last_version_run = runs
metadata['ocpVersion'] = str(float(metadata['ocpVersion'][:4]) - .01)
runs = match.get_uuid_by_metadata(metadata, fingerprint_index, lookback_date=start_timestamp, lookback_size=options['lookback_size'])
if len(last_version_run) > 0:
# get latest uuid as the "uuid" to compare against
last_uuid_run = last_version_run[0]
runs.append(last_uuid_run)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we only appending one uuid from the current version? Do we plan to use this only in CMR? Can't we do all runs from previous version vs current version comparison?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any of the algorithms should work as this is just gathering the UUIDs before it performs hunter or cmr, etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the future, we can maybe add in an option of how many current UUIDs to add when comparing with the previous UUID data. For now I just put one so that we could compare and see if any large changes in data points


if not runs:
logger.info("No UUID present for given metadata")
return None, None

benchmark_index = test["benchmarkIndex"]

#Want to set uuid list right before usage
buildUrls = {run["uuid"]: run["buildUrl"] for run in runs}
uuids = [run["uuid"] for run in runs]
uuids = filter_uuids_on_index(
metadata, benchmark_index, uuids, match, options["baseline"], options['node_count']
)
Expand Down
6 changes: 6 additions & 0 deletions test.bats
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ setup() {
export version=$(echo "$LATEST_VERSION" | cut -d. -f1,2)
}


@test "orion cmd with previous version" {
run_cmd orion cmd --config "configs/small-scale-cluster-density.yaml" --previous-version
}


@test "orion cmd label small scale cluster density with hunter-analyze " {
run_cmd orion cmd --config "examples/label-small-scale-cluster-density.yaml" --lookback 5d --hunter-analyze
}
Expand Down
Loading