From 19ea8c91e7459756c763c16f70081fbab5de2ece Mon Sep 17 00:00:00 2001 From: Benedikt Schesch <37979523+benedikt-schesch@users.noreply.github.com> Date: Fri, 7 Jun 2024 21:58:36 -0700 Subject: [PATCH] Make reproduction of results easier (#306) --- Makefile | 21 ++++++++++++--------- run.sh | 24 ++++++++++++++++++++---- src/python/test_repo_heads.py | 13 +------------ 3 files changed, 33 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index bdeb9571e4..5a407b2550 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,12 @@ compress-cache: if [ -f cache.tar.gz ]; then rm -f cache.tar.gz; fi tar --exclude="lock" -czf cache.tar.gz cache +# Compresses the cache without logs. +compress-cache-without-logs: + if [ ! -d cache ]; then echo "cache does not exist"; exit 1; fi + if [ -f cache_without_logs.tar.gz ]; then rm -f cache_without_logs.tar.gz; fi + tar --exclude="lock" --exclude="logs" -czf cache_without_logs.tar.gz cache + compress-small-cache: if [ ! -d cache-small ]; then echo "cache-small does not exist"; exit 1; fi if [ -f cache-small.tar ]; then rm -f cache-small.tar; fi @@ -72,6 +78,12 @@ decompress-cache: if [ -d cache ]; then echo "cache already exists"; exit 1; fi tar -xzf cache.tar.gz +# Decompresses the cache without logs. +decompress-cache-without-logs: + if [ ! -f cache_without_logs.tar.gz ]; then echo "cache_without_logs.tar.gz does not exist"; exit 1; fi + if [ -d cache ]; then echo "cache already exists"; exit 1; fi + tar -xzf cache_without_logs.tar.gz + decompress-small-cache: if [ ! -f cache-small.tar ]; then echo "cache-small.tar does not exist"; exit 1; fi if [ -d cache-small ]; then echo "cache-small already exists"; exit 1; fi @@ -166,12 +178,3 @@ tags: run: nice -n 5 sh run_full.sh | tee output.txt - -# Create a tarball of the artifacts for the paper. -# Keep this target last in the file. -create-artifacts: - rm -rf artifacts - git clone https://github.com/benedikt-schesch/AST-Merging-Evaluation.git artifacts - rm -rf artifacts/.git - sed -i '' 's/benedikt-schesch/anonymous-github-user/g' artifacts/README.md artifacts/Makefile - tar -czf artifacts.tar.gz artifacts diff --git a/run.sh b/run.sh index 82311ba3dd..6fcf56e7bc 100755 --- a/run.sh +++ b/run.sh @@ -97,10 +97,26 @@ git submodule update --init --recursive GIT_CONFIG_GLOBAL=$(pwd)/.gitconfig export GIT_CONFIG_GLOBAL -# Check if cache.tar exists and cache is missing -if [ -f cache.tar ] && [ ! -d cache ]; then - echo "Decompressing cache.tar" - # make decompress-cache +# Check if cache.tar.gz exists and cache is missing +if [ -f cache.tar.gz ] && [ ! -d cache ]; then + read -r -p "cache.tar.gz found and cache directory missing. Do you want to decompress? (y/n) " answer + if [ "$answer" = "y" ]; then + echo "Decompressing cache.tar.gz" + make decompress-cache + else + echo "Decompression aborted." + fi +fi + +# Check if cache_without_logs.tar.gz exists and cache is missing +if [ -f cache_without_logs.tar.gz ] && [ ! -d cache_without_logs ]; then + read -r -p "cache_without_logs.tar.gz found and cache_without_logs directory missing. Do you want to decompress? (y/n) " answer + if [ "$answer" = "y" ]; then + echo "Decompressing cache_without_logs.tar.gz" + make decompress-cache-without-logs + else + echo "Decompression aborted." + fi fi mvn -v | head -n 1 | cut -c 14-18 | grep -q 3.9. || { echo "Maven 3.9.* is required"; mvn -v; echo "PATH=$PATH"; exit 1; } diff --git a/src/python/test_repo_heads.py b/src/python/test_repo_heads.py index e750c05637..da31c897aa 100755 --- a/src/python/test_repo_heads.py +++ b/src/python/test_repo_heads.py @@ -89,18 +89,7 @@ def head_passes_tests(args: Tuple[pd.Series, Path]) -> pd.Series: test_state, _, repo_info["head tree fingerprint"] = repo.checkout_and_test( repo_info["head hash"], timeout=TIMEOUT_TESTING_PARENT, n_tests=3 ) - if test_state == TEST_STATE.Tests_passed: - # Make sure the repo is cloned and exists - repo.clone_repo() - if not repo.repo_path.exists(): - logger.error( - f"head_passes_tests: Repo {repo_slug} does not exist after passing tests." - ) - raise Exception( - f"Repo {repo_slug} does not exist after passing tests. \ - (Either clone the repo or remove the cache entry)" - ) - else: + if test_state != TEST_STATE.Tests_passed: shutil.rmtree(repo.repo_path, ignore_errors=True) repo_info["head test result"] = test_state.name