Skip to content

Commit

Permalink
fix: Load in from disk if cache missing
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiebergman committed Dec 9, 2024
1 parent 65b2bf9 commit b146d05
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions neps/state/neps_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@ def list_trial_ids(self) -> list[str]:

def latest(self) -> dict[str, Trial]:
if not self.cache_path.exists():
# If we end up with no cache but there are trials on disk, we need to
# read them in. However we will not save back the cache here in fear of
# overwriting
if any(path.name.startswith("config_") for path in self.directory.iterdir()):
trial_ids = self.list_trial_ids()
return {
trial_id: self.load_trial_from_disk(trial_id)
for trial_id in trial_ids
}

return {}

with self.cache_path.open("rb") as f:
Expand Down

0 comments on commit b146d05

Please sign in to comment.