Skip to content

Commit

Permalink
Fix _configuration_file argument getting passed to model (#15629)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgugger authored and FrancescoSaverioZuppichini committed Feb 15, 2022
1 parent 6b519ef commit cf81a59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/transformers/configuration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ def _get_config_dict(
if os.path.isfile(pretrained_model_name_or_path) or is_remote_url(pretrained_model_name_or_path):
config_file = pretrained_model_name_or_path
else:
configuration_file = kwargs.get("_configuration_file", CONFIG_NAME)
configuration_file = kwargs.pop("_configuration_file", CONFIG_NAME)

if os.path.isdir(pretrained_model_name_or_path):
config_file = os.path.join(pretrained_model_name_or_path, configuration_file)
Expand Down
6 changes: 5 additions & 1 deletion tests/test_configuration_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,12 @@ def test_repo_versioning_before(self):
import transformers as new_transformers

new_transformers.configuration_utils.__version__ = "v4.0.0"
new_configuration = new_transformers.models.auto.AutoConfig.from_pretrained(repo)
new_configuration, kwargs = new_transformers.models.auto.AutoConfig.from_pretrained(
repo, return_unused_kwargs=True
)
self.assertEqual(new_configuration.hidden_size, 2)
# This checks `_configuration_file` ia not kept in the kwargs by mistake.
self.assertDictEqual(kwargs, {"_from_auto": True})

# Testing an older version by monkey-patching the version in the module it's used.
import transformers as old_transformers
Expand Down

0 comments on commit cf81a59

Please sign in to comment.