Skip to content
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

lint: simplify hooks already covered by Ruff #1204

Merged
merged 27 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6d926e1
lint: simplify hooks already covered by Ruff
Borda Apr 18, 2024
079c63c
prune dev dependency
Borda Apr 18, 2024
e01b397
setting E, W, F
Borda Apr 18, 2024
4356449
Merge branch 'main' into precommit/ruff
Borda Apr 18, 2024
e0e4230
Merge branch 'main' into precommit/ruff
Borda Apr 19, 2024
62a345e
poetry?
Borda Apr 22, 2024
b1d5266
autopep8
Borda Apr 22, 2024
92c761a
Merge branch 'precommit/ruff' of https://github.com/Borda/OpenDevin i…
Borda Apr 22, 2024
155e96a
quote-style = "single"
Borda Apr 22, 2024
6c8d1c8
Merge branch 'main' into precommit/ruff
Borda Apr 22, 2024
acc8974
Merge branch 'main' into precommit/ruff
Borda Apr 23, 2024
99bf33b
Merge branch 'main' into precommit/ruff
Borda Apr 23, 2024
11d7c0e
Merge branch 'main' into precommit/ruff
Borda Apr 24, 2024
b1c6718
double-quote-string-fixer
Borda Apr 25, 2024
fe72183
--all-files
Borda Apr 25, 2024
13d0676
Merge branch 'precommit/ruff' of https://github.com/Borda/OpenDevin i…
Borda Apr 25, 2024
0244713
apply
Borda Apr 25, 2024
5e0c7d4
Merge branch 'main' into precommit/ruff
Borda Apr 25, 2024
22244a7
Q
Borda Apr 25, 2024
f3b4733
drop double-quote-string-fixer
Borda Apr 25, 2024
068d7cd
--all-files
Borda Apr 25, 2024
e4dd6fd
Merge branch 'main' into precommit/ruff
rbren Apr 25, 2024
f7bdf4a
Merge branch 'main' into precommit/ruff
Borda Apr 25, 2024
042c954
apply pre-commit
Borda Apr 25, 2024
bd81951
Merge branch 'precommit/ruff' of https://github.com/Borda/OpenDevin i…
Borda Apr 25, 2024
bf26fb6
python3.11 -m poetry lock --no-update
Borda Apr 25, 2024
f8b6597
Merge branch 'main' into precommit/ruff
rbren Apr 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.ipynb linguist-vendored
*.ipynb linguist-vendored
6 changes: 5 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ jobs:
- name: Install pre-commit
run: pip install pre-commit==3.7.0
- name: Run pre-commit hooks
run: pre-commit run --files opendevin/**/* agenthub/**/* --show-diff-on-failure --config ./dev_config/python/.pre-commit-config.yaml
run: |
pre-commit run \
--all-files \
--show-diff-on-failure \
--config ./dev_config/python/.pre-commit-config.yaml
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ install-precommit-hooks:

lint:
@echo "$(YELLOW)Running linters...$(RESET)"
@poetry run pre-commit run --files opendevin/**/* agenthub/**/* --show-diff-on-failure --config $(PRECOMMIT_CONFIG_PATH)
@poetry run pre-commit run --all-files --show-diff-on-failure --config $(PRECOMMIT_CONFIG_PATH)

build-frontend:
@echo "$(YELLOW)Building frontend...$(RESET)"
Expand Down
4 changes: 2 additions & 2 deletions agenthub/SWE_agent/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@


def invalid_error(cmd, docs):
return f'''ERROR:
return f"""ERROR:
Invalid command structure for
```
{cmd}
Expand All @@ -30,7 +30,7 @@ def invalid_error(cmd, docs):

Try again using this format:
{COMMAND_USAGE[docs]}
'''
"""


def get_action_from_string(command_string: str, path: str, line: int, thoughts: str = '') -> Action | None:
Expand Down
32 changes: 16 additions & 16 deletions agenthub/SWE_agent/prompts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

DEFAULT_COMMANDS_DICT = {
'exit': 'Executed when task is complete',
'read <file_name> [<start_line>] [<end_line>]': 'Shows a given file\'s contents starting from <start_line> up to <end_line>. Default: start_line = 0, end_line = -1. By default the whole file will be read.',
'read <file_name> [<start_line>] [<end_line>]': "Shows a given file's contents starting from <start_line> up to <end_line>. Default: start_line = 0, end_line = -1. By default the whole file will be read.",
'write <file> <changes> [<start_line>] [<end_line>]': 'Modifies a <file> by replacing the current lines between <start_line> and <end_line> with <changes>. Default start_line = 0 and end_line = -1. Calling this with no line args will replace the whole file.',
'browse <url>': 'Returns the text version of any url, this can be useful to look up documentation or finding issues on github',
'scroll_up': 'Takes no arguments. This will scroll up and show you the 100 lines above your current lines',
Expand All @@ -16,7 +16,7 @@

COMMAND_USAGE = {
'exit': 'Usage:\n```\nexit\n```\nExecuted when task is complete',
'read': 'Args:\n<file_name> [<start_line>] [<end_line>]\nUsage:\n```\nread file.py\n```\nor\n```\nread example.py <start_line> <end_line>\n```\nShows a given file\'s contents starting from <start_line> up to <end_line>. Default: start_line = 0, end_line = -1. by default the whole file will be read.',
'read': "Args:\n<file_name> [<start_line>] [<end_line>]\nUsage:\n```\nread file.py\n```\nor\n```\nread example.py <start_line> <end_line>\n```\nShows a given file's contents starting from <start_line> up to <end_line>. Default: start_line = 0, end_line = -1. by default the whole file will be read.",
'write': 'Args:\n<file> <changes> [<start_line>] [<end_line>]\nUsage:\n```\nwrite "def main():\n print("This is line one")" 0 2\n```\nModifies a <file> by replacing the current lines between <start_line> and <end_line> with <changes>. Default start_line = 0 and end_line = -1. Calling this with no line args will replace the whole file.',
'edit': 'Args:\n<start_line> <end_line> <changes>\nUsage:\n```\nedit 0 1 import pandas as pd\n```\nThis will modify the current file you are in with the changes you make between the line numbers you designate',
'goto': 'Args:\n<line_num>\nUsage:\n```\ngoto <line_num>\n```\nThis will show you the 100 lines below and including the line you specify within your current file.',
Expand Down Expand Up @@ -52,7 +52,7 @@
when using write and edit do not surround the code with any "" just write the code.
"""

