Skip to content

Commit a591e9e

Browse files
committed
Revert "Fix dependency hints on ImportError (#717)"
This reverts commit c07bbe7.
1 parent 39a3e98 commit a591e9e

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/evaluate/loading.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def _download_additional_modules(
243243
elif import_type == "external":
244244
url_or_filename = import_path
245245
else:
246-
raise ValueError(f"Wrong import_type: {import_type!r}. Expected 'library', 'internal', or 'external'.")
246+
raise ValueError("Wrong import_type")
247247

248248
local_import_path = cached_path(
249249
url_or_filename,
@@ -255,18 +255,20 @@ def _download_additional_modules(
255255

256256
# Check library imports
257257
needs_to_be_installed = set()
258-
for library_import_name, _ in library_imports:
258+
for library_import_name, library_import_path in library_imports:
259259
try:
260-
importlib.import_module(library_import_name) # noqa F841
260+
lib = importlib.import_module(library_import_name) # noqa F841
261261
except ImportError:
262262
library_import_name = "scikit-learn" if library_import_name == "sklearn" else library_import_name
263+
library_import_path = "scikit-learn" if library_import_path == "sklearn" else library_import_path
263264
library_import_name = "absl-py" if library_import_name == "absl" else library_import_name
264-
needs_to_be_installed.add(library_import_name)
265+
library_import_path = "absl-py" if library_import_path == "absl" else library_import_path
266+
needs_to_be_installed.add((library_import_name, library_import_path))
265267
if needs_to_be_installed:
266-
missing = sorted(needs_to_be_installed)
267268
raise ImportError(
268-
f"To be able to use {name}, you need to install these dependencies: "
269-
f"{', '.join(missing)} using the command 'pip install {' '.join(missing)}'."
269+
f"To be able to use {name}, you need to install the following dependencies"
270+
f"{[lib_name for lib_name, lib_path in needs_to_be_installed]} using 'pip install "
271+
f"{' '.join([lib_path for lib_name, lib_path in needs_to_be_installed])}' for instance."
270272
)
271273
return local_imports
272274

0 commit comments

Comments
 (0)