Skip to content

Commit

Permalink
Remove deprecated code for v0.16.x (#1492)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wauplin authored Jun 2, 2023
1 parent ee71a81 commit 0410930
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/huggingface_hub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
from typing import TYPE_CHECKING


__version__ = "0.15.0.dev0"
__version__ = "0.16.0.dev0"

# Alphabetical order of definitions is ensured in tests
# WARNING: any comment added in this dictionary definition will be lost when
Expand Down
24 changes: 3 additions & 21 deletions src/huggingface_hub/hub_mixin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import os
import warnings
from pathlib import Path
from typing import Dict, List, Optional, Type, TypeVar, Union

Expand All @@ -10,7 +9,6 @@
from .file_download import hf_hub_download, is_torch_available
from .hf_api import HfApi
from .utils import SoftTemporaryDirectory, logging, validate_hf_hub_args
from .utils._deprecation import _deprecate_positional_args


if is_torch_available():
Expand All @@ -31,7 +29,6 @@ class ModelHubMixin:
of mixin integration with the Hub. Check out our [integration guide](../guides/integrations) for more instructions.
"""

@_deprecate_positional_args(version="0.16")
def save_pretrained(
self,
save_directory: Union[str, Path],
Expand Down Expand Up @@ -89,7 +86,6 @@ def _save_pretrained(self, save_directory: Path) -> None:

@classmethod
@validate_hf_hub_args
@_deprecate_positional_args(version="0.16")
def from_pretrained(
cls: Type[T],
pretrained_model_name_or_path: Union[str, Path],
Expand Down Expand Up @@ -133,18 +129,6 @@ def from_pretrained(
Additional kwargs to pass to the model during initialization.
"""
model_id = pretrained_model_name_or_path

if isinstance(model_id, str) and len(model_id.split("@")) == 2:
warnings.warn(
(
"Passing a revision using 'namespace/model_id@revision' pattern is"
" deprecated and will be removed in version v0.16. Please pass"
" 'revision=...' as argument."
),
FutureWarning,
)
model_id, revision = model_id.split("@")

config_file: Optional[str] = None
if os.path.isdir(model_id):
if CONFIG_NAME in os.listdir(model_id):
Expand Down Expand Up @@ -173,7 +157,7 @@ def from_pretrained(
model_kwargs.update({"config": config})

return cls._from_pretrained(
model_id=model_id,
model_id=str(model_id),
revision=revision,
cache_dir=cache_dir,
force_download=force_download,
Expand All @@ -185,7 +169,6 @@ def from_pretrained(
)

@classmethod
@_deprecate_positional_args(version="0.16")
def _from_pretrained(
cls: Type[T],
*,
Expand Down Expand Up @@ -347,13 +330,12 @@ def _save_pretrained(self, save_directory: Path) -> None:
torch.save(model_to_save.state_dict(), save_directory / PYTORCH_WEIGHTS_NAME)

@classmethod
@_deprecate_positional_args(version="0.16")
def _from_pretrained(
cls,
*,
model_id: str,
revision: str,
cache_dir: str,
revision: Optional[str],
cache_dir: Optional[Union[str, Path]],
force_download: bool,
proxies: Optional[Dict],
resume_download: bool,
Expand Down

0 comments on commit 0410930

Please sign in to comment.