Skip to content

Commit

Permalink
Added latest results
Browse files Browse the repository at this point in the history
  • Loading branch information
benedikt-schesch committed May 25, 2024
1 parent 56fd0c2 commit 86b4f5f
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 22 deletions.
Binary file modified results/combined/merges_analyzer_histograms.pdf
Binary file not shown.
3 changes: 2 additions & 1 deletion src/python/merge_runtime_measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from cache_utils import lookup_in_cache, set_in_cache
import numpy as np
from loguru import logger
from variables import TIMEOUT_MERGING
from rich.progress import (
Progress,
SpinnerColumn,
Expand Down Expand Up @@ -101,7 +102,7 @@ def main():
tool=merge_tool,
left_commit=left_hash,
right_commit=right_hash,
timeout=0,
timeout=TIMEOUT_MERGING,
use_cache=False,
)
del repo
Expand Down
5 changes: 3 additions & 2 deletions src/python/merge_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import pandas as pd
from repo import Repository, MERGE_TOOL, TEST_STATE, MERGE_STATE
from test_repo_heads import num_processes
from variables import TIMEOUT_TESTING_MERGE, N_TESTS
from variables import TIMEOUT_TESTING_MERGE, TIMEOUT_MERGING, N_TESTS
from loguru import logger
from rich.progress import (
Progress,
Expand Down Expand Up @@ -74,7 +74,8 @@ def merge_tester(args: Tuple[str, pd.Series, Path]) -> pd.Series:
tool=merge_tool,
left_commit=merge_data["left"],
right_commit=merge_data["right"],
timeout=TIMEOUT_TESTING_MERGE,
timeout_test=TIMEOUT_TESTING_MERGE,
timeout_merge=TIMEOUT_MERGING,
n_tests=N_TESTS,
)
if result not in (
Expand Down
36 changes: 26 additions & 10 deletions src/python/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
LEFT_BRANCH_NAME,
RIGHT_BRANCH_NAME,
DELETE_WORKDIRS,
N_TESTS,
TIMEOUT_MERGING,
)
from loguru import logger

