Fix missing importlib.util import in exact_search.py#207
Open
peylix wants to merge 1 commit intobeir-cellar:mainfrom
Open
Fix missing importlib.util import in exact_search.py#207peylix wants to merge 1 commit intobeir-cellar:mainfrom
peylix wants to merge 1 commit intobeir-cellar:mainfrom
Conversation
The module was using `importlib.util.find_spec()` without properly importing the submodule, which could cause an AttributeError. This commit changed `import importlib` to `import importlib.util` to avoid the error.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes an
AttributeError: module 'importlib' has no attribute 'util'that occurs when importingDenseRetrievalExactSearch.Problem
Previously when using
DenseRetrievalExactSearch, I encountered the following error:After investigation, I found the file
beir/retrieval/search/dense/exact_search.pycurrently imports only theimportlibmodule but attempts to useimportlib.util.find_spec(). In Python, importing a parent module does not automatically import its submodules, leading to an AttributeError.Solution
Explicitly import the
importlib.utilsubmodule:This is consistent with other files in the codebase (e.g.,
faiss_search.py,faiss_index.py) that already use the correct import.Test Environment