MCPcopy Create free account
hub / github.com/claw-bench/claw-bench / fix_workspace_export

Function fix_workspace_export

scripts/fix_task_bugs.py:174–200  ·  view source on GitHub ↗

Add 'export WORKSPACE' where it's used by embedded Python but not exported.

(apply: bool)

Source from the content-addressed store, hash-verified

172
173
174def fix_workspace_export(apply: bool):
175 """Add 'export WORKSPACE' where it's used by embedded Python but not exported."""
176 for sh_file in sorted(TASKS_ROOT.rglob("*.sh")):
177 content = sh_file.read_text()
178
179 if "WORKSPACE=" not in content:
180 continue
181 if "os.environ" not in content:
182 continue
183 if "export WORKSPACE" in content:
184 continue
185
186 task_name = sh_file.parent.parent.name if sh_file.parent.name in ("solution", "environment") else sh_file.parent.name
187
188 # Add export after WORKSPACE= assignment
189 new_content = re.sub(
190 r'(WORKSPACE=("[^"]*"|\$\{[^}]*\}|[^\s]*))\n',
191 r'\1\nexport WORKSPACE\n',
192 content,
193 count=1,
194 )
195
196 if new_content != content:
197 stats["export"] += 1
198 if apply:
199 sh_file.write_text(new_content)
200 print(f" [export] {task_name}: added export WORKSPACE in {sh_file.name}")
201
202
203def fix_fin006_hardcoded(apply: bool):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected