From 3612d2f030554f4031e2ac2d38ab054a38e0291e Mon Sep 17 00:00:00 2001 From: Thomas Lazarus Date: Sat, 4 May 2024 20:41:18 -0500 Subject: [PATCH 1/4] Removes sklearn-intelex and updates changelog --- docs/changes.rst | 3 ++- skops/_min_dependencies.py | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/changes.rst b/docs/changes.rst index 6b69c0d1..c591aad8 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -11,7 +11,8 @@ skops Changelog v0.10 ---- - +- Removes Pythn 3.8 support and adds Python 3.12 Support :pr:`418` by :user:`Thomas Lazarus `. +- Removes `sklearn-intelex` as a dependency :pr:`420` by :user:`Thomas Lazarus `. v0.9 ---- diff --git a/skops/_min_dependencies.py b/skops/_min_dependencies.py index 2a9856bd..58f12c4c 100644 --- a/skops/_min_dependencies.py +++ b/skops/_min_dependencies.py @@ -13,7 +13,6 @@ # "tomli": ("1.1.0", "install", "python_full_version < '3.11.0a7'"), dependent_packages = { "scikit-learn": ("0.24", "install", None), - "scikit-learn-intelex": ("2021.7.1", "docs", None), "huggingface_hub": ("0.17.0", "install", None), "tabulate": ("0.8.8", "install", None), "quantile-forest": ("1.0.0", "tests", None), From e04d38feef9d3ae50602a66d3b9091ca595fb67e Mon Sep 17 00:00:00 2001 From: Thomas Lazarus Date: Tue, 7 May 2024 19:40:39 -0500 Subject: [PATCH 2/4] Removes sklearn-intelex from the API --- skops/card/_model_card.py | 2 -- skops/card/tests/test_card.py | 32 ------------------- skops/hub_utils/_hf_hub.py | 26 --------------- skops/hub_utils/tests/test_hf_hub.py | 48 ---------------------------- 4 files changed, 108 deletions(-) diff --git a/skops/card/_model_card.py b/skops/card/_model_card.py index 1efb0c28..02cd8000 100644 --- a/skops/card/_model_card.py +++ b/skops/card/_model_card.py @@ -106,8 +106,6 @@ def metadata_from_config(config_path: Union[str, Path]) -> ModelCardData: if task: card_data.tags += [task] card_data.model_file = config.get("sklearn", {}).get("model", {}).get("file") # type: ignore - if config.get("sklearn", {}).get("use_intelex"): - card_data.tags.append("scikit-learn-intelex") example_input = config.get("sklearn", {}).get("example_input", None) # Documentation on what the widget expects: diff --git a/skops/card/tests/test_card.py b/skops/card/tests/test_card.py index 693c7adb..97862d2a 100644 --- a/skops/card/tests/test_card.py +++ b/skops/card/tests/test_card.py @@ -1197,38 +1197,6 @@ def test_metadata_model_format_skops( metadata = metadata_load(local_path=Path(destination_path) / "README.md") assert metadata["model_format"] == "skops" - def test_metadata_tags_without_sklearn_intelex_tag( - self, destination_path, iris_data, iris_pkl_file - ): - # by default, intelex is not being used - X, _ = iris_data - hub_utils.init( - model=iris_pkl_file, - requirements=[], - dst=destination_path, - task="tabular-classification", - data=X, - ) - - metadata = metadata_from_config(destination_path) - assert "scikit-learn-intelex" not in metadata.tags - - def test_metadata_tags_with_sklearn_intelex_tag( - self, destination_path, iris_data, iris_pkl_file - ): - X, _ = iris_data - hub_utils.init( - model=iris_pkl_file, - requirements=[], - dst=destination_path, - task="tabular-classification", - data=X, - use_intelex=True, - ) - - metadata = metadata_from_config(destination_path) - assert "scikit-learn-intelex" in metadata.tags - @pytest.mark.xfail(reason="dynamic adjustment when model changes not implemented yet") class TestModelDynamicUpdate: diff --git a/skops/hub_utils/_hf_hub.py b/skops/hub_utils/_hf_hub.py index 660ed6b6..d1d1eff6 100644 --- a/skops/hub_utils/_hf_hub.py +++ b/skops/hub_utils/_hf_hub.py @@ -212,7 +212,6 @@ def _create_config( "pickle", "auto", ] = "auto", - use_intelex: bool = False, ) -> None: """Write the configuration into a ``config.json`` file. @@ -256,14 +255,6 @@ def _create_config( - ``"pickle"`` if the extension is one of ``{".pickle", ".pkl", ".joblib"}`` - ``"skops"`` if the extension is ``".skops"`` - - use_intelex: bool (default=False) - Whether to enable ``scikit-learn-intelex``. This can accelerate some - sklearn models by a large factor with the right hardware. In most cases, - enabling this option should not break any code, even if the model was - not initially trained with scikit-learn intelex and even if the hardware - does not support it. For more info, see - https://intel.github.io/scikit-learn-intelex/. """ # so that we don't have to explicitly add keys and they're added as a @@ -289,7 +280,6 @@ def recursively_default_dict() -> MutableMapping: config["sklearn"]["environment"] = requirements config["sklearn"]["task"] = task config["sklearn"]["model_format"] = model_format - config["sklearn"]["use_intelex"] = use_intelex if "tabular" in task: config["sklearn"]["example_input"] = _get_example_input_from_tabular_data(data) @@ -344,7 +334,6 @@ def init( "pickle", "auto", ] = "auto", - use_intelex: bool = False, ) -> None: """Initialize a scikit-learn based Hugging Face repo. @@ -388,14 +377,6 @@ def init( model_format: str (default="auto") The format the model was persisted in. Can be ``"auto"``, ``"skops"`` or ``"pickle"``. Defaults to ``"auto"`` that relies on file extension. - - use_intelex: bool (default=False) - Whether to enable ``scikit-learn-intelex``. This can accelerate some - sklearn models by a large factor with the right hardware. In most cases, - enabling this option should not break any code, even if the model was - not initially trained with scikit-learn intelex and even if the hardware - does not support it. For more info, see - https://intel.github.io/scikit-learn-intelex/. """ dst = Path(dst) if dst.exists() and bool(next(dst.iterdir(), None)): @@ -410,12 +391,6 @@ def init( dst.mkdir(parents=True, exist_ok=True) - # add intelex requirement, if it's used and not already in requirements - if use_intelex and not any( - r.startswith("scikit-learn-intelex") for r in requirements - ): - requirements.append("scikit-learn-intelex") - try: shutil.copy2(src=model, dst=dst) @@ -427,7 +402,6 @@ def init( task=task, data=data, model_format=model_format, - use_intelex=use_intelex, ) except Exception: shutil.rmtree(dst) diff --git a/skops/hub_utils/tests/test_hf_hub.py b/skops/hub_utils/tests/test_hf_hub.py index 2326c80a..b4609dba 100644 --- a/skops/hub_utils/tests/test_hf_hub.py +++ b/skops/hub_utils/tests/test_hf_hub.py @@ -652,51 +652,3 @@ def test_adding_existing_file_raises(self, init_path, some_file_0): ) with pytest.raises(FileExistsError, match=msg): add_files(some_file_0, dst=init_path) - - -class TestUseIntelex: - # Tests related to the usage of scikit-learn intelex, see #251 - def make_config(self, model, requirements, **kwargs): - dir_path = tempfile.mkdtemp() - shutil.rmtree(dir_path) - - init( - model=model, - dst=dir_path, - task="tabular-classification", - data=iris.data, - requirements=requirements, - **kwargs, - ) - config = get_config(dir_path) - return config - - def test_no_intelex(self, classifier): - # by default, intelex is not being used - config = self.make_config(model=classifier, requirements=["foobar"]) - environement = config["sklearn"]["environment"] - - assert config["sklearn"]["use_intelex"] is False - assert not any(r.startswith("scikit-learn-intelex") for r in environement) - - def test_use_intelex_but_not_explicitly_in_requirements(self, classifier): - # when using intelex, if it's not explicitly in the environment, add it - # automatically - config = self.make_config( - model=classifier, requirements=["foobar"], use_intelex=True - ) - environement = config["sklearn"]["environment"] - - assert config["sklearn"]["use_intelex"] is True - assert any(r == "scikit-learn-intelex" for r in environement) - - def test_use_intelex_explicitly_in_requirements(self, classifier): - # when users specify intelex explicitly, it's not added automatically to - # the requirements - reqs = ["foobar", "scikit-learn-intelex==2023.0.0"] - config = self.make_config(model=classifier, requirements=reqs, use_intelex=True) - environement = config["sklearn"]["environment"] - - assert config["sklearn"]["use_intelex"] is True - assert not any(r == "scikit-learn-intelex" for r in environement) - assert any(r == "scikit-learn-intelex==2023.0.0" for r in environement) From 8fac0d8504d2fcaabde25e271001b2511b715221 Mon Sep 17 00:00:00 2001 From: Thomas Lazarus <46943923+lazarust@users.noreply.github.com> Date: Wed, 8 May 2024 15:53:46 -0500 Subject: [PATCH 3/4] Update docs/changes.rst Co-authored-by: Adrin Jalali --- docs/changes.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changes.rst b/docs/changes.rst index c591aad8..61bec37e 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -12,7 +12,8 @@ skops Changelog v0.10 ---- - Removes Pythn 3.8 support and adds Python 3.12 Support :pr:`418` by :user:`Thomas Lazarus `. -- Removes `sklearn-intelex` as a dependency :pr:`420` by :user:`Thomas Lazarus `. +- Removes a shortcut to add `sklearn-intelex` as a not dependency. + :pr:`420` by :user:`Thomas Lazarus < lazarust > `. v0.9 ---- From 88f129c605b3d10ed5aef54cf11dfd2d51e7922b Mon Sep 17 00:00:00 2001 From: Thomas Lazarus Date: Mon, 13 May 2024 19:56:24 -0500 Subject: [PATCH 4/4] Removes extra paragraph from examples.rst --- docs/examples.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/examples.rst b/docs/examples.rst index 5a168482..f7ca5d38 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -15,11 +15,6 @@ Examples of interactions with the Hugging Face Hub - Text Classification: :ref:`sphx_glr_auto_examples_plot_text_classification.py` is an example of using skops to serialize a text classification model and create a model card and a Hugging Face Hub repository. -- Using Intel(R) Extension for scikit-learn: - :ref:`sphx_glr_auto_examples_plot_intelex.py` is an example of using - Intel(R) Extension for scikit-learn to speed up inference of classical - machine learning algorithms and how performance-optimized models work with - Hugging Face Hub. - Long semi-realistic guide using the California Housing dataset: :ref:`sphx_glr_auto_examples_plot_california_housing.py` is an exercise that goes through a semi-realistic data science and machine learning task and