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
bbcd5eea
Unverified
Commit
bbcd5eea
authored
Nov 29, 2022
by
Sylvain Gugger
Committed by
GitHub
Nov 29, 2022
Browse files
Fix init import_structure sorting (#20477)
* Fix init import_structure sorting * Fix rebase
parent
3b91f96f
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
176 additions
and
167 deletions
+176
-167
src/transformers/__init__.py
src/transformers/__init__.py
+159
-160
src/transformers/models/speech_to_text/__init__.py
src/transformers/models/speech_to_text/__init__.py
+14
-4
utils/custom_init_isort.py
utils/custom_init_isort.py
+3
-3
No files found.
src/transformers/__init__.py
View file @
bbcd5eea
This diff is collapsed.
Click to expand it.
src/transformers/models/speech_to_text/__init__.py
View file @
bbcd5eea
...
...
@@ -47,8 +47,13 @@ except OptionalDependencyNotAvailable:
else
:
_import_structure
[
"feature_extraction_speech_to_text"
]
=
[
"Speech2TextFeatureExtractor"
]
if
is_sentencepiece_available
():
_import_structure
[
"processing_speech_to_text"
]
=
[
"Speech2TextProcessor"
]
try
:
if
not
(
is_speech_available
()
and
is_sentencepiece_available
()):
raise
OptionalDependencyNotAvailable
()
except
OptionalDependencyNotAvailable
:
pass
else
:
_import_structure
[
"processing_speech_to_text"
]
=
[
"Speech2TextProcessor"
]
try
:
if
not
is_tf_available
():
...
...
@@ -96,8 +101,13 @@ if TYPE_CHECKING:
else
:
from
.feature_extraction_speech_to_text
import
Speech2TextFeatureExtractor
if
is_sentencepiece_available
():
from
.processing_speech_to_text
import
Speech2TextProcessor
try
:
if
not
(
is_speech_available
()
and
is_sentencepiece_available
()):
raise
OptionalDependencyNotAvailable
()
except
OptionalDependencyNotAvailable
:
pass
else
:
from
.processing_speech_to_text
import
Speech2TextProcessor
try
:
if
not
is_tf_available
():
...
...
utils/custom_init_isort.py
View file @
bbcd5eea
...
...
@@ -200,9 +200,9 @@ def sort_imports(file, check_only=True):
indent
=
get_indent
(
block_lines
[
1
])
# Slit the internal block into blocks of indent level 1.
internal_blocks
=
split_code_in_indented_blocks
(
internal_block_code
,
indent_level
=
indent
)
# We have two categories of import key: list or _import_structu[key].append/extend
pattern
=
_re_direct_key
if
"_import_structure"
in
block_lines
[
0
]
else
_re_indirect_key
# Grab the keys, but there is a trap: some lines are empty or j
s
ut comments.
# We have two categories of import key: list or _import_structu
re
[key].append/extend
pattern
=
_re_direct_key
if
"_import_structure
= {
"
in
block_lines
[
0
]
else
_re_indirect_key
# Grab the keys, but there is a trap: some lines are empty or ju
s
t comments.
keys
=
[(
pattern
.
search
(
b
).
groups
()[
0
]
if
pattern
.
search
(
b
)
is
not
None
else
None
)
for
b
in
internal_blocks
]
# We only sort the lines with a key.
keys_to_sort
=
[(
i
,
key
)
for
i
,
key
in
enumerate
(
keys
)
if
key
is
not
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