GENERAL_GUIDELINES = '''INSTRUCTIONS:
GENERAL_GUIDELINES = """INSTRUCTIONS:
Now, you're going to solve this issue on your own. You can use any bash commands or custom commands you wish to complete your task. Edit all the files you need to and run any checks or tests that you want.
Remember, YOU CAN ONLY ENTER ONE COMMAND AT A TIME. You should always wait for feedback after every command.
When you're satisfied with all of the changes you've made, you can indicate that you are done by running the exit command.
Expand All @@ -69,9 +69,9 @@
5. Understand your context: Always make sure to look at the currently open file and the current working directory. The currently open file might be in a different directory than the working directory.
6. Verify your edits: When editing files, it is easy to accidentally specify a wrong line number or to write code with incorrect indentation. Always check the code after you issue an edit to make sure that it reflects what you wanted to accomplish. If it didn't, issue another command to fix it.
7. Thoroughly test your solution: After making any changes to fix a bug, be sure to thoroughly test your solution to ensure the bug has been resolved. Re-run the bug reproduction script and verify that the issue has been addressed.
'''
"""

RESPONSE_FORMAT = '''RESPONSE FORMAT:
RESPONSE_FORMAT = """RESPONSE FORMAT:
This is the format of the response you will make in order to solve the current issue.
You will be given multiple iterations to complete this task so break it into steps and solve them one by one.

Expand Down Expand Up @@ -113,20 +113,20 @@
[ END FORMAT ]

Do not provide anything extra just your thought and action.
'''
"""

SYSTEM_MESSAGE = f'''SYSTEM INFO:
SYSTEM_MESSAGE = f"""SYSTEM INFO:
You am an autonomous coding agent, here to provide solutions for coding issues.
You have been designed to assist you with a wide range of programming tasks, from code editing and debugging to testing and deployment.
You have access to a variety of tools and commands that you can use to help you solve problems efficiently.

{GENERAL_GUIDELINES}

{DOCUMENTATION}
'''.strip()
""".strip()


def NO_ACTION(latest): return f'''
def NO_ACTION(latest): return f"""
You did not include any action to take in your most recent output:

===== Output ======
Expand All @@ -141,20 +141,20 @@ def NO_ACTION(latest): return f'''
{RESPONSE_FORMAT}

It is crucial you use the format provided as the output will be parsed automatically.
'''
"""


def file_info(file: str, line: int):
if file:
return f'''CURRENT WORKSPACE:
return f"""CURRENT WORKSPACE:
Open File: {file} on line {line}
You can use these commands with the current file:
Navigation: `scroll_up`, `scroll_down`, and `goto <line>`
Modification: `edit <start_line> <end_line> <changes>`
'''
"""


def STEP_PROMPT(task, file, line_num): return f'''
def STEP_PROMPT(task, file, line_num): return f"""
{RESPONSE_FORMAT}
You are currently trying to complete this task:
{task}
Expand All @@ -168,7 +168,7 @@ def STEP_PROMPT(task, file, line_num): return f'''
NEVER output multiple commands. ONLY take ONE STEP at a time.
When you have completed your task run the "exit" command.
Begin with your thought about the next step and then come up with an action to perform your thought.
'''.strip()
""".strip()


def unpack_dict(data: dict, restrict: list[str] = []):
Expand All @@ -185,13 +185,13 @@ def unpack_dict(data: dict, restrict: list[str] = []):
return '\n'.join(lines)


def MEMORY_FORMAT(act, obs): return f'''
def MEMORY_FORMAT(act, obs): return f"""
Previous Action:
{unpack_dict(act, ["content"])}

Output from Action:
{unpack_dict(obs)}
'''.strip()
""".strip()


