Skip to content

Commit

Permalink
apply() call now uses unique directory names
Browse files Browse the repository at this point in the history
  • Loading branch information
Racopokemon committed Nov 9, 2023
1 parent 9c6e882 commit 17d4de7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/algbench/benchmark_db.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import datetime
import json
import os
import random
import shutil
import sys
import typing
Expand Down Expand Up @@ -96,8 +98,12 @@ def front(self) -> typing.Optional[typing.Dict]:
return None

def apply(self, func: typing.Callable[[typing.Dict], typing.Dict]):
timestamp = datetime.datetime.now().strftime("%Y%m%d%H%M")
rand = random.randint(0, 9999)
old_db_dir = f"results_old{timestamp}_{rand}"

old_db = self._data
old_db.move_directory(os.path.join(self.path, "results_old"))
old_db.move_directory(os.path.join(self.path, old_db_dir))
self._data = NfsJsonList(os.path.join(os.path.join(self.path, "results")))

for entry in old_db:
Expand Down

0 comments on commit 17d4de7

Please sign in to comment.