From 9c98a4b29cbb8ce25d33f0f0771ea4c49107e80a Mon Sep 17 00:00:00 2001 From: Lucain Date: Wed, 17 Jul 2024 16:21:15 +0200 Subject: [PATCH] Do not mention gitalyUid in expand parameter (#2395) --- src/huggingface_hub/hf_api.py | 15 ++++++--------- tests/test_hf_api.py | 25 +++++++++---------------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/src/huggingface_hub/hf_api.py b/src/huggingface_hub/hf_api.py index bbe2efd885..b1775186e5 100644 --- a/src/huggingface_hub/hf_api.py +++ b/src/huggingface_hub/hf_api.py @@ -149,7 +149,6 @@ "downloads", "downloadsAllTime", "gated", - "gitalyUid", "inference", "lastModified", "library_name", @@ -177,7 +176,6 @@ "downloads", "downloadsAllTime", "gated", - "gitalyUid", "lastModified", "likes", "paperswithcode_id", @@ -192,7 +190,6 @@ "cardData", "datasets", "disabled", - "gitalyUid", "lastModified", "createdAt", "likes", @@ -1633,7 +1630,7 @@ def list_models( expand (`List[ExpandModelProperty_T]`, *optional*): List properties to return in the response. When used, only the properties in the list will be returned. This parameter cannot be used if `full`, `cardData` or `fetch_config` are passed. - Possible values are `"author"`, `"cardData"`, `"config"`, `"createdAt"`, `"disabled"`, `"downloads"`, `"downloadsAllTime"`, `"gated"`, `"gitalyUid"`, `"inference"`, `"lastModified"`, `"library_name"`, `"likes"`, `"mask_token"`, `"model-index"`, `"pipeline_tag"`, `"private"`, `"safetensors"`, `"sha"`, `"siblings"`, `"spaces"`, `"tags"`, `"transformersInfo"` and `"widgetData"`. + Possible values are `"author"`, `"cardData"`, `"config"`, `"createdAt"`, `"disabled"`, `"downloads"`, `"downloadsAllTime"`, `"gated"`, `"inference"`, `"lastModified"`, `"library_name"`, `"likes"`, `"mask_token"`, `"model-index"`, `"pipeline_tag"`, `"private"`, `"safetensors"`, `"sha"`, `"siblings"`, `"spaces"`, `"tags"`, `"transformersInfo"` and `"widgetData"`. full (`bool`, *optional*): Whether to fetch all model data, including the `last_modified`, the `sha`, the files and the `tags`. This is set to `True` by @@ -1836,7 +1833,7 @@ def list_datasets( expand (`List[ExpandDatasetProperty_T]`, *optional*): List properties to return in the response. When used, only the properties in the list will be returned. This parameter cannot be used if `full` is passed. - Possible values are `"author"`, `"cardData"`, `"citation"`, `"createdAt"`, `"disabled"`, `"description"`, `"downloads"`, `"downloadsAllTime"`, `"gated"`, `"gitalyUid"`, `"lastModified"`, `"likes"`, `"paperswithcode_id"`, `"private"`, `"siblings"`, `"sha"` and `"tags"`. + Possible values are `"author"`, `"cardData"`, `"citation"`, `"createdAt"`, `"disabled"`, `"description"`, `"downloads"`, `"downloadsAllTime"`, `"gated"`, `"lastModified"`, `"likes"`, `"paperswithcode_id"`, `"private"`, `"siblings"`, `"sha"` and `"tags"`. full (`bool`, *optional*): Whether to fetch all dataset data, including the `last_modified`, the `card_data` and the files. Can contain useful information such as the @@ -2017,7 +2014,7 @@ def list_spaces( expand (`List[ExpandSpaceProperty_T]`, *optional*): List properties to return in the response. When used, only the properties in the list will be returned. This parameter cannot be used if `full` is passed. - Possible values are `"author"`, `"cardData"`, `"datasets"`, `"disabled"`, `"gitalyUid"`, `"lastModified"`, `"createdAt"`, `"likes"`, `"private"`, `"runtime"`, `"sdk"`, `"siblings"`, `"sha"`, `"subdomain"`, `"tags"` and `"models"`. + Possible values are `"author"`, `"cardData"`, `"datasets"`, `"disabled"`, `"lastModified"`, `"createdAt"`, `"likes"`, `"private"`, `"runtime"`, `"sdk"`, `"siblings"`, `"sha"`, `"subdomain"`, `"tags"` and `"models"`. full (`bool`, *optional*): Whether to fetch all Spaces data, including the `last_modified`, `siblings` and `card_data` fields. @@ -2334,7 +2331,7 @@ def model_info( expand (`List[ExpandModelProperty_T]`, *optional*): List properties to return in the response. When used, only the properties in the list will be returned. This parameter cannot be used if `securityStatus` or `files_metadata` are passed. - Possible values are `"author"`, `"cardData"`, `"config"`, `"createdAt"`, `"disabled"`, `"downloads"`, `"downloadsAllTime"`, `"gated"`, `"gitalyUid"`, `"inference"`, `"lastModified"`, `"library_name"`, `"likes"`, `"mask_token"`, `"model-index"`, `"pipeline_tag"`, `"private"`, `"safetensors"`, `"sha"`, `"siblings"`, `"spaces"`, `"tags"`, `"transformersInfo"` and `"widgetData"`. + Possible values are `"author"`, `"cardData"`, `"config"`, `"createdAt"`, `"disabled"`, `"downloads"`, `"downloadsAllTime"`, `"gated"`, `"inference"`, `"lastModified"`, `"library_name"`, `"likes"`, `"mask_token"`, `"model-index"`, `"pipeline_tag"`, `"private"`, `"safetensors"`, `"sha"`, `"siblings"`, `"spaces"`, `"tags"`, `"transformersInfo"` and `"widgetData"`. token (Union[bool, str, None], optional): A valid user access token (string). Defaults to the locally saved token, which is the recommended method for authentication (see @@ -2408,7 +2405,7 @@ def dataset_info( expand (`List[ExpandDatasetProperty_T]`, *optional*): List properties to return in the response. When used, only the properties in the list will be returned. This parameter cannot be used if `files_metadata` is passed. - Possible values are `"author"`, `"cardData"`, `"citation"`, `"createdAt"`, `"disabled"`, `"description"`, `"downloads"`, `"downloadsAllTime"`, `"gated"`, `"gitalyUid"`, `"lastModified"`, `"likes"`, `"paperswithcode_id"`, `"private"`, `"siblings"`, `"sha"` and `"tags"`. + Possible values are `"author"`, `"cardData"`, `"citation"`, `"createdAt"`, `"disabled"`, `"description"`, `"downloads"`, `"downloadsAllTime"`, `"gated"`, `"lastModified"`, `"likes"`, `"paperswithcode_id"`, `"private"`, `"siblings"`, `"sha"` and `"tags"`. token (Union[bool, str, None], optional): A valid user access token (string). Defaults to the locally saved token, which is the recommended method for authentication (see @@ -2481,7 +2478,7 @@ def space_info( expand (`List[ExpandSpaceProperty_T]`, *optional*): List properties to return in the response. When used, only the properties in the list will be returned. This parameter cannot be used if `full` is passed. - Possible values are `"author"`, `"cardData"`, `"datasets"`, `"disabled"`, `"gitalyUid"`, `"lastModified"`, `"createdAt"`, `"likes"`, `"private"`, `"runtime"`, `"sdk"`, `"siblings"`, `"sha"`, `"subdomain"`, `"tags"` and `"models"`. + Possible values are `"author"`, `"cardData"`, `"datasets"`, `"disabled"`, `"lastModified"`, `"createdAt"`, `"likes"`, `"private"`, `"runtime"`, `"sdk"`, `"siblings"`, `"sha"`, `"subdomain"`, `"tags"` and `"models"`. token (Union[bool, str, None], optional): A valid user access token (string). Defaults to the locally saved token, which is the recommended method for authentication (see diff --git a/tests/test_hf_api.py b/tests/test_hf_api.py index d933e0f8a1..b0302e3dce 100644 --- a/tests/test_hf_api.py +++ b/tests/test_hf_api.py @@ -1716,12 +1716,11 @@ def test_list_models_expand_author(self): def test_list_models_expand_multiple(self): # Only the selected fields are returned - models = list(self._api.list_models(expand=["author", "downloadsAllTime", "gitalyUid"], limit=5)) + models = list(self._api.list_models(expand=["author", "downloadsAllTime"], limit=5)) for model in models: assert model.author is not None assert model.downloads_all_time is not None assert model.downloads is None - assert model.gitalyUid is not None # not a field except if requested explicitly def test_list_models_expand_unexpected_value(self): # Unexpected value => HTTP 400 @@ -1832,13 +1831,10 @@ def test_model_info_expand_author(self): def test_model_info_expand_multiple(self): # Only the selected fields are returned - model = self._api.model_info( - repo_id="HuggingFaceH4/zephyr-7b-beta", expand=["author", "downloadsAllTime", "gitalyUid"] - ) + model = self._api.model_info(repo_id="HuggingFaceH4/zephyr-7b-beta", expand=["author", "downloadsAllTime"]) assert model.author == "HuggingFaceH4" assert model.downloads is None assert model.downloads_all_time is not None - assert model.gitalyUid is not None # not a field except if requested explicitly assert model.created_at is None assert model.last_modified is None @@ -1949,12 +1945,11 @@ def test_list_datasets_expand_author(self): def test_list_datasets_expand_multiple(self): # Only the selected fields are returned - datasets = list(self._api.list_datasets(expand=["author", "downloadsAllTime", "gitalyUid"], limit=5)) + datasets = list(self._api.list_datasets(expand=["author", "downloadsAllTime"], limit=5)) for dataset in datasets: assert dataset.author is not None assert dataset.downloads_all_time is not None assert dataset.downloads is None - assert dataset.gitalyUid is not None # not a field except if requested explicitly def test_list_datasets_expand_unexpected_value(self): # Unexpected value => HTTP 400 @@ -2019,13 +2014,10 @@ def test_dataset_info_expand_author(self): def test_dataset_info_expand_multiple(self): # Only the selected fields are returned - dataset = self._api.dataset_info( - repo_id="HuggingFaceH4/no_robots", expand=["author", "downloadsAllTime", "gitalyUid"] - ) + dataset = self._api.dataset_info(repo_id="HuggingFaceH4/no_robots", expand=["author", "downloadsAllTime"]) assert dataset.author == "HuggingFaceH4" assert dataset.downloads is None assert dataset.downloads_all_time is not None - assert dataset.gitalyUid is not None # not a field except if requested explicitly assert dataset.created_at is None assert dataset.last_modified is None @@ -2055,11 +2047,11 @@ def test_space_info_expand_author(self): def test_space_info_expand_multiple(self): # Only the selected fields are returned - space = self._api.space_info(repo_id="HuggingFaceH4/zephyr-chat", expand=["author", "gitalyUid"]) + space = self._api.space_info(repo_id="HuggingFaceH4/zephyr-chat", expand=["author", "likes"]) assert space.author == "HuggingFaceH4" - assert space.gitalyUid is not None # not a field except if requested explicitly assert space.created_at is None assert space.last_modified is None + assert space.likes is not None def test_space_info_expand_unexpected_value(self): # Unexpected value => HTTP 400 @@ -2229,10 +2221,10 @@ def test_list_spaces_expand_author(self): def test_list_spaces_expand_multiple(self): # Only the selected fields are returned - spaces = list(self._api.list_spaces(expand=["author", "gitalyUid"], limit=5)) + spaces = list(self._api.list_spaces(expand=["author", "likes"], limit=5)) for space in spaces: assert space.author is not None - assert space.gitalyUid is not None # not a field except if requested explicitly + assert space.likes is not None def test_list_spaces_expand_unexpected_value(self): # Unexpected value => HTTP 400 @@ -4125,6 +4117,7 @@ def _check_expand_property_is_up_to_date(self, repo_url: RepoUrl): assert message.startswith('"expand" must be one of ') defined_args = set(get_args(property_type)) expected_args = set(message.replace('"expand" must be one of ', "").strip("[]").split(", ")) + expected_args.remove("gitalyUid") # internal one, do not document if defined_args != expected_args: should_be_removed = defined_args - expected_args