AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
Add ability to run multiple tests (#5233)
merwanehamadib101fec16b29
diff --git a/autogpts/forge/run b/autogpts/forge/runindex 6de613b8f7..8fa7719634 100755--- a/autogpts/forge/run+++ b/autogpts/forge/run@@ -8,4 +8,5 @@ if [ ! -f .env ]; thenecho "Please add your api keys to the .env file."fipoetry run python -m forge &-poetry run agbenchmark serve &++agbenchmark serve & #voluntarily not using poetry run so that it runs in editable modediff --git a/benchmark/agbenchmark/__main__.py b/benchmark/agbenchmark/__main__.pyindex 494fae6c48..bff606f966 100644--- a/benchmark/agbenchmark/__main__.py+++ b/benchmark/agbenchmark/__main__.py@@ -114,8 +114,8 @@ def run_benchmark(no_dep: bool = False,nc: bool = False,keep_answers: bool = False,- category: Optional[list[str]] = None,- skip_category: Optional[list[str]] = None,+ category: Optional[tuple[str]] = None,+ skip_category: Optional[tuple[str]] = None,test: Optional[str] = None,cutoff: Optional[int] = None,server: bool = False,@@ -157,7 +157,6 @@ def run_benchmark(if test:print("Running specific test:", test)- pytest_args.extend(["-k", test, "--test"])else:# Categories that are used in the challengescategories = get_unique_categories()diff --git a/benchmark/agbenchmark/app.py b/benchmark/agbenchmark/app.pyindex 8bc526133a..0485528b48 100644--- a/benchmark/agbenchmark/app.py+++ b/benchmark/agbenchmark/app.py@@ -54,7 +54,18 @@ app.add_middleware(def run_single_test(body: CreateReportRequest) -> Any:from agbenchmark.__main__ import run_benchmark- run_benchmark(category=[body.category], mock=body.mock)+ # it's a hack because other parts of the code are using sys.argv+ sys.argv = [sys.argv[0]]+ sys.argv.append("start")+ if body.category:+ sys.argv.append(f"--category={body.category}")+ for body_test in body.tests:+ sys.argv.append(f"--test={body_test}")+ categories = None+ if body.category:+ categories = tuple([body.category])++ run_benchmark(category=categories, mock=body.mock, test=tuple(body.tests))import jsonfrom pathlib import Path@@ -95,6 +106,8 @@ from fastapi import FastAPI, Request, Response@app.get("/updates")def get_updates(request: Request) -> Any:+ from agbenchmark.__main__ import UPDATES_JSON_PATH+try:# Read data from the "update.json" file (provide the correct file path)with open(UPDATES_JSON_PATH, "r") as file:diff --git a/benchmark/agbenchmark/generate_test.py b/benchmark/agbenchmark/generate_test.pyindex 3018726c7c..bf2c3be24c 100644--- a/benchmark/agbenchmark/generate_test.py+++ b/benchmark/agbenchmark/generate_test.py@@ -192,8 +192,12 @@ def generate_tests() -> None: # sourcery skip: invert-any-allcontinue# --test flag, only run the test if it's the exact one specified- test_flag = "--test" in commands- if test_flag and data["name"] not in commands:+ tests = []+ for command in commands:+ if command.startswith("--test="):+ tests.append(command.split("=")[1])++ if tests and data["name"] not in tests:continue# --maintain and --improve flag