Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
1fc855e4
Commit
1fc855e4
authored
Jan 13, 2020
by
Julien Chaumond
Browse files
[tests] Safety checks on CONFIG_MAPPING
parent
3c86b6f3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletion
+11
-1
tests/test_configuration_auto.py
tests/test_configuration_auto.py
+11
-1
No files found.
tests/test_configuration_auto.py
View file @
1fc855e4
...
@@ -16,7 +16,7 @@
...
@@ -16,7 +16,7 @@
import
os
import
os
import
unittest
import
unittest
from
transformers.configuration_auto
import
AutoConfig
from
transformers.configuration_auto
import
CONFIG_MAPPING
,
AutoConfig
from
transformers.configuration_bert
import
BertConfig
from
transformers.configuration_bert
import
BertConfig
from
transformers.configuration_roberta
import
RobertaConfig
from
transformers.configuration_roberta
import
RobertaConfig
...
@@ -42,3 +42,13 @@ class AutoConfigTest(unittest.TestCase):
...
@@ -42,3 +42,13 @@ class AutoConfigTest(unittest.TestCase):
def
test_config_for_model_str
(
self
):
def
test_config_for_model_str
(
self
):
config
=
AutoConfig
.
for_model
(
"roberta"
)
config
=
AutoConfig
.
for_model
(
"roberta"
)
self
.
assertIsInstance
(
config
,
RobertaConfig
)
self
.
assertIsInstance
(
config
,
RobertaConfig
)
def
test_pattern_matching_fallback
(
self
):
"""
In cases where config.json doesn't include a model_type,
perform a few safety checks on the config mapping's order.
"""
# no key string should be included in a later key string (typical failure case)
keys
=
list
(
CONFIG_MAPPING
.
keys
())
for
i
,
key
in
enumerate
(
keys
):
self
.
assertFalse
(
any
(
key
in
later_key
for
later_key
in
keys
[
i
+
1
:]))
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