Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,16 @@
import numpy as np
import spacy
from lm_eval.metrics import mean, weighted_mean, weighted_perplexity
from sqlitedict import SqliteDict

try:
from sqlitedict import SqliteDict

HAS_SQLITEDICT = True
except ImportError:
print(
"Eval harness with sqlitedict is deprecated. Sqlitedict has known vulnerability GHSA-g4r7-86gm-pgqc"
)
HAS_SQLITEDICT = False


def _SPACY_NLP(*args, **kwargs):
Expand Down Expand Up @@ -607,7 +616,10 @@ def __init__(self, lm, cache_db):
self.cache_db = cache_db
if os.path.dirname(cache_db):
os.makedirs(os.path.dirname(cache_db), exist_ok=True)
self.dbdict = SqliteDict(cache_db, autocommit=True)
if HAS_SQLITEDICT:
self.dbdict = SqliteDict(cache_db, autocommit=True)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It honestly probably won't matter but probably best to set self.dbdict to None sqlite dict does not exist. It looks like in the above CacheHook it's a noopt if dbdict is None.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion, I've introduced an else statement

else:
self.dbdict = None

# add hook to lm
lm.set_cache_hook(self.get_cache_hook())
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pytablewriter==0.58.0
requests==2.26.0
tqdm==4.62.3
zstandard==0.15.2
sqlitedict
hera
pydantic
kubeflow-training>=1.8
Expand Down