From da2cf2d3711de8d388f147661354506531a9e04e Mon Sep 17 00:00:00 2001 From: Philippe Moussalli Date: Thu, 13 Jul 2023 13:43:58 +0200 Subject: [PATCH] remove obsolete packages --- src/fondant/import_utils.py | 26 +------------------------- tests/test_import_utils.py | 12 +----------- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/src/fondant/import_utils.py b/src/fondant/import_utils.py index 9b004b551..65ba634d7 100644 --- a/src/fondant/import_utils.py +++ b/src/fondant/import_utils.py @@ -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]. """ @@ -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) diff --git a/tests/test_import_utils.py b/tests/test_import_utils.py index 23283c4eb..363560d35 100644 --- a/tests/test_import_utils.py +++ b/tests/test_import_utils.py @@ -4,10 +4,8 @@ import pytest from fondant.import_utils import ( - is_datasets_available, is_kfp_available, is_package_available, - is_pandas_available, ) @@ -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 @@ -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()