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.
Get rid of get file path by using the data.json convention to store the challenge information (#67)
merwanehamadie61523e59ed1
diff --git a/agbenchmark/README.md b/agbenchmark/README.mdindex a478f83f31..01f602dc62 100644--- a/agbenchmark/README.md+++ b/agbenchmark/README.md@@ -53,9 +53,6 @@ import osclass TestWriteFile(BasicChallenge):"""Testing if LLM can write to a file"""- def get_file_path(self) -> str: # all tests must implement this method- return os.path.join(os.path.dirname(__file__), "w_file_data.json")-@pytest.mark.depends(on=[], name="basic_write_file")def test_method(self, workspace):# implement scoring logic by looking at workspacediff --git a/agbenchmark/challenge.py b/agbenchmark/challenge.pyindex 4c8e698481..29bc3ff917 100644--- a/agbenchmark/challenge.py+++ b/agbenchmark/challenge.py@@ -3,7 +3,7 @@ import inspectimport osimport subprocessimport types-from abc import ABC, ABCMeta, abstractmethod+from abc import ABC, ABCMetafrom typing import Any, Dict, List, Optional, Tuple, Type, castimport pytest@@ -35,20 +35,12 @@ class Challenge(ABC, metaclass=ChallengeMeta):Defines helper methods for running a challenge"""_data_cache: Dict[str, ChallengeData] = {}-- @abstractmethod- def get_file_path(self) -> str:- """This should be implemented by any class which inherits from BasicChallenge"""- pass+ CHALLENGE_LOCATION: str@propertydef data(self) -> ChallengeData:- "Check if the data is already loaded, if not load it"- file_path = (- self.get_file_path()- ) # file_path serves as the key in the cache dictionary- if file_path not in Challenge._data_cache:- Challenge._data_cache[file_path] = ChallengeData.deserialize(file_path)+ file_path = f"{self.CHALLENGE_LOCATION}/data.json"+ Challenge._data_cache[file_path] = ChallengeData.deserialize(file_path)return Challenge._data_cache[file_path]@propertydiff --git a/agbenchmark/challenges/code/d1/debug_simple_typo_with_guidance_data.json b/agbenchmark/challenges/code/d1/data.jsonsimilarity index 100%rename from agbenchmark/challenges/code/d1/debug_simple_typo_with_guidance_data.jsonrename to agbenchmark/challenges/code/d1/data.jsondiff --git a/agbenchmark/challenges/code/d1/debug_simple_typo_with_guidance_test.py b/agbenchmark/challenges/code/d1/debug_simple_typo_with_guidance_test.pyindex e5f50c700b..16a12ae414 100644--- a/agbenchmark/challenges/code/d1/debug_simple_typo_with_guidance_test.py+++ b/agbenchmark/challenges/code/d1/debug_simple_typo_with_guidance_test.py@@ -1,4 +1,3 @@-import osfrom typing import Any, Dictimport pytest@@ -9,11 +8,6 @@ from agbenchmark.challenges.code.code import CodeChallengeclass TestDebugSimpleTypoWithGuidance(CodeChallenge):"""The first memory challenge"""- def get_file_path(self) -> str: # all tests must implement this method- return os.path.join(- os.path.dirname(__file__), "debug_simple_typo_with_guidance_data.json"- )-@pytest.mark.depends(name="test_debug_simple_typo_with_guidance")def test_method(self, config: Dict[str, Any]) -> None:self.setup_challenge(config)diff --git a/agbenchmark/challenges/code/d2/d2_test.py b/agbenchmark/challenges/code/d2/d2_test.pyindex d49f9dfe9d..7a5988b946 100644--- a/agbenchmark/challenges/code/d2/d2_test.py+++ b/agbenchmark/challenges/code/d2/d2_test.py@@ -1,4 +1,3 @@-import osfrom typing import Any, Dictimport pytest@@ -9,9 +8,6 @@ from agbenchmark.challenges.code.code import CodeChallengeclass TestDebugSimpleTypoWithoutGuidance(CodeChallenge):"""The first memory challenge"""- def get_file_path(self) -> str: # all tests must implement this method- return os.path.join(os.path.dirname(__file__), "d2_data.json")-@pytest.mark.depends(name="test_debug_simple_typo_without_guidance",depends=["test_debug_simple_typo_with_guidance"],diff --git a/agbenchmark/challenges/code/d2/d2_data.json b/agbenchmark/challenges/code/d2/data.jsonsimilarity index 100%rename from agbenchmark/challenges/code/d2/d2_data.jsonrename to agbenchmark/challenges/code/d2/data.jsondiff --git a/agbenchmark/challenges/memory/m1/m1_data.json b/agbenchmark/challenges/memory/m1/data.jsonsimilarity index 100%rename from agbenchmark/challenges/memory/m1/m1_data.jsonrename to agbenchmark/challenges/memory/m1/data.jsondiff --git a/agbenchmark/challenges/memory/m1/m1_test.py b/agbenchmark/challenges/memory/m1/m1_test.pyindex c1f3702447..9e5e0a775a 100644--- a/agbenchmark/challenges/memory/m1/m1_test.py+++ b/agbenchmark/challenges/memory/m1/m1_test.py@@ -1,4 +1,3 @@-import osfrom typing import Any, Dictimport pytest@@ -9,9 +8,6 @@ from agbenchmark.challenges.memory.memory import MemoryChallengeclass TestBasicMemory(MemoryChallenge):"""The first memory challenge"""- def get_file_path(self) -> str: # all tests must implement this method- return os.path.join(os.path.dirname(__file__), "m1_data.json")-@pytest.mark.depends(name="test_basic_memory")def test_method(self, config: Dict[str, Any]) -> None:self.setup_challenge(config)diff --git a/agbenchmark/challenges/memory/m2/remember_multiple_ids_data.json b/agbenchmark/challenges/memory/m2/data.jsonsimilarity index 100%rename from agbenchmark/challenges/memory/m2/remember_multiple_ids_data.jsonrename to agbenchmark/challenges/memory/m2/data.jsondiff --git a/agbenchmark/challenges/memory/m2/remember_multiple_ids_test.py b/agbenchmark/challenges/memory/m2/remember_multiple_ids_test.pyindex f0f2b39712..6ba38dad33 100644--- a/agbenchmark/challenges/memory/m2/remember_multiple_ids_test.py+++ b/agbenchmark/challenges/memory/m2/remember_multiple_ids_test.py@@ -1,4 +1,3 @@-import osfrom typing import Any, Dictimport pytest@@ -9,11 +8,6 @@ from agbenchmark.challenges.memory.memory import MemoryChallengeclass TestRememberMultipleIds(MemoryChallenge):"""The first memory challenge"""- def get_file_path(self) -> str: # all tests must implement this method- return os.path.join(- os.path.dirname(__file__), "remember_multiple_ids_data.json"- )-@pytest.mark.depends(name="test_remember_multiple_ids", depends=["test_basic_memory"])diff --git a/agbenchmark/challenges/memory/m3/remember_multiple_ids_with_noise_data.json b/agbenchmark/challenges/memory/m3/data.jsonsimilarity index 100%rename from agbenchmark/challenges/memory/m3/remember_multiple_ids_with_noise_data.jsonrename to agbenchmark/challenges/memory/m3/data.jsondiff --git a/agbenchmark/challenges/memory/m3/remember_multiple_ids_with_noise_test.py b/agbenchmark/challenges/memory/m3/remember_multiple_ids_with_noise_test.pyindex 493ea3574c..037a6929e9 100644--- a/agbenchmark/challenges/memory/m3/remember_multiple_ids_with_noise_test.py+++ b/agbenchmark/challenges/memory/m3/remember_multiple_ids_with_noise_test.py@@ -1,4 +1,3 @@-import osfrom typing import Any, Dictimport pytest@@ -9,11 +8,6 @@ from agbenchmark.challenges.memory.memory import MemoryChallengeclass TestRememberMultipleIdsWithNoise(MemoryChallenge):"""The first memory challenge"""- def get_file_path(self) -> str: # all tests must implement this method- return os.path.join(- os.path.dirname(__file__), "remember_multiple_ids_with_noise_data.json"- )-@pytest.mark.depends(name="test_remember_multiple_ids_with_noise",depends=["test_remember_multiple_ids"],diff --git a/agbenchmark/challenges/memory/m4/remember_multiple_phrases_with_noise_data.json b/agbenchmark/challenges/memory/m4/data.jsonsimilarity index 100%rename from agbenchmark/challenges/memory/m4/remember_multiple_phrases_with_noise_data.jsonrename to agbenchmark/challenges/memory/m4/data.jsondiff --git a/agbenchmark/challenges/memory/m4/remember_multiple_phrases_with_noise_test.py b/agbenchmark/challenges/memory/m4/remember_multiple_phrases_with_noise_test.pyindex e37e9a3850..2c931af8c8 100644--- a/agbenchmark/challenges/memory/m4/remember_multiple_phrases_with_noise_test.py+++ b/agbenchmark/challenges/memory/m4/remember_multiple_phrases_with_noise_test.py@@ -1,4 +1,3 @@-import osfrom typing import Any, Dictimport pytest@@ -9,11 +8,6 @@ from agbenchmark.challenges.memory.memory import MemoryChallengeclass TestRememberMultiplePhrasesWithNoise(MemoryChallenge):"""The first memory challenge"""- def get_file_path(self) -> str: # all tests must implement this method- return os.path.join(- os.path.dirname(__file__), "remember_multiple_phrases_with_noise_data.json"- )-@pytest.mark.depends(name="test_remember_multiple_phrases_with_noise",depends=["test_remember_multiple_ids_with_noise"],diff --git a/agbenchmark/challenges/retrieval/r1/r1_data.json b/agbenchmark/challenges/retrieval/r1/data.jsonsimilarity index 100%rename from agbenchmark/challenges/retrieval/r1/r1_data.jsonrename to agbenchmark/challenges/retrieval/r1/data.jsondiff --git a/agbenchmark/challenges/retrieval/r1/r1_test.py b/agbenchmark/challenges/retrieval/r1/r1_test.pyindex 285b8affc4..68d3de4e3e 100644--- a/agbenchmark/challenges/retrieval/r1/r1_test.py+++ b/agbenchmark/challenges/retrieval/r1/r1_test.py@@ -1,4 +1,3 @@-import osfrom typing import Any, Dictimport pytest@@ -9,9 +8,6 @@ from agbenchmark.challenges.retrieval.retrieval import RetrievalChallengeclass TestRetrieval(RetrievalChallenge):"""The first information-retrieval challenge"""- def get_file_path(self) -> str: # all tests must implement this method- return os.path.join(os.path.dirname(__file__), "r1_data.json")-@pytest.mark.depends(name="test_retrieval")def test_method(self, config: Dict[str, Any]) -> None:self.setup_challenge(config)diff --git a/agbenchmark/challenges/retrieval/r2/r2_data.json b/agbenchmark/challenges/retrieval/r2/data.jsonsimilarity index 100%rename from agbenchmark/challenges/retrieval/r2/r2_data.jsonrename to agbenchmark/challenges/retrieval/r2/data.jsondiff --git a/agbenchmark/challenges/retrieval/r2/r2_test.py b/agbenchmark/challenges/retrieval/r2/r2_test.pyindex ba727b8ed2..5a1a206909 100644--- a/agbenchmark/challenges/retrieval/r2/r2_test.py+++ b/agbenchmark/challenges/retrieval/r2/r2_test.py@@ -1,4 +1,3 @@-import osfrom typing import Any, Dictimport pytest@@ -9,9 +8,6 @@ from agbenchmark.challenges.retrieval.retrieval import RetrievalChallengeclass TestRetrieval2(RetrievalChallenge):"""The first information-retrieval challenge"""- def get_file_path(self) -> str: # all tests must implement this method- return os.path.join(os.path.dirname(__file__), "r2_data.json")-@pytest.mark.depends(on=["test_retrieval"], name="test_retrieval_2")def test_method(self, config: Dict[str, Any]) -> None:self.setup_challenge(config)diff --git a/agbenchmark/challenges/retrieval/r3/r3_data.json b/agbenchmark/challenges/retrieval/r3/data.jsonsimilarity index 100%rename from agbenchmark/challenges/retrieval/r3/r3_data.jsonrename to agbenchmark/challenges/retrieval/r3/data.jsondiff --git a/agbenchmark/challenges/retrieval/r3/r3_test.py b/agbenchmark/challenges/retrieval/r3/r3_test.pyindex b58f42672b..c4b4bcf12c 100644--- a/agbenchmark/challenges/retrieval/r3/r3_test.py+++ b/agbenchmark/challenges/retrieval/r3/r3_test.py@@ -1,4 +1,3 @@-import osfrom typing import Any, Dictimport pytest@@ -9,9 +8,6 @@ from agbenchmark.challenges.retrieval.retrieval import RetrievalChallengeclass TestRetrieval3(RetrievalChallenge):"""The first information-retrieval challenge"""- def get_file_path(self) -> str: # all tests must implement this method- return os.path.join(os.path.dirname(__file__), "r3_data.json")-@pytest.mark.depends(on=["test_retrieval_2"], name="test_retrieval_3")def test_method(self, config: Dict[str, Any]) -> None:self.setup_challenge(config)diff --git a/agbenchmark/tests/basic_abilities/read_file/r_file_data.json b/agbenchmark/tests/basic_abilities/read_file/data.jsonsimilarity index 100%rename from agbenchmark/tests/basic_abilities/read_file/r_file_data.jsonrename to agbenchmark/tests/basic_abilities/read_file/data.jsondiff --git a/agbenchmark/tests/basic_abilities/read_file/read_file_test.py b/agbenchmark/tests/basic_abilities/read_file/read_file_test.pyindex 7c38d2832b..cf5dceb695 100644--- a/agbenchmark/tests/basic_abilities/read_file/read_file_test.py+++ b/agbenchmark/tests/basic_abilities/read_file/read_file_test.py@@ -1,4 +1,3 @@-import osfrom typing import Any, Dictimport pytest@@ -9,9 +8,6 @@ from agbenchmark.tests.basic_abilities.basic_challenge import BasicChallengeclass TestReadFile(BasicChallenge):"""Testing if LLM can read a file"""- def get_file_path(self) -> str: # all tests must implement this method- return os.path.join(os.path.dirname(__file__), "r_file_data.json")-@pytest.mark.depends(on=["basic_write_file"], name="basic_read_file")def test_method(self, config: Dict[str, Any]) -> None:self.setup_challenge(config)diff --git a/agbenchmark/tests/basic_abilities/write_file/w_file_data.json b/agbenchmark/tests/basic_abilities/write_file/data.jsonsimilarity index 100%rename from agbenchmark/tests/basic_abilities/write_file/w_file_data.jsonrename to agbenchmark/tests/basic_abilities/write_file/data.jsondiff --git a/agbenchmark/tests/basic_abilities/write_file/write_file_test.py b/agbenchmark/tests/basic_abilities/write_file/write_file_test.pyindex 474d671273..ba03951868 100644--- a/agbenchmark/tests/basic_abilities/write_file/write_file_test.py+++ b/agbenchmark/tests/basic_abilities/write_file/write_file_test.py@@ -1,4 +1,3 @@-import osfrom typing import Any, Dictimport pytest@@ -9,9 +8,6 @@ from agbenchmark.tests.basic_abilities.basic_challenge import BasicChallengeclass TestWriteFile(BasicChallenge):"""Testing if LLM can write to a file"""- def get_file_path(self) -> str: # all tests must implement this method- return os.path.join(os.path.dirname(__file__), "w_file_data.json")-@pytest.mark.depends(name="basic_write_file")def test_method(self, config: Dict[str, Any]) -> None:self.setup_challenge(config)