Skip to content

Commit 98541de

Browse files
authored
DEPR deprecate hub_utils.get_model_output (#396)
1 parent a6c1ae9 commit 98541de

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

docs/changes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ v0.9
1616
estimators. :pr:`384` by :user:`Reid Johnson <reidjohnson>`.
1717
- Fix an issue with visualizing Skops files for `scikit-learn` tree estimators.
1818
:pr:`386` by :user:`Reid Johnson <reidjohnson>`.
19+
- :func:`skops.hug_utils.get_model_output` is deprecated and will be removed in version
20+
0.10. :pr:`396` by `Adrin Jalali`_.
1921

2022
v0.8
2123
----

skops/hub_utils/_hf_hub.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import json
1010
import os
1111
import shutil
12+
import warnings
1213
from pathlib import Path
1314
from typing import Any, List, Literal, MutableMapping, Optional, Sequence, Union
1415

@@ -702,11 +703,16 @@ def download(
702703
shutil.rmtree(path=cached_folder)
703704

704705

706+
# TODO(v0.10): remove this function
705707
def get_model_output(repo_id: str, data: Any, token: Optional[str] = None) -> Any:
706708
"""Returns the output of the model using Hugging Face Hub's inference API.
707709
708710
See the :ref:`User Guide <hf_hub_inference>` for more details.
709711
712+
.. deprecated:: 0.9
713+
Will be removed in version 0.10. Use ``huggingface_hub.InferenceClient``
714+
instead.
715+
710716
Parameters
711717
----------
712718
repo_id: str
@@ -737,8 +743,12 @@ def get_model_output(repo_id: str, data: Any, token: Optional[str] = None) -> An
737743
Also note that if the model repo is private, the inference API would not be
738744
available.
739745
"""
740-
# TODO: the "type: ignore" should eventually become unncessary when hf_hub
741-
# is updated
746+
warnings.warn(
747+
"This feature is no longer free on hf.co and therefore this function will"
748+
" be removed in the next release. Use `huggingface_hub.InferenceClient`"
749+
" instead.",
750+
FutureWarning,
751+
)
742752
model_info = HfApi().model_info(repo_id=repo_id, use_auth_token=token) # type: ignore
743753
if not model_info.pipeline_tag:
744754
raise ValueError(

skops/hub_utils/tests/test_hf_hub.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,8 @@ def test_inference(
503503

504504
X_test = data.data.head(5)
505505
y_pred = model.predict(X_test)
506-
output = get_model_output(repo_id, data=X_test, token=HF_HUB_TOKEN)
506+
with pytest.warns(FutureWarning):
507+
output = get_model_output(repo_id, data=X_test, token=HF_HUB_TOKEN)
507508

508509
# cleanup
509510
client.delete_repo(repo_id=repo_id, token=HF_HUB_TOKEN)
@@ -512,6 +513,12 @@ def test_inference(
512513
assert np.allclose(output, y_pred)
513514

514515

516+
def test_get_model_output_deprecated():
517+
with pytest.raises(Exception):
518+
with pytest.warns(FutureWarning, match="This feature is no longer free"):
519+
get_model_output("dummy", data=iris.data)
520+
521+
515522
def test_get_config(repo_path, config_json):
516523
config_path, file_format = config_json
517524
config = get_config(repo_path)

0 commit comments

Comments
 (0)