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
5f436238
Unverified
Commit
5f436238
authored
Jul 26, 2021
by
Sylvain Gugger
Committed by
GitHub
Jul 26, 2021
Browse files
Add possibility to ignore imports in test_fecther (#12801)
* Add possibility to ignore imports in test_fecther * Style
parent
7c300d6d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
5 deletions
+7
-5
src/transformers/tokenization_utils_base.py
src/transformers/tokenization_utils_base.py
+3
-3
utils/tests_fetcher.py
utils/tests_fetcher.py
+4
-2
No files found.
src/transformers/tokenization_utils_base.py
View file @
5f436238
...
@@ -1769,7 +1769,7 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
...
@@ -1769,7 +1769,7 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
init_kwargs
=
init_configuration
init_kwargs
=
init_configuration
if
config_tokenizer_class
is
None
:
if
config_tokenizer_class
is
None
:
from
.models.auto.configuration_auto
import
AutoConfig
from
.models.auto.configuration_auto
import
AutoConfig
# tests_ignore
# Second attempt. If we have not yet found tokenizer_class, let's try to use the config.
# Second attempt. If we have not yet found tokenizer_class, let's try to use the config.
try
:
try
:
...
@@ -1781,8 +1781,8 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
...
@@ -1781,8 +1781,8 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
if
config_tokenizer_class
is
None
:
if
config_tokenizer_class
is
None
:
# Third attempt. If we have not yet found the original type of the tokenizer,
# Third attempt. If we have not yet found the original type of the tokenizer,
# we are loading we see if we can infer it from the type of the configuration file
# we are loading we see if we can infer it from the type of the configuration file
from
.models.auto.configuration_auto
import
CONFIG_MAPPING
from
.models.auto.configuration_auto
import
CONFIG_MAPPING
# tests_ignore
from
.models.auto.tokenization_auto
import
TOKENIZER_MAPPING
from
.models.auto.tokenization_auto
import
TOKENIZER_MAPPING
# tests_ignore
if
hasattr
(
config
,
"model_type"
):
if
hasattr
(
config
,
"model_type"
):
config_class
=
CONFIG_MAPPING
.
get
(
config
.
model_type
)
config_class
=
CONFIG_MAPPING
.
get
(
config
.
model_type
)
...
...
utils/tests_fetcher.py
View file @
5f436238
...
@@ -131,7 +131,8 @@ def get_module_dependencies(module_fname):
...
@@ -131,7 +131,8 @@ def get_module_dependencies(module_fname):
imported_modules
=
[]
imported_modules
=
[]
# Let's start with relative imports
# Let's start with relative imports
relative_imports
=
re
.
findall
(
r
"from\s+(\.+\S+)\s+import\s+\S+\s"
,
content
)
relative_imports
=
re
.
findall
(
r
"from\s+(\.+\S+)\s+import\s+([^\n]+)\n"
,
content
)
relative_imports
=
[
mod
for
mod
,
imp
in
relative_imports
if
"# tests_ignore"
not
in
imp
]
for
imp
in
relative_imports
:
for
imp
in
relative_imports
:
level
=
0
level
=
0
while
imp
.
startswith
(
"."
):
while
imp
.
startswith
(
"."
):
...
@@ -151,7 +152,8 @@ def get_module_dependencies(module_fname):
...
@@ -151,7 +152,8 @@ def get_module_dependencies(module_fname):
# Let's continue with direct imports
# Let's continue with direct imports
# The import from the transformers module are ignored for the same reason we ignored the
# The import from the transformers module are ignored for the same reason we ignored the
# main init before.
# main init before.
direct_imports
=
re
.
findall
(
r
"from\s+transformers\.(\S+)\s+import\s+\S+\s"
,
content
)
direct_imports
=
re
.
findall
(
r
"from\s+transformers\.(\S+)\s+import\s+([^\n]+)\n"
,
content
)
direct_imports
=
[
mod
for
mod
,
imp
in
direct_imports
if
"# tests_ignore"
not
in
imp
]
for
imp
in
direct_imports
:
for
imp
in
direct_imports
:
import_parts
=
imp
.
split
(
"."
)
import_parts
=
imp
.
split
(
"."
)
dep_parts
=
[
"src"
,
"transformers"
]
+
import_parts
dep_parts
=
[
"src"
,
"transformers"
]
+
import_parts
...
...
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