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]
Fix: Using docker images from dockerhub (#85)
Kilian Lieret29cea49fce2c
diff --git a/sweagent/environment/swe_env.py b/sweagent/environment/swe_env.pyindex 8c2fa6fc..321732a9 100644--- a/sweagent/environment/swe_env.py+++ b/sweagent/environment/swe_env.py@@ -370,7 +370,11 @@ class SWEEnv(gym.Env):current_time = str(datetime.datetime.now())unique_string = current_time + process_idhash_object = hashlib.sha256(unique_string.encode())- self.container_name = f"{self.image_name}-{hash_object.hexdigest()[:10]}"+ # Cannot have colons/slashes in container name, but those are important in image names+ # i.e., when we want swe-agent to pull the image from dockerhub+ image_name_sanitized = self.image_name.replace("/", "-")+ image_name_sanitized = image_name_sanitized.replace(":", "-")+ self.container_name = f"{image_name_sanitized}-{hash_object.hexdigest()[:10]}"self.container, self.parent_pids = get_container(self.container_name, self.image_name, persistent=self.persistent)diff --git a/sweagent/environment/utils.py b/sweagent/environment/utils.pyindex daa29b20..031f3e32 100644--- a/sweagent/environment/utils.py+++ b/sweagent/environment/utils.py@@ -1,3 +1,4 @@+import shleximport dockerimport jsonimport logging@@ -170,6 +171,7 @@ def _get_non_persistent_container(ctr_name: str, image_name: str) -> Tuple[subpr"-l","-m",]+ logger.debug(f"Starting container with command: %s", shlex.join(startup_cmd))container = subprocess.Popen(startup_cmd,stdin=PIPE,@@ -225,6 +227,7 @@ def _get_persistent_container(ctr_name: str, image_name: str, persistent: bool ="-l","-m",]+ logger.debug(f"Starting container with command: %s", shlex.join(startup_cmd))container = subprocess.Popen(startup_cmd,stdin=PIPE,