Skip to content

Commit

Permalink
fix(management/allocators): correctly set SmartCacheTables before i…
Browse files Browse the repository at this point in the history
…nstantiating `TinyDB` databases
  • Loading branch information
ruancomelli committed Sep 9, 2022
1 parent 50bceed commit eb4e54b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions boiling_learning/management/allocators.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
from boiling_learning.utils.functional import Pack
from boiling_learning.utils.pathutils import PathLike, resolve

# Ensure that all databases/tables will now use the smart query cache
TinyDB.table_class = SmartCacheTable


class Allocator(abc.ABC):
@abc.abstractmethod
Expand Down Expand Up @@ -125,9 +128,5 @@ def default_table_allocator(
) -> JSONTableAllocator:
root = resolve(root, dir=True)
datapath = resolve(root / 'data', dir=True)
dbpath = root / 'db.json'

db = TinyDB(str(dbpath))
db.table_class = SmartCacheTable

return JSONTableAllocator(datapath, db, describer=describer, suffix=suffix)
database = TinyDB(str(root / 'db.json'))
return JSONTableAllocator(datapath, database, describer=describer, suffix=suffix)

0 comments on commit eb4e54b

Please sign in to comment.