Skip to content

Commit

Permalink
Make sure telemetry arguments are not returned as unused kwargs (hugg…
Browse files Browse the repository at this point in the history
…ingface#17063)

* Make sure telemetry arguments are not returned as unused kwargs

* Fix test
  • Loading branch information
sgugger authored and nandwalritik committed May 4, 2022
1 parent eda1b02 commit b13cc89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/transformers/configuration_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,10 @@ def from_dict(cls, config_dict: Dict[str, Any], **kwargs) -> "PretrainedConfig":
[`PretrainedConfig`]: The configuration object instantiated from those parameters.
"""
return_unused_kwargs = kwargs.pop("return_unused_kwargs", False)
# Those arguments may be passed along for our internal telemetry.
# We remove them so they don't appear in `return_unused_kwargs`.
kwargs.pop("_from_auto", None)
kwargs.pop("_from_pipeline", None)

config = cls(**config_dict)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_configuration_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ def test_repo_versioning_before(self):
)
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})
self.assertDictEqual(kwargs, {})

# 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 b13cc89

Please sign in to comment.