Skip to content

Commit 290aa26

Browse files
authored
Prepare for 0.30 (#2878)
1 parent 6456491 commit 290aa26

File tree

4 files changed

+9
-73
lines changed

4 files changed

+9
-73
lines changed

src/huggingface_hub/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
from typing import TYPE_CHECKING
4747

4848

49-
__version__ = "0.29.0.dev0"
49+
__version__ = "0.30.0.dev0"
5050

5151
# Alphabetical order of definitions is ensured in tests
5252
# WARNING: any comment added in this dictionary definition will be lost when

src/huggingface_hub/_webhooks_server.py

+2
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ def launch(self, prevent_thread_lock: bool = False, **launch_kwargs: Any) -> Non
186186
# Print instructions and block main thread
187187
space_host = os.environ.get("SPACE_HOST")
188188
url = "https://" + space_host if space_host is not None else (ui.share_url or ui.local_url)
189+
if url is None:
190+
raise ValueError("Cannot find the URL of the app. Please provide a valid `ui` or update `gradio` version.")
189191
url = url.strip("/")
190192
message = "\nWebhooks are correctly setup and ready to use:"
191193
message += "\n" + "\n".join(f" - POST {url}{webhook}" for webhook in self.registered_webhooks)

src/huggingface_hub/inference/_client.py

+3-36
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
)
103103
from huggingface_hub.inference._providers import PROVIDER_T, HFInferenceTask, get_provider_helper
104104
from huggingface_hub.utils import build_hf_headers, get_session, hf_raise_for_status
105-
from huggingface_hub.utils._deprecation import _deprecate_arguments, _deprecate_method
105+
from huggingface_hub.utils._deprecation import _deprecate_method
106106

107107

