Skip to content

Commit cd21071

Browse files
authored
only save when is enabled (brain-score#7)
1 parent a61da6c commit cd21071

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

result_caching/__init__.py

+7-5
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def wrapper(*args, **kwargs):
182182
infile_call_args = {self._dict_key: call_args[self._dict_key]}
183183
function_identifier = self.get_function_identifier(function, call_args)
184184
stored_result, reduced_call_args = None, call_args
185-
if self.is_stored(function_identifier):
185+
if is_enabled(function_identifier) and self.is_stored(function_identifier):
186186
self._logger.debug(f"Loading from storage: {function_identifier}")
187187
stored_result = self.load(function_identifier)
188188
infile_missing_call_args = self.missing_call_args(infile_call_args, stored_result)
@@ -205,8 +205,9 @@ def wrapper(*args, **kwargs):
205205
if stored_result is not None:
206206
result = self.merge_results(stored_result, result)
207207
# only save if new results
208-
self._logger.debug("Saving to storage: {}".format(function_identifier))
209-
self.save(result, function_identifier)
208+
if is_enabled(function_identifier):
209+
self._logger.debug("Saving to storage: {}".format(function_identifier))
210+
self.save(result, function_identifier)
210211
assert self.callargs_present(result, infile_call_args)
211212
result = self.filter_callargs(result, infile_call_args)
212213
return result
@@ -288,8 +289,9 @@ def wrapper(*args, **kwargs):
288289
if stored_result is not None:
289290
result = self.merge_results(stored_result, result)
290291
# only save if new results
291-
self._logger.debug("Saving to storage: {}".format(function_identifier))
292-
self.save(result, function_identifier)
292+
if is_enabled(function_identifier):
293+
self._logger.debug("Saving to storage: {}".format(function_identifier))
294+
self.save(result, function_identifier)
293295
self.ensure_callargs_present(result, infile_call_args)
294296
result = self.filter_callargs(result, infile_call_args)
295297
return result

0 commit comments

Comments
 (0)