Switch to Poetry (#378)

* create the pyproject file

* Fix the pyproject.toml file

* Update Makefile

* adapt makefile

* fix some execution issues

* Untrack lock files and wait for the backend to get start before frontend

* Remove LangChain dependencies

* Add github action for pytest

* add missing dependency

* rebase and fix the versions adding lock file

* add torch and pymupdfb deps

* some conflicts fixes

* Add dependencies evaluation group

* add poetry.lock

* Fix unexpected operator

---------

Co-authored-by: Robert Brennan <contact@rbren.io>
This commit is contained in:
Anas DORBANI 2024-04-05 00:27:29 +00:00 committed by GitHub
parent a0928ae590
commit 5ec0e5b7ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 6582 additions and 4892 deletions

17
.github/workflows/run-tests.yml vendored Normal file
View File

@ -0,0 +1,17 @@
name: Run Tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Run tests
run: |
make build
poetry run pytest ./tests

3
.gitignore vendored
View File

@ -100,7 +100,7 @@ ipython_config.py
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock
# poetry.lock
# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
@ -128,6 +128,7 @@ venv/
ENV/
env.bak/
venv.bak/
*venv/
# Spyder project settings
.spyderproject

View File

@ -8,6 +8,7 @@ FRONTEND_PORT = 3001
DEFAULT_WORKSPACE_DIR = "./workspace"
DEFAULT_MODEL = "gpt-4-0125-preview"
CONFIG_FILE = config.toml
PRECOMMIT_CONFIG_PATH = "./dev_config/python/.pre-commit-config.yaml"
# Build
build:
@ -15,8 +16,11 @@ build:
@echo "Pulling Docker image..."
@docker pull $(DOCKER_IMAGE)
@echo "Installing Python dependencies..."
@python -m pip install pipenv
@python -m pipenv install -v
@curl -sSL https://install.python-poetry.org | python3 -
@poetry install --without evaluation
@echo "Activating Poetry shell..."
@echo "Installing pre-commit hooks..."
@poetry run pre-commit install --config $(PRECOMMIT_CONFIG_PATH)
@echo "Setting up frontend environment..."
@echo "Detect Node.js version..."
@cd frontend && node ./scripts/detect-node-version.js
@ -30,7 +34,7 @@ build:
# Start backend
start-backend:
@echo "Starting backend..."
@python -m pipenv run uvicorn opendevin.server.listen:app --port $(BACKEND_PORT)
@poetry run uvicorn opendevin.server.listen:app --port $(BACKEND_PORT)
# Start frontend
start-frontend:
@ -40,15 +44,15 @@ start-frontend:
# Run the app
run:
@echo "Running the app..."
@if [ "$(OS)" == "Windows_NT" ]; then \
@if [ "$(OS)" = "Windows_NT" ]; then \
echo "`make run` is not supported on Windows. Please run `make start-frontend` and `make start-backend` separately."; \
exit 1; \
fi
@mkdir -p logs
@rm -f logs/pipe
@mkfifo logs/pipe
@cat logs/pipe | (make start-backend) &
@echo 'test' | tee logs/pipe | (make start-frontend)
@poetry run nohup uvicorn opendevin.server.listen:app --port $(BACKEND_PORT) > logs/backend_$(shell date +'%Y%m%d_%H%M%S').log 2>&1 &
@echo "Waiting for the backend to start..."
@until nc -z localhost $(BACKEND_PORT); do sleep 0.1; done
@cd frontend && npm run start -- --port $(FRONTEND_PORT)
# Setup config.toml
setup-config:

32
Pipfile
View File

@ -1,32 +0,0 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
datasets = "*"
pandas = "*"
litellm = "*"
termcolor = "*"
seaborn = "*"
docker = "*"
fastapi = "*"
uvicorn = {extras = ["standard"], version = "*"}
ruff = "*"
mypy = "*"
llama-index = "*"
llama-index-vector-stores-chroma = "*"
chromadb = "*"
llama-index-embeddings-huggingface = "*"
llama-index-embeddings-azure-openai = "*"
llama-index-embeddings-ollama = "*"
google-generativeai = "*"
toml = "*"
json_repair = "*"
numpy = "*"
playwright = "*"
[dev-packages]
[requires]
python_version = "3.11"

3854
Pipfile.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +0,0 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[[source]]
url = "https://download.pytorch.org/whl/cpu"
verify_ssl = true
name = "pytorch"
[packages]
torch = {version = "*", index = "pytorch"}
datasets = "*"
pandas = "*"
litellm = "*"
termcolor = "*"
seaborn = "*"
docker = "*"
fastapi = "*"
uvicorn = {extras = ["standard"], version = "*"}
ruff = "*"
mypy = "*"
llama-index = "*"
llama-index-vector-stores-chroma = "*"
chromadb = "*"
llama-index-embeddings-huggingface = "*"
llama-index-embeddings-azure-openai = "*"
llama-index-embeddings-ollama = "*"
google-generativeai = "*"
toml = "*"
json_repair = "*"
numpy = "*"
playwright = "*"
[dev-packages]
[requires]
python_version = "3.11"

View File

@ -8,4 +8,4 @@ warn_redundant_casts = True
no_implicit_optional = True
strict_optional = True
exclude = agenthub/monologue_agent/regression
exclude = agenthub/monologue_agent/regression

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
import os
import toml
import toml # type: ignore
from dotenv import load_dotenv
@ -34,12 +34,14 @@ for key, value in config.items():
config[key] = tomlConfig[key]
def _get(key: str, default):
value = config.get(key, default)
if not value:
value = os.environ.get(key, default)
return value
def get_or_error(key: str):
"""
Get a key from the config, or raise an error if it doesn't exist.
@ -49,12 +51,14 @@ def get_or_error(key: str):
raise KeyError(f"Please set '{key}' in `config.toml` or `.env`.")
return value
def get_or_default(key: str, default):
"""
Get a key from the config, or return a default value if it doesn't exist.
"""
return _get(key, default)
def get_or_none(key: str):
"""
Get a key from the config, or return None if it doesn't exist.

5814
poetry.lock generated Normal file

File diff suppressed because it is too large Load Diff

48
pyproject.toml Normal file
View File

@ -0,0 +1,48 @@
[tool.poetry]
name = "opendevin"
version = "0.1.0"
description = "OpenDevin: Code Less, Make More"
authors = ["OpenDevin"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/OpenDevin/OpenDevin"
[tool.poetry.dependencies]
python = "^3.11"
datasets = "*"
pandas = "*"
litellm = "*"
termcolor = "*"
seaborn = "*"
docker = "*"
fastapi = "*"
toml = "*"
uvicorn = "*"
types-toml = "*"
numpy = "*"
json-repair = "*"
playwright = "*"
[tool.poetry.group.llama-index.dependencies]
llama-index = "*"
llama-index-vector-stores-chroma = "*"
chromadb = "*"
llama-index-embeddings-huggingface = "*"
llama-index-embeddings-azure-openai = "*"
llama-index-embeddings-ollama = "*"
pymupdfb = "*"
[tool.poetry.group.dev.dependencies]
ruff = "*"
mypy = "*"
pre-commit = "*"
[tool.poetry.group.test.dependencies]
pytest = "*"
[tool.poetry.group.evaluation.dependencies]
torch = "*"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"