108108
if TYPE_CHECKING:
@@ -3033,22 +3033,14 @@ def visual_question_answering(
30333033
response = self._inner_post(request_parameters)
30343034
return VisualQuestionAnsweringOutputElement.parse_obj_as_list(response)
30353035

3036-
@_deprecate_arguments(
3037-
version="0.30.0",
3038-
deprecated_args=["labels"],
3039-
custom_message="`labels`has been renamed to `candidate_labels` and will be removed in huggingface_hub>=0.30.0.",
3040-
)
30413036
def zero_shot_classification(
30423037
self,
30433038
text: str,
3044-
# temporarily keeping it optional for backward compatibility.
3045-
candidate_labels: List[str] = None, # type: ignore
3039+
candidate_labels: List[str],
30463040
*,
30473041
multi_label: Optional[bool] = False,
30483042
hypothesis_template: Optional[str] = None,
30493043
model: Optional[str] = None,
3050-
# deprecated argument
3051-
labels: List[str] = None, # type: ignore
30523044
) -> List[ZeroShotClassificationOutputElement]:
30533045
"""
30543046
Provide as input a text and a set of candidate labels to classify the input text.
@@ -3127,16 +3119,6 @@ def zero_shot_classification(
31273119
]
31283120
```
31293121
"""
3130-
# handle deprecation
3131-
if labels is not None:
3132-
if candidate_labels is not None:
3133-
raise ValueError(
3134-
"Cannot specify both `labels` and `candidate_labels`. Use `candidate_labels` instead."
3135-
)
3136-
candidate_labels = labels
3137-
elif candidate_labels is None:
3138-
raise ValueError("Must specify `candidate_labels`")
3139-
31403122
provider_helper = get_provider_helper(self.provider, task="zero-shot-classification")
31413123
request_parameters = provider_helper.prepare_request(
31423124
inputs=text,
@@ -3156,16 +3138,10 @@ def zero_shot_classification(
31563138
for label, score in zip(output["labels"], output["scores"])
31573139
]
31583140

3159-
@_deprecate_arguments(
3160-
version="0.30.0",
3161-
deprecated_args=["labels"],
3162-
custom_message="`labels`has been renamed to `candidate_labels` and will be removed in huggingface_hub>=0.30.0.",
3163-
)
31643141
def zero_shot_image_classification(
31653142
self,
31663143
image: ContentT,
3167-
# temporarily keeping it optional for backward compatibility.
3168-
candidate_labels: List[str] = None, # type: ignore
3144+
candidate_labels: List[str],
31693145
*,
31703146
model: Optional[str] = None,
31713147
hypothesis_template: Optional[str] = None,
@@ -3210,15 +3186,6 @@ def zero_shot_image_classification(
32103186
[ZeroShotImageClassificationOutputElement(label='dog', score=0.956),...]
32113187
```
32123188
"""
3213-
# handle deprecation
3214-
if labels is not None:
3215-
if candidate_labels is not None:
3216-
raise ValueError(
3217-
"Cannot specify both `labels` and `candidate_labels`. Use `candidate_labels` instead."
3218-
)
3219-
candidate_labels = labels
3220-
elif candidate_labels is None:
3221-
raise ValueError("Must specify `candidate_labels`")
32223189
# Raise ValueError if input is less than 2 labels
32233190
if len(candidate_labels) < 2:
32243191
raise ValueError("You must specify at least 2 classes to compare.")

src/huggingface_hub/inference/_generated/_async_client.py

+3-36
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
)
8888
from huggingface_hub.inference._providers import PROVIDER_T, HFInferenceTask, get_provider_helper
8989
from huggingface_hub.utils import build_hf_headers, get_session, hf_raise_for_status
90-
from huggingface_hub.utils._deprecation import _deprecate_arguments, _deprecate_method
90+
from huggingface_hub.utils._deprecation import _deprecate_method
9191

9292
from .._common import _async_yield_from, _import_aiohttp
9393

@@ -3094,22 +3094,14 @@ async def visual_question_answering(
30943094
response = await self._inner_post(request_parameters)
30953095
return VisualQuestionAnsweringOutputElement.parse_obj_as_list(response)
30963096

3097-
@_deprecate_arguments(
3098-
version="0.30.0",
3099-
deprecated_args=["labels"],
3100-
custom_message="`labels`has been renamed to `candidate_labels` and will be removed in huggingface_hub>=0.30.0.",
3101-
)
31023097
async def zero_shot_classification(
31033098
self,
31043099
text: str,
3105-
# temporarily keeping it optional for backward compatibility.
3106-
candidate_labels: List[str] = None, # type: ignore
3100+
candidate_labels: List[str],
31073101
*,
31083102
multi_label: Optional[bool] = False,
31093103
hypothesis_template: Optional[str] = None,
31103104
model: Optional[str] = None,
3111-
# deprecated argument
3112-
labels: List[str] = None, # type: ignore
31133105
) -> List[ZeroShotClassificationOutputElement]:
31143106
"""
31153107
Provide as input a text and a set of candidate labels to classify the input text.
@@ -3190,16 +3182,6 @@ async def zero_shot_classification(
31903182
]
31913183
```
31923184
"""
3193-
# handle deprecation
3194-
if labels is not None:
3195-
if candidate_labels is not None:
3196-
raise ValueError(
3197-
"Cannot specify both `labels` and `candidate_labels`. Use `candidate_labels` instead."
3198-
)
3199-
candidate_labels = labels
3200-
elif candidate_labels is None:
3201-
raise ValueError("Must specify `candidate_labels`")
3202-
32033185
provider_helper = get_provider_helper(self.provider, task="zero-shot-classification")
32043186
request_parameters = provider_helper.prepare_request(
32053187
inputs=text,
@@ -3219,16 +3201,10 @@ async def zero_shot_classification(
32193201
for label, score in zip(output["labels"], output["scores"])
32203202
]
32213203

3222-
@_deprecate_arguments(
3223-
version="0.30.0",
3224-
deprecated_args=["labels"],
3225-
custom_message="`labels`has been renamed to `candidate_labels` and will be removed in huggingface_hub>=0.30.0.",
3226-
)
32273204
async def zero_shot_image_classification(
32283205
self,
32293206
image: ContentT,
3230-
# temporarily keeping it optional for backward compatibility.
3231-
candidate_labels: List[str] = None, # type: ignore
3207+
candidate_labels: List[str],
32323208
*,
32333209
model: Optional[str] = None,
32343210
hypothesis_template: Optional[str] = None,
@@ -3274,15 +3250,6 @@ async def zero_shot_image_classification(
32743250
[ZeroShotImageClassificationOutputElement(label='dog', score=0.956),...]
32753251
```
32763252
"""
3277-
# handle deprecation
3278-
if labels is not None:
3279-
if candidate_labels is not None:
3280-
raise ValueError(
3281-
"Cannot specify both `labels` and `candidate_labels`. Use `candidate_labels` instead."
3282-
)
3283-
candidate_labels = labels
3284-
elif candidate_labels is None:
3285-
raise ValueError("Must specify `candidate_labels`")
32863253
# Raise ValueError if input is less than 2 labels
32873254
if len(candidate_labels) < 2:
32883255
raise ValueError("You must specify at least 2 classes to compare.")

0 commit comments

Comments
 (0)