Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
2dce350b
Unverified
Commit
2dce350b
authored
Feb 11, 2022
by
Sylvain Gugger
Committed by
GitHub
Feb 11, 2022
Browse files
Fix _configuration_file argument getting passed to model (#15629)
parent
85aee09e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
src/transformers/configuration_utils.py
src/transformers/configuration_utils.py
+1
-1
tests/test_configuration_common.py
tests/test_configuration_common.py
+5
-1
No files found.
src/transformers/configuration_utils.py
View file @
2dce350b
...
...
@@ -580,7 +580,7 @@ class PretrainedConfig(PushToHubMixin):
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
)
...
...
tests/test_configuration_common.py
View file @
2dce350b
...
...
@@ -334,8 +334,12 @@ class ConfigurationVersioningTest(unittest.TestCase):
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment