Update deprecated load_module (#21651)
This commit is contained in:
@@ -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__)
|
|||||||
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 = {
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
@@ -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(
|
|||||||
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
|
||||||
|
|
||||||
|
|||||||
@@ -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(
|
|||||||
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
|
||||||
|
|
||||||
|
|||||||
@@ -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(
|
|||||||
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):
|
||||||
|
|||||||
@@ -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():
|
|||||||
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
|
||||||
|
|||||||
@@ -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(
|
|||||||
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():
|
||||||
|
|||||||
@@ -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(
|
|||||||
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
|
||||||
|
|||||||
@@ -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(
|
|||||||
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,
|
||||||
|
|||||||
@@ -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(
|
|||||||
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.
|
||||||
|
|||||||
Reference in New Issue
Block a user