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.
Added caching based on file key (#62)
Silen Naihinc76062b09245
diff --git a/agbenchmark/challenge.py b/agbenchmark/challenge.pyindex 865d644444..dee2b435ed 100644--- a/agbenchmark/challenge.py+++ b/agbenchmark/challenge.py@@ -20,6 +20,8 @@ class Challenge(ABC):"""The parent class to all specific challenges classes.Defines helper methods for running a challenge"""+ _data_cache: Dict[str, ChallengeData] = {}+@abstractmethoddef get_file_path(self) -> str:"""This should be implemented by any class which inherits from BasicChallenge"""@@ -27,8 +29,13 @@ class Challenge(ABC):@propertydef data(self) -> ChallengeData:- # TODO: make it so that this is cached somewhere to just call self.deserialized_data- return ChallengeData.deserialize(self.get_file_path())+ "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)+ return Challenge._data_cache[file_path]@propertydef mock(self) -> Optional[str]: