Spaces:
Running
Running
Commit ·
6b8d880
1
Parent(s): 0781876
fix: skip git checkout when base_commit is empty/HEAD — fixes clone error in HF Spaces
Browse files- api/tasks.py +1 -1
- sandbox/executor.py +12 -7
api/tasks.py
CHANGED
|
@@ -107,7 +107,7 @@ async def run_agent_task_async(
|
|
| 107 |
|
| 108 |
repo = request_data["repo"]
|
| 109 |
problem_statement = request_data["problem_statement"]
|
| 110 |
-
base_commit = request_data.get("base_commit"
|
| 111 |
fail_to_pass = request_data.get("fail_to_pass", [])
|
| 112 |
pass_to_pass = request_data.get("pass_to_pass", [])
|
| 113 |
max_attempts = request_data.get("max_attempts", 3)
|
|
|
|
| 107 |
|
| 108 |
repo = request_data["repo"]
|
| 109 |
problem_statement = request_data["problem_statement"]
|
| 110 |
+
base_commit = request_data.get("base_commit") or "HEAD"
|
| 111 |
fail_to_pass = request_data.get("fail_to_pass", [])
|
| 112 |
pass_to_pass = request_data.get("pass_to_pass", [])
|
| 113 |
max_attempts = request_data.get("max_attempts", 3)
|
sandbox/executor.py
CHANGED
|
@@ -154,7 +154,8 @@ class SandboxExecutor:
|
|
| 154 |
github_url = f"https://github.com/{repo}.git"
|
| 155 |
workspace_dir.mkdir(parents=True, exist_ok=True)
|
| 156 |
|
| 157 |
-
|
|
|
|
| 158 |
clone_result = self._run_local(
|
| 159 |
["git", "clone", "--depth=1", github_url, str(workspace_dir)],
|
| 160 |
timeout=120, # network operation — longer timeout
|
|
@@ -163,12 +164,16 @@ class SandboxExecutor:
|
|
| 163 |
logger.error("Clone failed: %s", clone_result.stderr[:500])
|
| 164 |
return clone_result
|
| 165 |
|
| 166 |
-
#
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 172 |
|
| 173 |
def apply_patch(
|
| 174 |
self,
|
|
|
|
| 154 |
github_url = f"https://github.com/{repo}.git"
|
| 155 |
workspace_dir.mkdir(parents=True, exist_ok=True)
|
| 156 |
|
| 157 |
+
commit_label = base_commit[:8] if base_commit and base_commit != "HEAD" else "HEAD"
|
| 158 |
+
logger.info("Cloning %s @ %s", repo, commit_label)
|
| 159 |
clone_result = self._run_local(
|
| 160 |
["git", "clone", "--depth=1", github_url, str(workspace_dir)],
|
| 161 |
timeout=120, # network operation — longer timeout
|
|
|
|
| 164 |
logger.error("Clone failed: %s", clone_result.stderr[:500])
|
| 165 |
return clone_result
|
| 166 |
|
| 167 |
+
# Only checkout a specific commit if one is explicitly provided
|
| 168 |
+
# (skip when empty string or HEAD — --depth=1 already checked out latest)
|
| 169 |
+
if base_commit and base_commit.strip() and base_commit.upper() != "HEAD":
|
| 170 |
+
checkout_result = self._run_local(
|
| 171 |
+
["git", "checkout", base_commit],
|
| 172 |
+
cwd=workspace_dir,
|
| 173 |
+
)
|
| 174 |
+
return checkout_result
|
| 175 |
+
|
| 176 |
+
return clone_result
|
| 177 |
|
| 178 |
def apply_patch(
|
| 179 |
self,
|