Skip to content

Commit

Permalink
Remove obsolete packages (#293)
Browse files Browse the repository at this point in the history
PR that removes obsolete extra packages from `import_utils`
  • Loading branch information
PhilippeMoussalli authored Jul 17, 2023
1 parent 520da12 commit 3a9cb86
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
26 changes: 1 addition & 25 deletions src/fondant/import_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,9 @@

logger = logging.getLogger(__name__)

PANDAS_IMPORT_ERROR = """
`{0}` requires the pandas library but it was not found in your environment. Please install fondant
using the 'pandas' extra.
"""

DATASETS_IMPORT_ERROR = """
`{0}` requires the 🤗 Datasets library but it was not found in your environment.
Please install fondant using the 'datasets' extra.
Note that if you have a local folder named `datasets` or a local python file named
`datasets.py` in your current working directory, python may try to import this instead of the 🤗
Datasets library. You should rename this folder or that python file if that's the case.
Please note that you may need to restart your runtime after installation.
"""

KFP_IMPORT_ERROR = """
`{0}` requires the kubeflow pipelines (kfp) library but it was not found in your environment.
Please install fondant using the 'pipelines' extra.
Please install fondant using pip install fondant [pipelines].
"""


Expand All @@ -50,16 +36,6 @@ def is_package_available(package_name: str, import_error_msg: str) -> bool:
raise ModuleNotFoundError(import_error_msg.format(Path(sys.argv[0]).stem))


def is_datasets_available():
"""Check if 'datasets' is available."""
return is_package_available("datasets", DATASETS_IMPORT_ERROR)


def is_pandas_available():
"""Check if 'pandas' is available."""
return is_package_available("pandas", PANDAS_IMPORT_ERROR)


def is_kfp_available():
"""Check if 'pandas' is available."""
return is_package_available("kfp", KFP_IMPORT_ERROR)
12 changes: 1 addition & 11 deletions tests/test_import_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

import pytest
from fondant.import_utils import (
is_datasets_available,
is_kfp_available,
is_package_available,
is_pandas_available,
)


Expand Down Expand Up @@ -35,8 +33,6 @@ def test_is_package_available(package_name, import_error_msg, expected_result):
@mock.patch("importlib.metadata.version", return_value="0.1.0")
def test_available_packages(importlib_util_find_spec, importlib_metadata_version):
"""Test that is_datasets_available is not False when the packages are available."""
assert is_datasets_available() is not False
assert is_pandas_available() is not False
assert is_kfp_available() is not False


Expand All @@ -45,12 +41,6 @@ def test_available_packages(importlib_util_find_spec, importlib_metadata_version
side_effect=importlib.metadata.PackageNotFoundError,
)
def test_unavailable_packages(mock_importlib_metadata_version):
"""Test that is_datasets_available returns False when 'datasets' is not available."""
with pytest.raises(ModuleNotFoundError):
is_datasets_available()

with pytest.raises(ModuleNotFoundError):
is_pandas_available()

"""Test that importing fondant related packages returns valid errors when not available."""
with pytest.raises(ModuleNotFoundError):
is_kfp_available()

0 comments on commit 3a9cb86

Please sign in to comment.