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
9d1116e9
Unverified
Commit
9d1116e9
authored
Feb 15, 2023
by
Sylvain Gugger
Committed by
GitHub
Feb 15, 2023
Browse files
Update deprecated load_module (#21651)
parent
1567bef3
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
39 additions
and
10 deletions
+39
-10
src/transformers/processing_utils.py
src/transformers/processing_utils.py
+4
-1
tests/pipelines/test_pipelines_common.py
tests/pipelines/test_pipelines_common.py
+3
-1
utils/check_config_attributes.py
utils/check_config_attributes.py
+4
-1
utils/check_config_docstrings.py
utils/check_config_docstrings.py
+4
-1
utils/check_copies.py
utils/check_copies.py
+4
-1
utils/check_inits.py
utils/check_inits.py
+4
-1
utils/check_repo.py
utils/check_repo.py
+4
-1
utils/check_table.py
utils/check_table.py
+4
-1
utils/check_task_guides.py
utils/check_task_guides.py
+4
-1
utils/update_metadata.py
utils/update_metadata.py
+4
-1
No files found.
src/transformers/processing_utils.py
View file @
9d1116e9
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
import
importlib.util
import
importlib.util
import
os
import
os
import
sys
from
pathlib
import
Path
from
pathlib
import
Path
from
.dynamic_module_utils
import
custom_object_save
from
.dynamic_module_utils
import
custom_object_save
...
@@ -31,7 +32,9 @@ logger = logging.get_logger(__name__)
...
@@ -31,7 +32,9 @@ logger = logging.get_logger(__name__)
spec
=
importlib
.
util
.
spec_from_file_location
(
spec
=
importlib
.
util
.
spec_from_file_location
(
"transformers"
,
Path
(
__file__
).
parent
/
"__init__.py"
,
submodule_search_locations
=
[
Path
(
__file__
).
parent
]
"transformers"
,
Path
(
__file__
).
parent
/
"__init__.py"
,
submodule_search_locations
=
[
Path
(
__file__
).
parent
]
)
)
transformers_module
=
spec
.
loader
.
load_module
()
transformers_module
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
transformers_module
)
transformers_module
=
sys
.
modules
[
"transformers"
]
AUTO_TO_BASE_CLASS_MAPPING
=
{
AUTO_TO_BASE_CLASS_MAPPING
=
{
...
...
tests/pipelines/test_pipelines_common.py
View file @
9d1116e9
...
@@ -74,7 +74,9 @@ spec = importlib.util.spec_from_file_location(
...
@@ -74,7 +74,9 @@ spec = importlib.util.spec_from_file_location(
os
.
path
.
join
(
PATH_TO_TRANSFORMERS
,
"__init__.py"
),
os
.
path
.
join
(
PATH_TO_TRANSFORMERS
,
"__init__.py"
),
submodule_search_locations
=
[
PATH_TO_TRANSFORMERS
],
submodule_search_locations
=
[
PATH_TO_TRANSFORMERS
],
)
)
transformers_module
=
spec
.
loader
.
load_module
()
transformers_module
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
transformers_module
)
transformers_module
=
sys
.
modules
[
"transformers"
]
class
ANY
:
class
ANY
:
...
...
utils/check_config_attributes.py
View file @
9d1116e9
...
@@ -17,6 +17,7 @@ import importlib
...
@@ -17,6 +17,7 @@ import importlib
import
inspect
import
inspect
import
os
import
os
import
re
import
re
import
sys
# All paths are set with the intent you should run this script from the root of the repo with the command
# All paths are set with the intent you should run this script from the root of the repo with the command
...
@@ -30,7 +31,9 @@ spec = importlib.util.spec_from_file_location(
...
@@ -30,7 +31,9 @@ spec = importlib.util.spec_from_file_location(
os
.
path
.
join
(
PATH_TO_TRANSFORMERS
,
"__init__.py"
),
os
.
path
.
join
(
PATH_TO_TRANSFORMERS
,
"__init__.py"
),
submodule_search_locations
=
[
PATH_TO_TRANSFORMERS
],
submodule_search_locations
=
[
PATH_TO_TRANSFORMERS
],
)
)
transformers
=
spec
.
loader
.
load_module
()
transformers
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
transformers
)
transformers
=
sys
.
modules
[
"transformers"
]
CONFIG_MAPPING
=
transformers
.
models
.
auto
.
configuration_auto
.
CONFIG_MAPPING
CONFIG_MAPPING
=
transformers
.
models
.
auto
.
configuration_auto
.
CONFIG_MAPPING
...
...
utils/check_config_docstrings.py
View file @
9d1116e9
...
@@ -17,6 +17,7 @@ import importlib
...
@@ -17,6 +17,7 @@ import importlib
import
inspect
import
inspect
import
os
import
os
import
re
import
re
import
sys
# All paths are set with the intent you should run this script from the root of the repo with the command
# All paths are set with the intent you should run this script from the root of the repo with the command
...
@@ -30,7 +31,9 @@ spec = importlib.util.spec_from_file_location(
...
@@ -30,7 +31,9 @@ spec = importlib.util.spec_from_file_location(
os
.
path
.
join
(
PATH_TO_TRANSFORMERS
,
"__init__.py"
),
os
.
path
.
join
(
PATH_TO_TRANSFORMERS
,
"__init__.py"
),
submodule_search_locations
=
[
PATH_TO_TRANSFORMERS
],
submodule_search_locations
=
[
PATH_TO_TRANSFORMERS
],
)
)
transformers
=
spec
.
loader
.
load_module
()
transformers
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
transformers
)
transformers
=
sys
.
modules
[
"transformers"
]
CONFIG_MAPPING
=
transformers
.
models
.
auto
.
configuration_auto
.
CONFIG_MAPPING
CONFIG_MAPPING
=
transformers
.
models
.
auto
.
configuration_auto
.
CONFIG_MAPPING
...
...
utils/check_copies.py
View file @
9d1116e9
...
@@ -18,6 +18,7 @@ import glob
...
@@ -18,6 +18,7 @@ import glob
import
importlib.util
import
importlib.util
import
os
import
os
import
re
import
re
import
sys
import
black
import
black
from
doc_builder.style_doc
import
style_docstrings_in_code
from
doc_builder.style_doc
import
style_docstrings_in_code
...
@@ -103,7 +104,9 @@ spec = importlib.util.spec_from_file_location(
...
@@ -103,7 +104,9 @@ spec = importlib.util.spec_from_file_location(
os
.
path
.
join
(
TRANSFORMERS_PATH
,
"__init__.py"
),
os
.
path
.
join
(
TRANSFORMERS_PATH
,
"__init__.py"
),
submodule_search_locations
=
[
TRANSFORMERS_PATH
],
submodule_search_locations
=
[
TRANSFORMERS_PATH
],
)
)
transformers_module
=
spec
.
loader
.
load_module
()
transformers_module
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
transformers_module
)
transformers_module
=
sys
.
modules
[
"transformers"
]
def
_should_continue
(
line
,
indent
):
def
_should_continue
(
line
,
indent
):
...
...
utils/check_inits.py
View file @
9d1116e9
...
@@ -17,6 +17,7 @@ import collections
...
@@ -17,6 +17,7 @@ import collections
import
importlib.util
import
importlib.util
import
os
import
os
import
re
import
re
import
sys
from
pathlib
import
Path
from
pathlib
import
Path
...
@@ -279,7 +280,9 @@ def check_submodules():
...
@@ -279,7 +280,9 @@ def check_submodules():
os
.
path
.
join
(
PATH_TO_TRANSFORMERS
,
"__init__.py"
),
os
.
path
.
join
(
PATH_TO_TRANSFORMERS
,
"__init__.py"
),
submodule_search_locations
=
[
PATH_TO_TRANSFORMERS
],
submodule_search_locations
=
[
PATH_TO_TRANSFORMERS
],
)
)
transformers
=
spec
.
loader
.
load_module
()
transformers
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
transformers
)
transformers
=
sys
.
modules
[
"transformers"
]
module_not_registered
=
[
module_not_registered
=
[
module
module
...
...
utils/check_repo.py
View file @
9d1116e9
...
@@ -17,6 +17,7 @@ import importlib
...
@@ -17,6 +17,7 @@ import importlib
import
inspect
import
inspect
import
os
import
os
import
re
import
re
import
sys
import
warnings
import
warnings
from
collections
import
OrderedDict
from
collections
import
OrderedDict
from
difflib
import
get_close_matches
from
difflib
import
get_close_matches
...
@@ -311,7 +312,9 @@ spec = importlib.util.spec_from_file_location(
...
@@ -311,7 +312,9 @@ spec = importlib.util.spec_from_file_location(
os
.
path
.
join
(
PATH_TO_TRANSFORMERS
,
"__init__.py"
),
os
.
path
.
join
(
PATH_TO_TRANSFORMERS
,
"__init__.py"
),
submodule_search_locations
=
[
PATH_TO_TRANSFORMERS
],
submodule_search_locations
=
[
PATH_TO_TRANSFORMERS
],
)
)
transformers
=
spec
.
loader
.
load_module
()
transformers
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
transformers
)
transformers
=
sys
.
modules
[
"transformers"
]
def
check_model_list
():
def
check_model_list
():
...
...
utils/check_table.py
View file @
9d1116e9
...
@@ -18,6 +18,7 @@ import collections
...
@@ -18,6 +18,7 @@ import collections
import
importlib.util
import
importlib.util
import
os
import
os
import
re
import
re
import
sys
# All paths are set with the intent you should run this script from the root of the repo with the command
# All paths are set with the intent you should run this script from the root of the repo with the command
...
@@ -68,7 +69,9 @@ spec = importlib.util.spec_from_file_location(
...
@@ -68,7 +69,9 @@ spec = importlib.util.spec_from_file_location(
os
.
path
.
join
(
TRANSFORMERS_PATH
,
"__init__.py"
),
os
.
path
.
join
(
TRANSFORMERS_PATH
,
"__init__.py"
),
submodule_search_locations
=
[
TRANSFORMERS_PATH
],
submodule_search_locations
=
[
TRANSFORMERS_PATH
],
)
)
transformers_module
=
spec
.
loader
.
load_module
()
transformers_module
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
transformers_module
)
transformers_module
=
sys
.
modules
[
"transformers"
]
# Thanks to https://stackoverflow.com/questions/29916065/how-to-do-camelcase-split-in-python
# Thanks to https://stackoverflow.com/questions/29916065/how-to-do-camelcase-split-in-python
...
...
utils/check_task_guides.py
View file @
9d1116e9
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
import
argparse
import
argparse
import
importlib.util
import
importlib.util
import
os
import
os
import
sys
# All paths are set with the intent you should run this script from the root of the repo with the command
# All paths are set with the intent you should run this script from the root of the repo with the command
...
@@ -56,7 +57,9 @@ spec = importlib.util.spec_from_file_location(
...
@@ -56,7 +57,9 @@ spec = importlib.util.spec_from_file_location(
os
.
path
.
join
(
TRANSFORMERS_PATH
,
"__init__.py"
),
os
.
path
.
join
(
TRANSFORMERS_PATH
,
"__init__.py"
),
submodule_search_locations
=
[
TRANSFORMERS_PATH
],
submodule_search_locations
=
[
TRANSFORMERS_PATH
],
)
)
transformers_module
=
spec
.
loader
.
load_module
()
transformers_module
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
transformers_module
)
transformers_module
=
sys
.
modules
[
"transformers"
]
TASK_GUIDE_TO_MODELS
=
{
TASK_GUIDE_TO_MODELS
=
{
"asr.mdx"
:
transformers_module
.
models
.
auto
.
modeling_auto
.
MODEL_FOR_CTC_MAPPING_NAMES
,
"asr.mdx"
:
transformers_module
.
models
.
auto
.
modeling_auto
.
MODEL_FOR_CTC_MAPPING_NAMES
,
...
...
utils/update_metadata.py
View file @
9d1116e9
...
@@ -18,6 +18,7 @@ import collections
...
@@ -18,6 +18,7 @@ import collections
import
importlib.util
import
importlib.util
import
os
import
os
import
re
import
re
import
sys
import
tempfile
import
tempfile
import
pandas
as
pd
import
pandas
as
pd
...
@@ -36,7 +37,9 @@ spec = importlib.util.spec_from_file_location(
...
@@ -36,7 +37,9 @@ spec = importlib.util.spec_from_file_location(
os
.
path
.
join
(
TRANSFORMERS_PATH
,
"__init__.py"
),
os
.
path
.
join
(
TRANSFORMERS_PATH
,
"__init__.py"
),
submodule_search_locations
=
[
TRANSFORMERS_PATH
],
submodule_search_locations
=
[
TRANSFORMERS_PATH
],
)
)
transformers_module
=
spec
.
loader
.
load_module
()
transformers_module
=
importlib
.
util
.
module_from_spec
(
spec
)
spec
.
loader
.
exec_module
(
transformers_module
)
transformers_module
=
sys
.
modules
[
"transformers"
]
# Regexes that match TF/Flax/PT model names.
# Regexes that match TF/Flax/PT model names.
...
...
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