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

Feat: add lint frontend and lint all to Makefile. #1354

Merged
merged 4 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,21 @@ install-precommit-hooks:
@poetry run pre-commit install --config $(PRECOMMIT_CONFIG_PATH)
@echo "$(GREEN)Pre-commit hooks installed successfully.$(RESET)"

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

lint-frontend:
@echo "$(YELLOW)Running linters for frontend...$(RESET)"
@cd frontend && npm run lint

lint-all:
yimothysu marked this conversation as resolved.
Show resolved Hide resolved
@$(MAKE) -s lint-frontend
@$(MAKE) -s lint-backend

lint:
@$(MAKE) -s lint-all
yimothysu marked this conversation as resolved.
Show resolved Hide resolved

build-frontend:
@echo "$(YELLOW)Building frontend...$(RESET)"
@cd frontend && npm run build
Expand Down
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"preview": "vite preview",
"make-i18n": "node scripts/make-i18n-translations.cjs",
"prelint": "npm run make-i18n",
"lint": "eslint src/**/*.ts* && prettier --check src/**/*.ts*",
"lint": "eslint src --ext .ts,.tsx,.js && prettier --check src/**/*.{ts,tsx}",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Somewhat unrelated but do we want a lint-fix as well?

"prepare": "cd .. && husky install frontend/.husky"
},
"husky": {
Expand All @@ -50,7 +50,7 @@
}
},
"lint-staged": {
"src/**/*.ts*": [
"src/**/*.{ts,tsx,js}": [
"eslint --fix",
"prettier --write"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { I18nKey } from "#/i18n/declaration";
import { Autocomplete, AutocompleteItem, Tooltip } from "@nextui-org/react";
import React from "react";
import { useTranslation } from "react-i18next";
import { I18nKey } from "#/i18n/declaration";

type Label = "model" | "agent" | "language";

Expand Down
27 changes: 12 additions & 15 deletions opendevin/controller/action_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,20 @@ class ActionManager:

def __init__(
self,
sid: str,
sid: str = 'default',
):
sandbox_type = config.get(ConfigType.SANDBOX_TYPE).lower()
if sandbox_type == 'exec':
self.sandbox = DockerExecBox(
sid=(sid or 'default'),
)
elif sandbox_type == 'local':
self.sandbox = LocalBox()
elif sandbox_type == 'ssh':
self.sandbox = DockerSSHBox(
sid=(sid or 'default')
)
elif sandbox_type == 'e2b':
self.sandbox = E2BBox()
else:
raise ValueError(f'Invalid sandbox type: {sandbox_type}')
match sandbox_type:
case 'exec':
self.sandbox = DockerExecBox(sid=sid)
case 'ssh':
self.sandbox = DockerSSHBox(sid=sid)
case 'local':
self.sandbox = LocalBox()
case 'e2b':
self.sandbox = E2BBox()
case _:
raise ValueError(f'Invalid sandbox type: {sandbox_type}')

def init_sandbox_plugins(self, plugins: List[PluginRequirement]):
self.sandbox.init_plugins(plugins)
Expand Down
10 changes: 9 additions & 1 deletion opendevin/controller/agent_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,20 @@ class AgentController:
def __init__(
self,
agent: Agent,
inputs: dict = {},
sid: str = 'default',
max_iterations: int = MAX_ITERATIONS,
max_chars: int = MAX_CHARS,
callbacks: List[Callable] = [],
):
"""Initializes a new instance of the AgentController class.

Args:
agent: The agent instance to control.
sid: The session ID of the agent.
max_iterations: The maximum number of iterations the agent can run.
max_chars: The maximum number of characters the agent can output.
callbacks: A list of callback functions to run after each action.
"""
self.id = sid
self.agent = agent
self.max_iterations = max_iterations
Expand Down
2 changes: 1 addition & 1 deletion opendevin/sandbox/plugins/requirement.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ class PluginRequirement:
# FOLDER/FILES to be copied to the sandbox
host_src: str
sandbox_dest: str
# NOTE: bash_script_path shoulds be relative to the `sandbox_dest` path
# NOTE: bash_script_path should be relative to the `sandbox_dest` path
bash_script_path: str