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
9b0d2860
"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "f3ed26a3fbb4889030441e4dffa28fec7fd16d71"
Unverified
Commit
9b0d2860
authored
May 16, 2022
by
Sylvain Gugger
Committed by
GitHub
May 16, 2022
Browse files
Better error in the Auto API when a dep is missing (#17289)
parent
66b3e106
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
0 deletions
+18
-0
src/transformers/models/auto/feature_extraction_auto.py
src/transformers/models/auto/feature_extraction_auto.py
+6
-0
src/transformers/models/auto/processing_auto.py
src/transformers/models/auto/processing_auto.py
+6
-0
src/transformers/models/auto/tokenization_auto.py
src/transformers/models/auto/tokenization_auto.py
+6
-0
No files found.
src/transformers/models/auto/feature_extraction_auto.py
View file @
9b0d2860
...
@@ -84,6 +84,12 @@ def feature_extractor_class_from_name(class_name: str):
...
@@ -84,6 +84,12 @@ def feature_extractor_class_from_name(class_name: str):
if
getattr
(
extractor
,
"__name__"
,
None
)
==
class_name
:
if
getattr
(
extractor
,
"__name__"
,
None
)
==
class_name
:
return
extractor
return
extractor
# We did not fine the class, but maybe it's because a dep is missing. In that case, the class will be in the main
# init and we return the proper dummy to get an appropriate error message.
main_module
=
importlib
.
import_module
(
"transformers"
)
if
hasattr
(
main_module
,
class_name
):
return
getattr
(
main_module
,
class_name
)
return
None
return
None
...
...
src/transformers/models/auto/processing_auto.py
View file @
9b0d2860
...
@@ -74,6 +74,12 @@ def processor_class_from_name(class_name: str):
...
@@ -74,6 +74,12 @@ def processor_class_from_name(class_name: str):
if
getattr
(
processor
,
"__name__"
,
None
)
==
class_name
:
if
getattr
(
processor
,
"__name__"
,
None
)
==
class_name
:
return
processor
return
processor
# We did not fine the class, but maybe it's because a dep is missing. In that case, the class will be in the main
# init and we return the proper dummy to get an appropriate error message.
main_module
=
importlib
.
import_module
(
"transformers"
)
if
hasattr
(
main_module
,
class_name
):
return
getattr
(
main_module
,
class_name
)
return
None
return
None
...
...
src/transformers/models/auto/tokenization_auto.py
View file @
9b0d2860
...
@@ -287,6 +287,12 @@ def tokenizer_class_from_name(class_name: str):
...
@@ -287,6 +287,12 @@ def tokenizer_class_from_name(class_name: str):
if
getattr
(
tokenizer
,
"__name__"
,
None
)
==
class_name
:
if
getattr
(
tokenizer
,
"__name__"
,
None
)
==
class_name
:
return
tokenizer
return
tokenizer
# We did not fine the class, but maybe it's because a dep is missing. In that case, the class will be in the main
# init and we return the proper dummy to get an appropriate error message.
main_module
=
importlib
.
import_module
(
"transformers"
)
if
hasattr
(
main_module
,
class_name
):
return
getattr
(
main_module
,
class_name
)
return
None
return
None
...
...
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