From 86b4f5f66b83b0af59d1304b772f7d90c615b059 Mon Sep 17 00:00:00 2001 From: Benedikt Schesch Date: Sat, 25 May 2024 12:22:31 -0700 Subject: [PATCH] Added latest results --- .../combined/merges_analyzer_histograms.pdf | Bin 213437 -> 213437 bytes src/python/merge_runtime_measure.py | 3 +- src/python/merge_tester.py | 5 ++- src/python/repo.py | 36 ++++++++++++----- .../delete_intellimerge_keys_from_cache.py | 38 +++++++++++++----- test.sh | 9 +++++ 6 files changed, 69 insertions(+), 22 deletions(-) create mode 100755 test.sh diff --git a/results/combined/merges_analyzer_histograms.pdf b/results/combined/merges_analyzer_histograms.pdf index d44b2741b747decd8010e42c50e170fa9d6056a5..2cb4af5179d1114cde59ec44a26cbfd76214d784 100644 GIT binary patch delta 29 kcmdnn%)7Ulx1oixg=q^jlMTCxk+HF%k@ 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 ( diff --git a/src/python/repo.py b/src/python/repo.py index de65c00616..42ce1d603e 100755 --- a/src/python/repo.py +++ b/src/python/repo.py @@ -31,6 +31,8 @@ LEFT_BRANCH_NAME, RIGHT_BRANCH_NAME, DELETE_WORKDIRS, + N_TESTS, + TIMEOUT_MERGING, ) from loguru import logger @@ -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], @@ -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. @@ -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, @@ -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, @@ -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], @@ -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. @@ -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: @@ -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, diff --git a/src/python/utils/delete_intellimerge_keys_from_cache.py b/src/python/utils/delete_intellimerge_keys_from_cache.py index 341f8558ba..7ed818d0a3 100644 --- a/src/python/utils/delete_intellimerge_keys_from_cache.py +++ b/src/python/utils/delete_intellimerge_keys_from_cache.py @@ -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): @@ -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__": diff --git a/test.sh b/test.sh new file mode 100755 index 0000000000..2c26042d34 --- /dev/null +++ b/test.sh @@ -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