Expand Down Expand Up @@ -299,8 +301,9 @@ def _merge_and_test(
tool: MERGE_TOOL,
left_commit: str,
right_commit: str,
timeout: int, # in seconds
n_tests: int,
timeout_test: int,
timeout_merge: int = TIMEOUT_MERGING,
n_tests: int = N_TESTS,
) -> Tuple[
Union[TEST_STATE, MERGE_STATE],
Union[str, None],
Expand All @@ -314,7 +317,8 @@ def _merge_and_test(
tool (MERGE_TOOL): The tool to use.
left_commit (str): The left commit to merge.
right_commit (str): The right commit to merge.
timeout (int): The timeout limit, in seconds.
timeout_test (int): The timeout limit for the test, in seconds.
timeout_merge (int): The timeout limit for the merge, in seconds.
n_tests (int): The number of times to run the test.
Returns:
TEST_STATE: The result of the test.
Expand All @@ -330,7 +334,7 @@ def _merge_and_test(
right_fingerprint,
_,
_,
) = self.merge(tool, left_commit, right_commit, -1)
) = self.merge(tool, left_commit, right_commit, timeout_merge)
if merge_status != MERGE_STATE.Merge_success:
return (
merge_status,
Expand All @@ -339,7 +343,7 @@ def _merge_and_test(
right_fingerprint,
-1,
)
test_result, test_coverage = self.test(timeout, n_tests)
test_result, test_coverage = self.test(timeout_test, n_tests)
return (
test_result,
merge_fingerprint,
Expand All @@ -353,8 +357,9 @@ def merge_and_test(
tool: MERGE_TOOL,
left_commit: str,
right_commit: str,
timeout: int,
n_tests: int,
timeout_test: int,
timeout_merge: int = TIMEOUT_MERGING,
n_tests: int = N_TESTS,
) -> Tuple[
Union[TEST_STATE, MERGE_STATE],
Union[str, None],
Expand All @@ -368,7 +373,8 @@ def merge_and_test(
tool (MERGE_TOOL): The tool to use.
left_commit (str): The left commit to merge.
right_commit (str): The right commit to merge.
timeout (int): The timeout limit, in seconds.
timeout_test (int): The timeout limit for the test, in seconds.
timeout_merge (int): The timeout limit for the merge, in seconds.
n_tests (int): The number of times to run the test.
Returns:
TEST_STATE: The result of the test.
Expand All @@ -382,7 +388,12 @@ def merge_and_test(
)
if sha_cache_entry is None:
return self._merge_and_test(
tool, left_commit, right_commit, timeout, n_tests
tool=tool,
left_commit=left_commit,
right_commit=right_commit,
timeout_test=timeout_test,
timeout_merge=timeout_merge,
n_tests=n_tests,
)
merge_result = MERGE_STATE[sha_cache_entry["merge status"]]
if merge_result != MERGE_STATE.Merge_success:
Expand All @@ -396,7 +407,12 @@ def merge_and_test(
result, test_coverage = self.get_test_cache_entry(sha_cache_entry["sha"])
if result is None:
return self._merge_and_test(
tool, left_commit, right_commit, timeout, n_tests
tool=tool,
left_commit=left_commit,
right_commit=right_commit,
timeout_test=timeout_test,
timeout_merge=timeout_merge,
n_tests=n_tests,
)
return (
result,
Expand Down
38 changes: 29 additions & 9 deletions src/python/utils/delete_intellimerge_keys_from_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"""Delete the keys containing 'imports' in the JSON files in the given directory."""

import os
import sys
import json
from pathlib import Path
from argparse import ArgumentParser


def count_import_keys(directory):
Expand Down Expand Up @@ -47,15 +50,32 @@ def delete_import_keys(directory):

def main():
"""Main function."""
directory = "cache"
potential_deletions = count_import_keys(directory)
print(f"Potential deletions: {potential_deletions}")
confirm = input("Do you want to proceed with deleting these keys? (yes/no): ")
if confirm.lower() == "yes":
total_deleted = delete_import_keys(directory)
print(f"Total keys deleted: {total_deleted}")
else:
print("Operation cancelled.")
parser = ArgumentParser()
parser.add_argument(
"--cache",
type=str,
default="cache_small",
help="The cache directory to delete keys from.",
)
parser.add_argument(
"-y", "--yes", action="store_true", help="Skip the confirmation prompt."
)
args = parser.parse_args()
cache_dir = Path(args.cache)
if not cache_dir.exists():
print(f"Directory '{cache_dir}' does not exist.")
return

if not args.yes:
potential_deletions = count_import_keys(args.cache)
print(f"Potential deletions: {potential_deletions}")
confirm = input("Do you want to proceed with deleting these keys? (yes/no): ")
if confirm.lower() != "yes":
print("Operation cancelled.")
sys.exit(0)

total_deleted = delete_import_keys(args.cache)
print(f"Total keys deleted: {total_deleted}")


if __name__ == "__main__":
Expand Down
9 changes: 9 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

rm -rf replay_output .workdir run_small_output
python3 src/python/utils/delete_intellimerge_keys_from_cache.py --cache cache-small/sha_cache_entry/mangstadt --yes
./run_small.sh --include_trivial_merges --no_timing
cp -r .workdir/mangstadt/ez-vcard/merge-tester-intellimerge-ea6026ee62cc184db68d841d50d58474fcdf4862-ab2032ca9769d452d4906f51cf56ca7d983a27c4 run_small_output
python3 src/python/replay_merge.py --merges_csv results/small/result.csv --idx 1-7
cp -r .workdir/mangstadt/ez-vcard-merge-replay-intellimerge-ea6026ee62cc184db68d841d50d58474fcdf4862-ab2032ca9769d452d4906f51cf56ca7d983a27c4 replay_output
rm -rf .workdir

0 comments on commit 86b4f5f

Please sign in to comment.