mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Ad/fix pre commit (#807)
* Fix pre-commit config and some mypy issues * remove hook of requirements.txt
This commit is contained in:
parent
66cd9f9bd9
commit
d38113cead
10
Makefile
10
Makefile
@ -60,9 +60,6 @@ build:
|
||||
@curl -sSL https://install.python-poetry.org | python3 -
|
||||
@poetry install --without evaluation
|
||||
@echo "$(GREEN)Activating Poetry shell...$(RESET)"
|
||||
@echo "$(GREEN)Installing pre-commit hooks...$(RESET)"
|
||||
@git config --unset-all core.hooksPath || true
|
||||
@poetry run pre-commit install --config $(PRECOMMIT_CONFIG_PATH)
|
||||
@echo "$(GREEN)Setting up frontend environment...$(RESET)"
|
||||
@echo "$(YELLOW)Detect Node.js version...$(RESET)"
|
||||
@cd frontend && node ./scripts/detect-node-version.js
|
||||
@ -71,6 +68,9 @@ build:
|
||||
rm -rf node_modules; \
|
||||
fi
|
||||
@cd frontend && echo "$(BLUE)Enabling pnpm...$(RESET)" && corepack enable && echo "$(BLUE)Installing frontend dependencies with pnpm...$(RESET)" && pnpm install && echo "$(BLUE)Running make-i18n with pnpm...$(RESET)" && pnpm run make-i18n
|
||||
@echo "$(GREEN)Installing pre-commit hooks...$(RESET)"
|
||||
@git config --unset-all core.hooksPath || true
|
||||
@poetry run pre-commit install --config $(PRECOMMIT_CONFIG_PATH)
|
||||
@echo "$(GREEN)Build completed successfully.$(RESET)"
|
||||
|
||||
# Start backend
|
||||
@ -107,7 +107,7 @@ setup-config:
|
||||
|
||||
@read -p "Enter your LLM API key: " llm_api_key; \
|
||||
echo "LLM_API_KEY=\"$$llm_api_key\"" >> $(CONFIG_FILE).tmp
|
||||
|
||||
|
||||
@read -p "Enter your LLM Base URL [mostly used for local LLMs, leave blank if not needed - example: http://localhost:5001/v1/]: " llm_base_url; \
|
||||
if [[ ! -z "$$llm_base_url" ]]; then echo "LLM_BASE_URL=\"$$llm_base_url\"" >> $(CONFIG_FILE).tmp; fi
|
||||
|
||||
@ -148,4 +148,4 @@ help:
|
||||
@echo " $(GREEN)help$(RESET) - Display this help message, providing information on available targets."
|
||||
|
||||
# Phony targets
|
||||
.PHONY: build build-eval start-backend start-frontend run setup-config help
|
||||
.PHONY: build build-eval start-backend start-frontend run setup-config help
|
||||
|
||||
@ -7,7 +7,6 @@ repos:
|
||||
- id: check-yaml
|
||||
- id: debug-statements
|
||||
- id: double-quote-string-fixer
|
||||
- id: requirements-txt-fixer
|
||||
|
||||
- repo: https://github.com/hhatto/autopep8
|
||||
rev: v2.1.0
|
||||
@ -22,18 +21,24 @@ repos:
|
||||
pass_filenames: false
|
||||
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.3.3
|
||||
# Ruff version.
|
||||
rev: v0.3.5
|
||||
hooks:
|
||||
# Run the linter.
|
||||
- id: ruff
|
||||
entry: ruff check --config dev_config/python/ruff.toml opendevin/ agenthub/
|
||||
always_run: true
|
||||
pass_filenames: false
|
||||
types_or: [ python, pyi, jupyter ]
|
||||
args: [ --fix ]
|
||||
# Run the formatter.
|
||||
- id: ruff-format
|
||||
entry: ruff check --config dev_config/python/ruff.toml opendevin/ agenthub/
|
||||
types_or: [ python, pyi, jupyter ]
|
||||
|
||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||
rev: v1.9.0
|
||||
hooks:
|
||||
- id: mypy
|
||||
additional_dependencies: [types-requests, types-setuptools]
|
||||
additional_dependencies: [types-requests, types-setuptools, types-pyyaml, types-toml]
|
||||
entry: mypy --config-file dev_config/python/mypy.ini opendevin/ agenthub/
|
||||
always_run: true
|
||||
pass_filenames: false
|
||||
|
||||
@ -1,38 +1,37 @@
|
||||
import os
|
||||
import toml # type: ignore
|
||||
import toml
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
DEFAULT_CONFIG = {
|
||||
"LLM_API_KEY": None,
|
||||
"LLM_BASE_URL": None,
|
||||
"WORKSPACE_DIR": os.path.join(os.getcwd(), "workspace"),
|
||||
"LLM_MODEL": "gpt-4-0125-preview",
|
||||
"SANDBOX_CONTAINER_IMAGE": "ghcr.io/opendevin/sandbox",
|
||||
"RUN_AS_DEVIN": "false",
|
||||
"LLM_EMBEDDING_MODEL": "local",
|
||||
"LLM_NUM_RETRIES": 6,
|
||||
"LLM_COOLDOWN_TIME" : 1,
|
||||
"DIRECTORY_REWRITE" : "",
|
||||
"PROMPT_DEBUG_DIR": "",
|
||||
"MAX_ITERATIONS": 100,
|
||||
'LLM_API_KEY': None,
|
||||
'LLM_BASE_URL': None,
|
||||
'WORKSPACE_DIR': os.path.join(os.getcwd(), 'workspace'),
|
||||
'LLM_MODEL': 'gpt-4-0125-preview',
|
||||
'SANDBOX_CONTAINER_IMAGE': 'ghcr.io/opendevin/sandbox',
|
||||
'RUN_AS_DEVIN': 'false',
|
||||
'LLM_EMBEDDING_MODEL': 'local',
|
||||
'LLM_NUM_RETRIES': 6,
|
||||
'LLM_COOLDOWN_TIME': 1,
|
||||
'DIRECTORY_REWRITE': '',
|
||||
'PROMPT_DEBUG_DIR': '',
|
||||
'MAX_ITERATIONS': 100,
|
||||
}
|
||||
|
||||
config_str = ""
|
||||
if os.path.exists("config.toml"):
|
||||
with open("config.toml", "rb") as f:
|
||||
config_str = f.read().decode("utf-8")
|
||||
config_str = ''
|
||||
if os.path.exists('config.toml'):
|
||||
with open('config.toml', 'rb') as f:
|
||||
config_str = f.read().decode('utf-8')
|
||||
|
||||
tomlConfig = toml.loads(config_str)
|
||||
config = DEFAULT_CONFIG.copy()
|
||||
for key, value in config.items():
|
||||
if key in os.environ:
|
||||
config[key] = os.environ[key]
|
||||
elif key in tomlConfig:
|
||||
config[key] = tomlConfig[key]
|
||||
|
||||
if key in os.environ:
|
||||
config[key] = os.environ[key]
|
||||
elif key in tomlConfig:
|
||||
config[key] = tomlConfig[key]
|
||||
|
||||
|
||||
def _get(key: str, default):
|
||||
@ -65,6 +64,7 @@ def get_or_none(key: str):
|
||||
"""
|
||||
return _get(key, None)
|
||||
|
||||
|
||||
def get(key: str):
|
||||
"""
|
||||
Get a key from the config, please make sure it exists.
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
from opendevin.action import (
|
||||
action_from_dict,
|
||||
Action,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user