def CONTEXT_PROMPT(memory, window):
Expand Down
4 changes: 2 additions & 2 deletions agenthub/planner_agent/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ def get_hint(latest_action_id: str) -> str:
""" Returns action type hint based on given action_id """

hints = {
'': 'You haven\'t taken any actions yet. Start by using `ls` to check out what files you\'re working with.',
'': "You haven't taken any actions yet. Start by using `ls` to check out what files you're working with.",
ActionType.RUN: 'You should think about the command you just ran, what output it gave, and how that affects your plan.',
ActionType.READ: 'You should think about the file you just read, what you learned from it, and how that affects your plan.',
ActionType.WRITE: 'You just changed a file. You should think about how it affects your plan.',
ActionType.BROWSE: 'You should think about the page you just visited, and what you learned from it.',
ActionType.THINK: 'Look at your last thought in the history above. What does it suggest? Don\'t think anymore--take action.',
ActionType.THINK: "Look at your last thought in the history above. What does it suggest? Don't think anymore--take action.",
ActionType.RECALL: 'You should think about the information you just recalled, and how it should affect your plan.',
ActionType.ADD_TASK: 'You should think about the next action to take.',
ActionType.MODIFY_TASK: 'You should think about the next action to take.',
Expand Down
13 changes: 0 additions & 13 deletions dev_config/python/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,6 @@ repos:
- id: check-yaml
- id: debug-statements

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
hooks:
- id: flake8
args: ['--select=Q000'] # Q000 is the error code for single quote enforcement
additional_dependencies:
- flake8-quotes

- repo: https://github.com/hhatto/autopep8
Borda marked this conversation as resolved.
Show resolved Hide resolved
rev: v2.1.0
hooks:
- id: autopep8

- repo: https://github.com/asottile/setup-cfg-fmt
rev: v2.5.0
hooks:
Expand Down
19 changes: 18 additions & 1 deletion dev_config/python/ruff.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
exclude = [
"agenthub/monologue_agent/regression/",
]
]

[lint]
select = [
"E",
"W",
"F",
"Q",
]

ignore = [
"E501",
]

flake8-quotes = {inline-quotes = "single"}

[format]
quote-style = "single"
2 changes: 1 addition & 1 deletion docs/architecture/Architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ This Overview is simplified to show the main components and their interactions.

*__Disclaimer__: The backend architecture is a work in progress and is subject to change. The following diagram shows the current architecture of the backend based on the commit that is shown in the footer of the diagram.*

![backend_architecture.svg](backend_architecture.svg)
![backend_architecture.svg](backend_architecture.svg)
7 changes: 3 additions & 4 deletions docs/architecture/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ The generation of the backend architecture diagram is partially automated. The d
- [py2puml](https://github.com/lucsorel/py2puml) installed

## Steps
1. Autogenerate the diagram by running the following command from the root of the repository:
1. Autogenerate the diagram by running the following command from the root of the repository:
```py2puml opendevin opendevin > docs/architecture/backend_architecture.puml```

2. Open the generated file in a PlantUML editor, e.g. Visual Studio Code with the PlantUML extension or [PlantText](https://www.planttext.com/)

3. Review the generated PUML and make all necessary adjustments to the diagram (add missing parts, fix mistakes, improve positioning).
3. Review the generated PUML and make all necessary adjustments to the diagram (add missing parts, fix mistakes, improve positioning).
*py2puml creates the diagram based on the type hints in the code, so missing or incorrect type hints may result in an incomplete or incorrect diagram.*

4. Review the diff between the new and the previous diagram and manually check if the changes are correct.
4. Review the diff between the new and the previous diagram and manually check if the changes are correct.
*Make sure not to remove parts that were manually added to the diagram in the past and are still relevant.*

4. Add the commit hash of the commit that was used to generate the diagram to the diagram footer.

5. Export the diagram as PNG and SVG files and replace the existing diagrams in the `docs/architecture` directory. This can be done with (e.g. [PlantText](https://www.planttext.com/))

2 changes: 1 addition & 1 deletion docs/architecture/backend_architecture.puml
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,4 @@ opendevin.controller.agent_controller.AgentController -> opendevin.controller.co
opendevin.controller.command_manager.CommandManager -> opendevin.sandbox.sandbox.DockerInteractive

footer Based on f3fda42; Generated by //py2puml//
@enduml
@enduml
2 changes: 1 addition & 1 deletion docs/architecture/backend_architecture.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions docs/architecture/system_architecture.puml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@


node frontend as frontend{

component App

package components{

component Terminal

component ChatInterface

component BannerSettings
Expand Down Expand Up @@ -37,8 +37,8 @@ node frontend as frontend{

Terminal -[hidden]u-> ChatInterface
ChatInterface -[hidden]u-> BannerSettings



interface "HTTP (:3001)" as HTTP
HTTP - App
Expand All @@ -50,13 +50,13 @@ node backend{
component Server

'defined in server/server.py, port is defined at startup with uvicorn
interface "Client WS\n(:3000/ws)" as client_socket
interface "Client WS\n(:3000/ws)" as client_socket
client_socket - Server


}
node AgentController{
node AgentController{

}
Server -d-> AgentController
}
Expand Down
Loading
Loading