AutoGPT/agbenchmark/start_benchmark.py

69 lines
2.2 KiB
Python
Raw Normal View History

import click
import pytest
import json
import os
@click.group()
def cli():
pass
@cli.command()
2023-06-22 12:18:22 +00:00
@click.option("--category", default=None, help="Specific category to run")
@click.option("--noreg", is_flag=True, help="Skip regression tests")
def start(category, noreg):
"""Start the benchmark tests. If a category flag is is provided, run the categories with that mark."""
"""Start the benchmark tests. If a category flag is provided, run the categories with that mark."""
config_file = "agbenchmark/config.json"
2023-06-22 12:18:22 +00:00
# Check if configuration file exists and is not empty
if not os.path.exists(config_file) or os.stat(config_file).st_size == 0:
config = {}
config["hostname"] = click.prompt(
2023-06-22 12:18:22 +00:00
"\nPlease enter a new hostname", default="localhost"
)
2023-06-22 12:18:22 +00:00
config["port"] = click.prompt("Please enter a new port", default=8080)
config["workspace"] = click.prompt(
2023-06-22 12:18:22 +00:00
"Please enter a new workspace path", default="/path/to/workspace"
)
2023-06-22 12:18:22 +00:00
with open(config_file, "w") as f:
json.dump(config, f)
2023-06-22 12:18:22 +00:00
else:
# If the configuration file exists and is not empty, load it
with open(config_file, "r") as f:
config = json.load(f)
2023-06-22 12:18:22 +00:00
print("Current configuration:")
for key, value in config.items():
print(f"{key}: {value}")
print("Starting benchmark tests...", category)
pytest_args = ["agbenchmark", "-vs"]
if category:
pytest_args.extend(
["-m", category]
) # run categorys that are of a specific marker
if noreg:
pytest_args.extend(
["-k", "not regression"]
) # run categorys that are of a specific marker but don't include regression categorys
print(f"Running {'non-regression' + category if noreg else category} categorys")
else:
2023-06-22 12:18:22 +00:00
if noreg:
print("Running all non-regression categorys")
pytest_args.extend(
["-k", "not regression"]
) # run categorys that are not regression categorys
else:
print("Running all categorys") # run all categorys
# Run pytest with the constructed arguments
pytest.main(pytest_args)
if __name__ == "__main__":
start()