Skip to content

Commit

Permalink
Fix resume_download future warning (#31007)
Browse files Browse the repository at this point in the history
* Fix resume_download future warning

* better like this

* Add regression test
  • Loading branch information
Wauplin authored May 24, 2024
1 parent acbfaf6 commit fd3c128
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/transformers/configuration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ def _get_config_dict(
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
cache_dir = kwargs.pop("cache_dir", None)
force_download = kwargs.pop("force_download", False)
resume_download = kwargs.pop("resume_download", False)
resume_download = kwargs.pop("resume_download", None)
proxies = kwargs.pop("proxies", None)
token = kwargs.pop("token", None)
local_files_only = kwargs.pop("local_files_only", False)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_configuration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import tempfile
import unittest
import unittest.mock as mock
import warnings
from pathlib import Path

from huggingface_hub import HfFolder, delete_repo
Expand Down Expand Up @@ -306,3 +307,10 @@ def test_has_non_default_generation_parameters(self):
self.assertTrue(config._has_non_default_generation_parameters())
config = BertConfig(min_length=0) # `min_length = 0` is a default generation kwarg
self.assertFalse(config._has_non_default_generation_parameters())

def test_loading_config_do_not_raise_future_warnings(self):
"""Regression test for https://github.com/huggingface/transformers/issues/31002."""
# Loading config should not raise a FutureWarning. It was the case before.
with warnings.catch_warnings():
warnings.simplefilter("error")
PretrainedConfig.from_pretrained("bert-base-uncased")

0 comments on commit fd3c128

Please sign in to comment.