Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
Get rid of get file path method
Browse files Browse the repository at this point in the history
Signed-off-by: Merwane Hamadi <merwanehamadi@gmail.com>
  • Loading branch information
waynehamadi committed Jul 7, 2023
1 parent 6ef32a9 commit aa97c7d
Show file tree
Hide file tree
Showing 24 changed files with 4 additions and 67 deletions.
3 changes: 0 additions & 3 deletions agbenchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ import os
class 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 workspace
Expand Down
16 changes: 4 additions & 12 deletions agbenchmark/challenge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import subprocess
import types
from abc import ABC, ABCMeta, abstractmethod
from abc import ABC, ABCMeta
from typing import Any, Dict, List, Optional, Tuple, Type, cast

import pytest
Expand Down Expand Up @@ -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

@property
def 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]

@property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from typing import Any, Dict

import pytest
Expand All @@ -9,11 +8,6 @@
class 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)
Expand Down
4 changes: 0 additions & 4 deletions agbenchmark/challenges/code/d2/d2_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from typing import Any, Dict

import pytest
Expand All @@ -9,9 +8,6 @@
class 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"],
Expand Down
4 changes: 0 additions & 4 deletions agbenchmark/challenges/memory/m1/m1_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from typing import Any, Dict

import pytest
Expand All @@ -9,9 +8,6 @@
class 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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from typing import Any, Dict

import pytest
Expand All @@ -9,11 +8,6 @@
class 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"]
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from typing import Any, Dict

import pytest
Expand All @@ -9,11 +8,6 @@
class 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"],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from typing import Any, Dict

import pytest
Expand All @@ -9,11 +8,6 @@
class 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"],
Expand Down
4 changes: 0 additions & 4 deletions agbenchmark/challenges/retrieval/r1/r1_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from typing import Any, Dict

import pytest
Expand All @@ -9,9 +8,6 @@
class 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)
Expand Down
4 changes: 0 additions & 4 deletions agbenchmark/challenges/retrieval/r2/r2_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from typing import Any, Dict

import pytest
Expand All @@ -9,9 +8,6 @@
class 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)
Expand Down
4 changes: 0 additions & 4 deletions agbenchmark/challenges/retrieval/r3/r3_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from typing import Any, Dict

import pytest
Expand All @@ -9,9 +8,6 @@
class 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)
Expand Down
4 changes: 0 additions & 4 deletions agbenchmark/tests/basic_abilities/read_file/read_file_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from typing import Any, Dict

import pytest
Expand All @@ -9,9 +8,6 @@
class 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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from typing import Any, Dict

import pytest
Expand All @@ -9,9 +8,6 @@
class 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)
Expand Down

0 comments on commit aa97c7d

Please sign in to comment.