137
137
_get_token_from_file ,
138
138
_get_token_from_google_colab ,
139
139
)
140
- from .utils ._deprecation import _deprecate_method
140
+ from .utils ._deprecation import _deprecate_arguments , _deprecate_method
141
141
from .utils ._runtime import is_xet_available
142
142
from .utils ._typing import CallableT
143
143
from .utils .endpoint_helpers import _is_emission_within_threshold
@@ -1855,6 +1855,9 @@ def get_dataset_tags(self) -> Dict:
1855
1855
hf_raise_for_status (r )
1856
1856
return r .json ()
1857
1857
1858
+ @_deprecate_arguments (
1859
+ version = "1.0" , deprecated_args = ["language" , "library" , "task" , "tags" ], custom_message = "Use `filter` instead."
1860
+ )
1858
1861
@validate_hf_hub_args
1859
1862
def list_models (
1860
1863
self ,
@@ -1865,12 +1868,8 @@ def list_models(
1865
1868
gated : Optional [bool ] = None ,
1866
1869
inference : Optional [Literal ["warm" ]] = None ,
1867
1870
inference_provider : Optional [Union [Literal ["all" ], "PROVIDER_T" , List ["PROVIDER_T" ]]] = None ,
1868
- library : Optional [Union [str , List [str ]]] = None ,
1869
- language : Optional [Union [str , List [str ]]] = None ,
1870
1871
model_name : Optional [str ] = None ,
1871
- task : Optional [Union [str , List [str ]]] = None ,
1872
1872
trained_dataset : Optional [Union [str , List [str ]]] = None ,
1873
- tags : Optional [Union [str , List [str ]]] = None ,
1874
1873
search : Optional [str ] = None ,
1875
1874
pipeline_tag : Optional [str ] = None ,
1876
1875
emissions_thresholds : Optional [Tuple [float , float ]] = None ,
@@ -1884,13 +1883,19 @@ def list_models(
1884
1883
cardData : bool = False ,
1885
1884
fetch_config : bool = False ,
1886
1885
token : Union [bool , str , None ] = None ,
1886
+ # Deprecated arguments - use `filter` instead
1887
+ language : Optional [Union [str , List [str ]]] = None ,
1888
+ library : Optional [Union [str , List [str ]]] = None ,
1889
+ tags : Optional [Union [str , List [str ]]] = None ,
1890
+ task : Optional [Union [str , List [str ]]] = None ,
1887
1891
) -> Iterable [ModelInfo ]:
1888
1892
"""
1889
1893
List models hosted on the Huggingface Hub, given some filters.
1890
1894
1891
1895
Args:
1892
1896
filter (`str` or `Iterable[str]`, *optional*):
1893
1897
A string or list of string to filter models on the Hub.
1898
+ Models can be filtered by library, language, task, tags, and more.
1894
1899
author (`str`, *optional*):
1895
1900
A string which identify the author (user or organization) of the
1896
1901
returned models.
@@ -1904,23 +1909,19 @@ def list_models(
1904
1909
A string to filter models on the Hub that are served by a specific provider.
1905
1910
Pass `"all"` to get all models served by at least one provider.
1906
1911
library (`str` or `List`, *optional*):
1907
- A string or list of strings of foundational libraries models were
1908
- originally trained from, such as pytorch, tensorflow, or allennlp.
1912
+ Deprecated. Pass a library name in `filter` to filter models by library.
1909
1913
language (`str` or `List`, *optional*):
1910
- A string or list of strings of languages, both by name and country
1911
- code, such as "en" or "English"
1914
+ Deprecated. Pass a language in `filter` to filter models by language.
1912
1915
model_name (`str`, *optional*):
1913
1916
A string that contain complete or partial names for models on the
1914
1917
Hub, such as "bert" or "bert-base-cased"
1915
1918
task (`str` or `List`, *optional*):
1916
- A string or list of strings of tasks models were designed for, such
1917
- as: "fill-mask" or "automatic-speech-recognition"
1919
+ Deprecated. Pass a task in `filter` to filter models by task.
1918
1920
trained_dataset (`str` or `List`, *optional*):
1919
1921
A string tag or a list of string tags of the trained dataset for a
1920
1922
model on the Hub.
1921
1923
tags (`str` or `List`, *optional*):
1922
- A string tag or a list of tags to filter models on the Hub by, such
1923
- as `text-generation` or `spacy`.
1924
+ Deprecated. Pass tags in `filter` to filter models by tags.
1924
1925
search (`str`, *optional*):
1925
1926
A string that will be contained in the returned model ids.
1926
1927
pipeline_tag (`str`, *optional*):
@@ -1991,7 +1992,7 @@ def list_models(
1991
1992
if expand and (full or cardData or fetch_config ):
1992
1993
raise ValueError ("`expand` cannot be used if `full`, `cardData` or `fetch_config` are passed." )
1993
1994
1994
- if emissions_thresholds is not None and cardData is None :
1995
+ if emissions_thresholds is not None and not cardData :
1995
1996
raise ValueError ("`emissions_thresholds` were passed without setting `cardData=True`." )
1996
1997
1997
1998
path = f"{ self .endpoint } /api/models"
@@ -2074,6 +2075,7 @@ def list_models(
2074
2075
if emissions_thresholds is None or _is_emission_within_threshold (model_info , * emissions_thresholds ):
2075
2076
yield model_info
2076
2077
2078
+ @_deprecate_arguments (version = "1.0" , deprecated_args = ["tags" ], custom_message = "Use `filter` instead." )
2077
2079
@validate_hf_hub_args
2078
2080
def list_datasets (
2079
2081
self ,
@@ -2088,7 +2090,6 @@ def list_datasets(
2088
2090
language : Optional [Union [str , List [str ]]] = None ,
2089
2091
multilinguality : Optional [Union [str , List [str ]]] = None ,
2090
2092
size_categories : Optional [Union [str , List [str ]]] = None ,
2091
- tags : Optional [Union [str , List [str ]]] = None ,
2092
2093
task_categories : Optional [Union [str , List [str ]]] = None ,
2093
2094
task_ids : Optional [Union [str , List [str ]]] = None ,
2094
2095
search : Optional [str ] = None ,
@@ -2100,6 +2101,8 @@ def list_datasets(
2100
2101
expand : Optional [List [ExpandDatasetProperty_T ]] = None ,
2101
2102
full : Optional [bool ] = None ,
2102
2103
token : Union [bool , str , None ] = None ,
2104
+ # Deprecated arguments - use `filter` instead
2105
+ tags : Optional [Union [str , List [str ]]] = None ,
2103
2106
) -> Iterable [DatasetInfo ]:
2104
2107
"""
2105
2108
List datasets hosted on the Huggingface Hub, given some filters.
@@ -2134,7 +2137,7 @@ def list_datasets(
2134
2137
the Hub by the size of the dataset such as `100K<n<1M` or
2135
2138
`1M<n<10M`.
2136
2139
tags (`str` or `List`, *optional*):
2137
- A string tag or a list of tags to filter datasets on the Hub .
2140
+ Deprecated. Pass tags in `filter` to filter datasets by tags .
2138
2141
task_categories (`str` or `List`, *optional*):
2139
2142
A string or list of strings that can be used to identify datasets on
2140
2143
the Hub by the designed task, such as `audio_classification` or
0 commit comments