SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]
Doc: Contrast persistent containers and cached task images (#544)
Kilian Lieretd9d9a9baa039
diff --git a/docs/usage/cl_tutorial.md b/docs/usage/cl_tutorial.mdindex 02599bd0..e73371b4 100644--- a/docs/usage/cl_tutorial.md+++ b/docs/usage/cl_tutorial.md@@ -80,7 +80,7 @@ SWE-agent will then start from this commit when trying to solve the problem.!!! warning "Uncommitted changes"When running with a local `--repo_path`, SWE-agent will use the last commit, i.e., all local, uncommitted changes will not be seen by SWE-agent.-## Installing dependencies and setting up the environment+## Installing dependencies and setting up the environment <a name="environment-setup"></a>Now let's move on to a slightly more complicated issue ([`swe-agent/test-repo #22`](https://github.com/SWE-agent/test-repo/issues/22)).@@ -120,11 +120,32 @@ The config file can have the following keys:## Speeding up SWE-agent!!! tip "Speed up in v0.6"- SWE-agent v0.6 saw major speedups. Please upgrade to the latest version.+ SWE-agent v0.6 (June 4th, 2024) introduced major speedups. Please upgrade to the latest version.-If you solve multiple issues from the same repository/in the same environment, you can specify the-`--cache_task_images` flag. This will create a persistent docker image with the initialized environment-required for the problem.+After the Docker container has been started, the target repository cloned/copied, and the dependencies installed,+almost all of the remaining runtime can be attributed to waiting for your LM provider to answer your API calls.++Therefore, speeding SWE-agent is mostly about speeding up the setup stages.+We currently offer two ways to cache the setup stages:++* By specifying `--container_name`, you run SWE-agent with a _persistent_ Docker container: Rather than being deleted+ after every task, the Docker container will only be paused and can be resumed. Cloned repositories from previous+ runs with the same container name, as well as any installed conda environments (versioned by the version of the package+ you are installing) will be already available.+* Alternatively, you can specify `--cache_task_images`. For every repository/base commit/environment setup, we+ [commit][docker commit] the changes from the installation stage to the Docker image. The corresponding containers are temporary as usual.+ Unlike the persistent containers, there will be a new image _for almost every base commit_ (that is, probabyl for every task+ when evaluating on a benchmark), which makes this only relevant when running over the same tasks more than once+ (for example when testing different agent configurations or LMs).++!!! tip "Confused about the two options?"+ Probably `--container_name my_container_name` will do what you want.++!!! note "What's the difference between Docker images and containers?"+ Docker containers are running instances of Docker images (that you can think of as snapshots of what+ happens after you build the `Dockerfile`). [More information](https://stackoverflow.com/a/26960888/).++[docker commit]: https://docs.docker.com/reference/cli/docker/container/commit/## Taking actionsdiff --git a/sweagent/environment/swe_env.py b/sweagent/environment/swe_env.pyindex bb2fda5a..50f53264 100644--- a/sweagent/environment/swe_env.py+++ b/sweagent/environment/swe_env.py@@ -71,7 +71,9 @@ class EnvironmentArguments(FrozenSerializable):# Specify a branch name or a commit hash to checkout before running the task.# Only used when running over a single problem statement/issue.base_commit: str | None = None- # Use a persistent container with this name+ # Use a persistent container with this name. After every task, the container will be paused, but not removed.+ # This is useful for speedup when running multiple tasks from the same repositories in a row, as the repositories+ # will have already been cloned and the conda environments will have been installed.container_name: str | None = None# Try to install the environment before running the task.install_environment: bool = True@@ -82,14 +84,14 @@ class EnvironmentArguments(FrozenSerializable):# Do not use attempt to use a repository mirror from https://github.com/swe-bench.no_mirror: bool = False# Cache task images to speed up task initialization. This means that the environment will be saved as a- # docker image for every repository and base commit combination. This uses quite a bit of disk space+ # docker image for every repository, base commit, and setup combination. This uses quite a bit of disk space# but speeds up task initialization significantly when running over multiple issues from the same repository# (or using different models for the same issues).cache_task_images: bool = False# Custom environment setup. Currently only used when data_path points to a single issue.# This needs to be either a string pointing to a yaml file (with yaml, yml file extension)# or a shell script (with sh extension).- # See https://github.com/princeton-nlp/SWE-agent/pull/153 for more information+ # See https://princeton-nlp.github.io/SWE-agent/usage/cl_tutorial#environment-setupenvironment_setup: str | None = None# Only used when running on single issue. Path to local repository or github repository.repo_path: str = ""