Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix verify gensim and numpy installation version check #187

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions hezar/embeddings/embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
)
from ..utils import Logger, get_lib_version, verify_dependencies

from packaging import version
import importlib.metadata

logger = Logger(__name__)

Expand All @@ -28,9 +30,12 @@

# Check if the right combo of gensim/numpy versions are installed
def _verify_gensim_installation():
numpy_version = importlib.metadata.version("numpy")
Copy link
Member

Choose a reason for hiding this comment

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

You can also use the get_lib_version under the utils which was already there and uses the exact same code you have here.

gensim_version = importlib.metadata.version("gensim")

if (
not get_lib_version("numpy").startswith(REQUIRED_NUMPY_VERSION)
or not get_lib_version("gensim").startswith(REQUIRED_GENSIM_VERSION)
version.parse(numpy_version) < version.parse(REQUIRED_NUMPY_VERSION)
Copy link
Member

Choose a reason for hiding this comment

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

The issue is that the gensim version must actually be 4.3.2 and the numpy version must be 1.24.* not lower.

or version.parse(gensim_version) < version.parse(REQUIRED_GENSIM_VERSION)
):
raise ImportError(
f"The embeddings module in this version of Hezar, requires a combo of numpy>={REQUIRED_NUMPY_VERSION} and "
Expand Down