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: Allow to override tools dirs etc. (#1046)
Kilian Lieretd869a1accb93
diff --git a/docs/config/env.md b/docs/config/env.mdindex a82cbeda..8dc584ad 100644--- a/docs/config/env.md+++ b/docs/config/env.md@@ -3,9 +3,19 @@This page details all environment variables that are currently in use by SWE-agent.* All API keys (for LMs and GitHub) can be set as an environment variable. See [here](../installation/keys.md) for more information.-* `SWE_AGENT_CONFIG_ROOT`: Used to resolve relative paths in the [config](config.md)+* `SWE_AGENT_CONFIG_ROOT`: Used to resolve relative paths in the [config](config.md). E.g., if `SWE_AGENT_CONFIG_ROOT=/a/b/c` and you set+ add a tool bundle as `tools/my_bundle`, it will be resolved to `/a/b/c/tools/my_bundle`. The default of `SWE_AGENT_CONFIG_ROOT` is the+ the `swe-agent` package directory.-The following three variables can only be set as environment variables, not in the config file+The following variables can only be set as environment variables, not in the config file.++If you install `swe-agent` without the `--editable` option, please make sure to set++* `SWE_AGENT_CONFIG_DIR` (default `<PACKAGE>/config`)+* `SWE_AGENT_TOOLS_DIR` (default `<PACKAGE>/tools`)+* `SWE_AGENT_TRAJECTORY_DIR` (default `<PACKAGE>/trajectories`)++In addition, the following env variables allow to configure the logging.* `SWE_AGENT_LOG_TIME`: Add timestamps to log* `SWE_AGENT_LOG_STREAM_LEVEL`: Level of logging that is shown on the command line interface (`TRACE` being a custom level below `DEBUG`). Will have no effect for `run-batch`.diff --git a/sweagent/__init__.py b/sweagent/__init__.pyindex 7c430655..b14376db 100644--- a/sweagent/__init__.py+++ b/sweagent/__init__.py@@ -1,5 +1,6 @@from __future__ import annotations+import osimport sysfrom functools import partialfrom logging import WARNING, getLogger@@ -36,13 +37,13 @@ if sys.version_info < PYTHON_MINIMUM_VERSION:assert PACKAGE_DIR.is_dir(), PACKAGE_DIRREPO_ROOT = PACKAGE_DIR.parentassert REPO_ROOT.is_dir(), REPO_ROOT-CONFIG_DIR = PACKAGE_DIR.parent / "config"+CONFIG_DIR = Path(os.getenv("SWE_AGENT_CONFIG_DIR", PACKAGE_DIR.parent / "config"))assert CONFIG_DIR.is_dir(), CONFIG_DIR-TOOLS_DIR = PACKAGE_DIR.parent / "tools"+TOOLS_DIR = Path(os.getenv("SWE_AGENT_TOOLS_DIR", PACKAGE_DIR.parent / "tools"))assert TOOLS_DIR.is_dir(), TOOLS_DIR-TRAJECTORY_DIR = PACKAGE_DIR.parent / "trajectories"+TRAJECTORY_DIR = Path(os.getenv("SWE_AGENT_TRAJECTORY_DIR", PACKAGE_DIR.parent / "trajectories"))assert TRAJECTORY_DIR.is_dir(), TRAJECTORY_DIR