From c7622969c23d69771b2652c28c449da03e6b6d2d Mon Sep 17 00:00:00 2001 From: John Yang Date: Mon, 8 Jul 2024 18:59:21 -0400 Subject: [PATCH] Rename `install` -> `specs` --- swebench/harness/test_spec.py | 46 +++++++++++++++++------------------ 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/swebench/harness/test_spec.py b/swebench/harness/test_spec.py index a73e4b55..93913916 100644 --- a/swebench/harness/test_spec.py +++ b/swebench/harness/test_spec.py @@ -112,7 +112,7 @@ def get_test_specs_from_dataset(dataset: Union[list[SWEbenchInstance], list[Test return list(map(make_test_spec, dataset)) -def make_repo_script_list(install, repo, repo_directory, base_commit, env_name): +def make_repo_script_list(specs, repo, repo_directory, base_commit, env_name): """ Create a list of bash commands to set up the repository for testing. This is the setup script for the instance image. @@ -133,16 +133,16 @@ def make_repo_script_list(install, repo, repo_directory, base_commit, env_name): setup_commands.append(MAP_REPO_TO_INSTALL[repo]) # Run pre-install set up if provided - if "pre_install" in install: - for pre_install in install["pre_install"]: + if "pre_install" in specs: + for pre_install in specs["pre_install"]: setup_commands.append(pre_install) - if "install" in install: - setup_commands.append(install["install"]) + if "install" in specs: + setup_commands.append(specs["install"]) return setup_commands -def make_env_script_list(instance, install, env_name): +def make_env_script_list(instance, specs, env_name): """ Creates the list of commands to set up the conda environment for testing. This is the setup script for the environment image. @@ -152,10 +152,10 @@ def make_env_script_list(instance, install, env_name): "source /opt/miniconda3/bin/activate", ] # Create conda environment according to install instructinos - pkgs = install.get("packages", "") + pkgs = specs.get("packages", "") if pkgs == "requirements.txt": # Create environment - cmd = f"conda create -n {env_name} python={install['python']} -y" + cmd = f"conda create -n {env_name} python={specs['python']} -y" reqs_commands.append(cmd) # Install dependencies @@ -174,9 +174,9 @@ def make_env_script_list(instance, install, env_name): reqs_commands.append( f"cat <<'{HEREDOC_DELIMITER}' > {path_to_reqs}\n{reqs}\n{HEREDOC_DELIMITER}" ) - if "no_use_env" in install and install["no_use_env"]: + if "no_use_env" in specs and specs["no_use_env"]: # `conda create` based installation - cmd = f"conda create -c conda-forge -n {env_name} python={install['python']} -y" + cmd = f"conda create -c conda-forge -n {env_name} python={specs['python']} -y" reqs_commands.append(cmd) # Install dependencies @@ -187,27 +187,27 @@ def make_env_script_list(instance, install, env_name): cmd = f"conda env create --file {path_to_reqs}" reqs_commands.append(cmd) - cmd = f"conda activate {env_name} && conda install python={install['python']} -y" + cmd = f"conda activate {env_name} && conda install python={specs['python']} -y" reqs_commands.append(cmd) # Remove environment.yml reqs_commands.append(f"rm {path_to_reqs}") else: # Create environment + install dependencies - cmd = f"conda create -n {env_name} python={install['python']} {pkgs} -y" + cmd = f"conda create -n {env_name} python={specs['python']} {pkgs} -y" reqs_commands.append(cmd) reqs_commands.append(f"conda activate {env_name}") # Install additional packages if specified - if "pip_packages" in install: - pip_packages = " ".join(install["pip_packages"]) + if "pip_packages" in specs: + pip_packages = " ".join(specs["pip_packages"]) cmd = f"python -m pip install {pip_packages}" reqs_commands.append(cmd) return reqs_commands -def make_eval_script_list(instance, install, env_name, repo_directory, base_commit, test_patch): +def make_eval_script_list(instance, specs, env_name, repo_directory, base_commit, test_patch): """ Applies the test patch and runs the tests. """ @@ -229,8 +229,8 @@ def make_eval_script_list(instance, install, env_name, repo_directory, base_comm f"conda activate {env_name}", f"cd {repo_directory}", ] - if "eval_commands" in install: - eval_commands += install["eval_commands"] + if "eval_commands" in specs: + eval_commands += specs["eval_commands"] eval_commands += [ f"git config --global --add safe.directory {repo_directory}", # for nonroot user f"cd {repo_directory}", @@ -241,8 +241,8 @@ def make_eval_script_list(instance, install, env_name, repo_directory, base_comm "source /opt/miniconda3/bin/activate", f"conda activate {env_name}", ] - if "install" in install: - eval_commands.append(install["install"]) + if "install" in specs: + eval_commands.append(specs["install"]) eval_commands += [ reset_tests_command, apply_test_patch_command, @@ -274,12 +274,12 @@ def _from_json_or_obj(key: str) -> Any: env_name = "testbed" repo_directory = f"/{env_name}" - install = MAP_REPO_VERSION_TO_SPECS[repo][version] + specs = MAP_REPO_VERSION_TO_SPECS[repo][version] - repo_script_list = make_repo_script_list(install, repo, repo_directory, base_commit, env_name) - env_script_list = make_env_script_list(instance, install, env_name) + repo_script_list = make_repo_script_list(specs, repo, repo_directory, base_commit, env_name) + env_script_list = make_env_script_list(instance, specs, env_name) eval_script_list = make_eval_script_list( - instance, install, env_name, repo_directory, base_commit, test_patch + instance, specs, env_name, repo_directory, base_commit, test_patch ) if platform.machine() in {"aarch64", "arm64"}: # use arm64 unless explicitly specified