-
Notifications
You must be signed in to change notification settings - Fork 38
Adding SWE-Smith support #122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a800470
Add SWE-Smith
MarcCote 39624e3
Support loading local dataset file
MarcCote 550d918
Address comments + REfactor swe_bench.py and swe_smith.py
MarcCote 6341af9
Adding test for SWE-Smith and fix test for SWE-Bench. Add apply_gold_…
MarcCote 77763d0
Update unit tests + refactoring
MarcCote e2aef27
Also skip SWE-Smith unit tests on PR
MarcCote 5708bef
change log
xingdi-eric-yuan 3fc10f2
Update Readme and fix autograd
MarcCote c751555
Adding exclusion list for flaky instances.
MarcCote File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| include debug_gym/envs/configs/*.yaml | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| from debug_gym.agents.debug_agent import Debug_5_Agent, DebugAgent | ||
| from debug_gym.agents.rewrite_agent import RewriteAgent | ||
| from debug_gym.agents.solution_agent import AgentSolution |
MarcCote marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import subprocess | ||
|
|
||
| from debug_gym.agents.base_agent import BaseAgent, register_agent | ||
| from debug_gym.gym.envs.swe_bench import SWEBenchEnv | ||
| from debug_gym.gym.envs.swe_smith import SWESmithEnv | ||
| from debug_gym.gym.tools.tool import ToolCall | ||
|
|
||
|
|
||
| @register_agent | ||
| class AgentSolution(BaseAgent): | ||
| name: str = "solution_agent" | ||
|
|
||
| def run(self, task_name=None, debug=False): | ||
| self.history.reset() | ||
|
|
||
| info = self.env.reset(options={"task_name": task_name}) | ||
| self.history.step(info) | ||
|
|
||
| if info.done is True: | ||
| return True | ||
|
|
||
| self.logger.info( | ||
| f"Score: {info.score}/{info.max_score} ({info.score/info.max_score:.1%})" | ||
| ) | ||
|
|
||
| # Make a simple pdb call to make sure it is working. | ||
| action = ToolCall(name="pdb", id="pdb", arguments={"command": "help help"}) | ||
| pdb_help_info = self.env.step(action) | ||
| assert ( | ||
| "h(elp)" in pdb_help_info.step_observation.observation | ||
| ), f"PDB command did not return expected help message.\n{pdb_help_info.step_observation.observation}" | ||
|
|
||
| # Send a pdb continue command, and check the output matches the one from env.reset. | ||
| action = ToolCall(name="pdb", id="pdb", arguments={"command": "continue"}) | ||
| pdb_continue_info = self.env.step(action) | ||
|
|
||
| assert ( | ||
| "Reached the end of the program. Restarting the debugging session." | ||
| in pdb_continue_info.step_observation.observation | ||
| ) or ( | ||
| info.step_observation.observation.splitlines()[-1] | ||
| in pdb_continue_info.step_observation.observation | ||
| ), f"PDB command did not return expected continue message.\n{pdb_continue_info.step_observation.observation}" | ||
|
|
||
| try: | ||
| self.env.apply_gold_patch() | ||
| except NotImplementedError as e: | ||
| self.logger.error( | ||
| f"The environment {type(self.env)} is not compatible with SolutionAgent" | ||
| "Check the README.md to see which environments are compatible." | ||
| ) | ||
| raise | ||
|
|
||
| if debug: | ||
| breakpoint() | ||
|
|
||
| action = ToolCall(name="eval", id="eval", arguments={}) | ||
| info = self.env.step(action) | ||
|
|
||
| self.history.step(info) | ||
|
|
||
| self.logger.info( | ||
| f"Score: {info.score}/{info.max_score} ({info.score/info.max_score:.1%})" | ||
| ) | ||
| assert ( | ||
| info.done | ||
| ), f"The task is not done after applying the gold patch.\n{info.step_observation.observation}" | ||
|
|
||
| return info.done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.