Skip to content
This repository has been archived by the owner on Sep 13, 2023. It is now read-only.

Commit

Permalink
Add agbenchmark routes + CI test
Browse files Browse the repository at this point in the history
Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com>
  • Loading branch information
waynehamadi committed Aug 17, 2023
1 parent d7dd3b2 commit 68a7148
Show file tree
Hide file tree
Showing 7 changed files with 366 additions and 313 deletions.
15 changes: 15 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[flake8]
max-line-length = 88
select = "E303, W293, W291, W292, E305, E231, E302"
exclude =
.tox,
__pycache__,
*.pyc,
.env
venv*/*,
.venv/*,
reports/*,
dist/*,
agent/*,
code,
agbenchmark/challenges/*
118 changes: 118 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: CI

on:
workflow_dispatch:
branches: [master]
schedule:
- cron: '0 8 * * *'
push:
branches: [master, ci-test*]
pull_request:
branches: [stable, master, release-*]

jobs:
lint:
runs-on: ubuntu-latest
env:
min-python-version: '3.10'

steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: true

- name: Set up Python ${{ env.min-python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.min-python-version }}

- id: get_date
name: Get date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python -
- name: Install dependencies
run: |
export POETRY_VIRTUALENVS_IN_PROJECT=true
poetry install -vvv
- name: Lint with flake8
run: poetry run flake8

- name: Check black formatting
run: poetry run black . --exclude test.py --check
if: success() || failure()

- name: Check isort formatting
run: poetry run isort . --check
if: success() || failure()

- name: Check mypy formatting
run: poetry run mypy --ignore-missing-imports .
if: success() || failure()

- name: Check for unused imports and pass statements
run: |
cmd="poetry run autoflake --remove-all-unused-imports --recursive --ignore-init-module-imports --ignore-pass-after-docstring agbenchmark"
$cmd --check || (echo "You have unused imports or pass statements, please run '${cmd} --in-place'" && exit 1)
if: success() || failure()

tests:
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
submodules: true
token: ${{ env.GH_TOKEN }}

- name: Setup Chrome and ChromeDriver
run: |
sudo apt-get update
sudo apt-get install -y wget
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt-get install -f
- name: Set up Python ${{ env.min-python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.min-python-version }}

- id: get_date
name: Get date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python -
- name: Install dependencies
run: |
poetry install -vvv
poetry build
- name: Run regression tests
run: |
sh run
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
AGENT_NAME: ${{ matrix.agent-name }}
HELICONE_API_KEY: ${{ secrets.HELICONE_API_KEY }}
REQUESTS_CA_BUNDLE: /etc/ssl/certs/ca-certificates.crt
HELICONE_CACHE_ENABLED: false
HELICONE_PROPERTY_AGENT: ${{ matrix.agent-name }}
REPORT_LOCATION: ${{ format('../../reports/{0}', matrix.agent-name) }}
6 changes: 4 additions & 2 deletions autogpt/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

from agent_protocol import Agent
from dotenv import load_dotenv

import autogpt.agent
import autogpt.db
from autogpt.benchmark_integration import add_benchmark_routes

if __name__ == "__main__":
"""Runs the agent server"""
load_dotenv()
router = add_benchmark_routes()

database_name = os.getenv("DATABASE_STRING")
print(database_name)
port = os.getenv("PORT")
Expand All @@ -19,4 +21,4 @@
agent = Agent.setup_agent(auto_gpt.task_handler, auto_gpt.step_handler)
agent.db = database
agent.workspace = workspace
agent.start(port=port)
agent.start(port=port, router=router)
29 changes: 29 additions & 0 deletions autogpt/benchmark_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
from pathlib import Path

from agent_protocol.agent import base_router
from fastapi.responses import FileResponse
from fastapi import (
HTTPException as FastAPIHTTPException, # Import HTTPException from FastAPI
)
from agbenchmark.app import get_artifact
from agbenchmark.app import get_skill_tree
from fastapi import APIRouter

def add_benchmark_routes():

new_router = APIRouter()

@new_router.get("/skill_tree")
async def get_skill_tree_endpoint() -> dict: # Renamed to avoid a clash with the function import
return get_skill_tree()

@new_router.get("/agent/challenges/{challenge_id}/artifacts/{artifact_id}")
async def get_artifact_endpoint(
challenge_id: str, artifact_id: str
) -> FileResponse: # Added return type annotation
return get_artifact(challenge_id, artifact_id)

# Include the new router in the base router
base_router.include_router(new_router)

return base_router
13 changes: 13 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[mypy]
namespace_packages = True
follow_imports = skip
check_untyped_defs = True
disallow_untyped_defs = True
exclude = ^(agbenchmark/challenges/|agent/|venv|venv-dev)
ignore_missing_imports = True

[mypy-agbenchmark.utils.data_types.*]
ignore_errors = True

[mypy-numpy.*]
ignore_errors = True
Loading

0 comments on commit 68a7148

Please sign in to comment.