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

Remove obsolete packages #293

Merged
merged 1 commit into from
Jul 17, 2023
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
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()