mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-17 22:14:28 +01:00
fixed multiple report folder bug
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
# radio charts, logs, helper functions for tests, anything else relevant.
|
||||
import datetime
|
||||
import os
|
||||
import re
|
||||
from pathlib import Path
|
||||
@@ -109,103 +110,6 @@ def get_highest_success_difficulty(
|
||||
return "No successful tests"
|
||||
|
||||
|
||||
def assign_paths(folder_path: Path) -> tuple[str, str, str, str, str]:
|
||||
CONFIG_PATH = str(folder_path / "config.json")
|
||||
|
||||
reports_location = folder_path / "reports"
|
||||
|
||||
# if the user has a locally defined challenges path that they've added tests to
|
||||
CHALLENGES_PATH = str(folder_path / "challenges")
|
||||
if not os.path.exists(CHALLENGES_PATH):
|
||||
CHALLENGES_PATH = str(Path(__file__).parent.parent / "challenges")
|
||||
|
||||
if not os.path.exists(reports_location):
|
||||
os.makedirs(reports_location)
|
||||
|
||||
# from the ci
|
||||
if REPORT_LOCATION:
|
||||
reports_location = Path.cwd() / REPORT_LOCATION
|
||||
|
||||
REPORTS_PATH = calculate_info_test_path(reports_location)
|
||||
|
||||
REGRESSION_TESTS_PATH = str(reports_location / "regression_tests.json")
|
||||
|
||||
SUCCESS_RATE_PATH = str(reports_location / "success_rate.json")
|
||||
|
||||
return (
|
||||
CONFIG_PATH,
|
||||
REGRESSION_TESTS_PATH,
|
||||
REPORTS_PATH,
|
||||
SUCCESS_RATE_PATH,
|
||||
CHALLENGES_PATH,
|
||||
)
|
||||
|
||||
|
||||
def calculate_dynamic_paths() -> tuple[Path, str, str, str, str, str]:
|
||||
# the default home is where you're running from
|
||||
HOME_DIRECTORY = Path(os.getcwd())
|
||||
|
||||
if os.path.join("Auto-GPT-Benchmarks", "backend") in str(
|
||||
HOME_DIRECTORY
|
||||
): # accounting for backend calls
|
||||
HOME_DIRECTORY = HOME_DIRECTORY.parent
|
||||
|
||||
benchmarks_folder_path = HOME_DIRECTORY / "agbenchmark"
|
||||
|
||||
if AGENT_NAME and not os.path.join("Auto-GPT-Benchmarks", "agent") in str(
|
||||
HOME_DIRECTORY
|
||||
):
|
||||
# if the agent name is defined but the run is not from the agent repo, then home is the agent repo
|
||||
# used for development of both a benchmark and an agent
|
||||
HOME_DIRECTORY = HOME_DIRECTORY / "agent" / AGENT_NAME
|
||||
benchmarks_folder_path = HOME_DIRECTORY / "agbenchmark"
|
||||
|
||||
(
|
||||
CONFIG_PATH,
|
||||
REGRESSION_TESTS_PATH,
|
||||
REPORTS_PATH,
|
||||
SUCCESS_RATE_PATH,
|
||||
CHALLENGES_PATH,
|
||||
) = assign_paths(benchmarks_folder_path)
|
||||
else:
|
||||
# otherwise the default is when home is an agent (running agbenchmark from agent/agent_repo)
|
||||
# used when its just a pip install
|
||||
(
|
||||
CONFIG_PATH,
|
||||
REGRESSION_TESTS_PATH,
|
||||
REPORTS_PATH,
|
||||
SUCCESS_RATE_PATH,
|
||||
CHALLENGES_PATH,
|
||||
) = assign_paths(benchmarks_folder_path)
|
||||
|
||||
if not benchmarks_folder_path.exists():
|
||||
benchmarks_folder_path.mkdir(exist_ok=True)
|
||||
|
||||
if not os.path.exists(benchmarks_folder_path / "reports"):
|
||||
os.makedirs(benchmarks_folder_path / "reports")
|
||||
|
||||
if not os.path.exists(REGRESSION_TESTS_PATH):
|
||||
with open(REGRESSION_TESTS_PATH, "w"):
|
||||
pass
|
||||
|
||||
if not os.path.exists(SUCCESS_RATE_PATH):
|
||||
with open(SUCCESS_RATE_PATH, "w"):
|
||||
pass
|
||||
|
||||
if not os.path.exists(Path(REPORTS_PATH) / "report.json"):
|
||||
with open(Path(REPORTS_PATH) / "report.json", "w"):
|
||||
pass
|
||||
|
||||
return (
|
||||
HOME_DIRECTORY,
|
||||
CONFIG_PATH,
|
||||
REGRESSION_TESTS_PATH,
|
||||
REPORTS_PATH,
|
||||
SUCCESS_RATE_PATH,
|
||||
CHALLENGES_PATH,
|
||||
)
|
||||
|
||||
|
||||
# def get_git_commit_sha(directory: Path) -> Optional[str]:
|
||||
# try:
|
||||
# repo = git.Repo(directory)
|
||||
|
||||
Reference in New Issue
Block a user