Skip to content

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]

Enh: Use uv for editable install by default (#547)

Kilian Lierete2da9227fc94
diff --git a/config/environment_setup/py310_default.yaml b/config/environment_setup/py310_default.yaml
index 4ba2790c..5888d1f8 100644
--- a/config/environment_setup/py310_default.yaml
+++ b/config/environment_setup/py310_default.yaml
@@ -1,2 +1,4 @@
python: '3.10'
-install: 'pip install -e .'
+# Use uv pip for speedup, but fallback to classic pip if we fail
+# Upgrade pip to avoid https://stackoverflow.com/a/73779542/
+install: 'uv pip install -e . || (python -m pip install --upgrade pip && python -m pip install -e .)'
diff --git a/docs/installation/source.md b/docs/installation/source.md
index b66062fe..7d4fbcd6 100644
--- a/docs/installation/source.md
+++ b/docs/installation/source.md
@@ -21,7 +21,7 @@ Installation from source is the preferred way to set up SWE-agent on your machin
```bash
docker pull sweagent/swe-agent:latest
```
-Alternatively, you can run `./setup.sh` to create your own `swe-agent` docker image.
+ Alternatively, you can run `./setup.sh` to create your own `swe-agent` docker image.
6. Set up your LM API keys as explained [here](keys.md).
[nodejs-install]: https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
@@ -33,7 +33,7 @@ Alternatively, you can run `./setup.sh` to create your own `swe-agent` docker im
SWE-agent is still in active development. Features and enhancement are added often.
To make sure you are on the latest version, periodically run `git pull`
(there is no need to redo the `pip install`).
- You might also want to run `docker pull sweagent/swe-agent:latest` periodically
+ You might also want to run `docker pull sweagent/swe-agent:latest` or `./setup.sh` periodically
(though changes to the container are more rare).
!!! note "Development setup"
diff --git a/docs/usage/cl_tutorial.md b/docs/usage/cl_tutorial.md
index e73371b4..6e113b63 100644
--- a/docs/usage/cl_tutorial.md
+++ b/docs/usage/cl_tutorial.md
@@ -103,10 +103,20 @@ Let's take a look at the config file
```yaml
python: '3.10'
-install: 'pip install -e .'
+install: 'uv pip install -e . || (python -m pip install --upgrade pip && python -m pip install -e .)'
```
-Here, `install` is an arbitrary command that is run, while `python` will be the python version that is setup with conda.
+Here, `install` is an arbitrary command that is run, while `python` will be the required python version.
+The default install command will create an [editable install][] of the python package.
+We first try to use [`uv pip`][uv] (a much faster implementation of `pip` in [rust][]), but fall back to "normal" pip if it fails.
+
+!!! tip "Editable installs"
+ Using [editable installs][editable install] is crucial for SWE-agent so that
+ changes to the package code take effect without having to reinstall the package.
+
+[editable install]: https://setuptools.pypa.io/en/latest/userguide/development_mode.html
+[uv]: https://pypi.org/project/uv/
+[rust]: https://www.rust-lang.org/
The config file can have the following keys:
@@ -121,6 +131,7 @@ The config file can have the following keys:
!!! tip "Speed up in v0.6"
SWE-agent v0.6 (June 4th, 2024) introduced major speedups. Please upgrade to the latest version.
+ To make use of [`uv pip`][uv], make sure that you have the latest `sweagent/swe-agent:latest` image.
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.
diff --git a/tests/test_env.py b/tests/test_env.py
index 74474b58..397d40cb 100644
--- a/tests/test_env.py
+++ b/tests/test_env.py
@@ -11,6 +11,7 @@ import pytest
import yaml
import docker
+from sweagent import CONFIG_DIR
from sweagent.environment.swe_env import EnvHook, EnvironmentArguments, SWEEnv
@@ -123,7 +124,18 @@ def test_execute_environment(tmp_path, test_env_args):
@pytest.mark.slow()
-def test_execute_environment_clone_python_uv(tmp_path, test_env_args):
+def test_execute_environment_default(test_env_args):
+ env_config_paths = (CONFIG_DIR / "environment_setup").iterdir()
+ assert env_config_paths
+ for env_config_path in env_config_paths:
+ print(env_config_path)
+ test_env_args = dataclasses.replace(test_env_args, environment_setup=env_config_path)
+ with swe_env_context(test_env_args) as env:
+ env.reset()
+
+
+def test_execute_environment_clone_python(tmp_path, test_env_args):
"""This should clone the existing python 3.10 conda environment for speedup"""
test_env = {
"python": "3.10",