Reorganize file utils (#16264)
* Split file_utils in several submodules * Fixes * Add back more objects * More fixes * Who exactly decided to import that from there? * Second suggestion to code with code review * Revert wront move * Fix imports * Adapt all imports * Adapt all imports everywhere * Revert this import, will fix in a separate commit
This commit is contained in:
@@ -874,7 +874,7 @@ NEW_BERT_CONSTANT = "value"
|
||||
test_init = """
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...file_utils import _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available
|
||||
from ...utils import _LazyModule, is_flax_available, is_tf_available, is_tokenizers_available, is_torch_available
|
||||
|
||||
_import_structure = {
|
||||
"configuration_gpt2": ["GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPT2Config", "GPT2OnnxConfig"],
|
||||
@@ -918,7 +918,7 @@ else:
|
||||
init_no_tokenizer = """
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...file_utils import _LazyModule, is_flax_available, is_tf_available, is_torch_available
|
||||
from ...utils import _LazyModule, is_flax_available, is_tf_available, is_torch_available
|
||||
|
||||
_import_structure = {
|
||||
"configuration_gpt2": ["GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPT2Config", "GPT2OnnxConfig"],
|
||||
@@ -954,7 +954,7 @@ else:
|
||||
init_pt_only = """
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...file_utils import _LazyModule, is_tokenizers_available, is_torch_available
|
||||
from ...utils import _LazyModule, is_tokenizers_available, is_torch_available
|
||||
|
||||
_import_structure = {
|
||||
"configuration_gpt2": ["GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPT2Config", "GPT2OnnxConfig"],
|
||||
@@ -986,7 +986,7 @@ else:
|
||||
init_pt_only_no_tokenizer = """
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...file_utils import _LazyModule, is_torch_available
|
||||
from ...utils import _LazyModule, is_torch_available
|
||||
|
||||
_import_structure = {
|
||||
"configuration_gpt2": ["GPT2_PRETRAINED_CONFIG_ARCHIVE_MAP", "GPT2Config", "GPT2OnnxConfig"],
|
||||
@@ -1026,7 +1026,7 @@ else:
|
||||
test_init = """
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...file_utils import _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available
|
||||
from ...utils import _LazyModule, is_flax_available, is_tf_available, is_torch_available, is_vision_available
|
||||
|
||||
_import_structure = {
|
||||
"configuration_vit": ["VIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTConfig"],
|
||||
@@ -1068,7 +1068,7 @@ else:
|
||||
init_no_feature_extractor = """
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...file_utils import _LazyModule, is_flax_available, is_tf_available, is_torch_available
|
||||
from ...utils import _LazyModule, is_flax_available, is_tf_available, is_torch_available
|
||||
|
||||
_import_structure = {
|
||||
"configuration_vit": ["VIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTConfig"],
|
||||
@@ -1104,7 +1104,7 @@ else:
|
||||
init_pt_only = """
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...file_utils import _LazyModule, is_torch_available, is_vision_available
|
||||
from ...utils import _LazyModule, is_torch_available, is_vision_available
|
||||
|
||||
_import_structure = {
|
||||
"configuration_vit": ["VIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTConfig"],
|
||||
@@ -1134,7 +1134,7 @@ else:
|
||||
init_pt_only_no_feature_extractor = """
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from ...file_utils import _LazyModule, is_torch_available
|
||||
from ...utils import _LazyModule, is_torch_available
|
||||
|
||||
_import_structure = {
|
||||
"configuration_vit": ["VIT_PRETRAINED_CONFIG_ARCHIVE_MAP", "ViTConfig"],
|
||||
|
||||
@@ -24,7 +24,8 @@ import transformers
|
||||
|
||||
# Try to import everything from transformers to ensure every object can be loaded.
|
||||
from transformers import * # noqa F406
|
||||
from transformers.file_utils import (
|
||||
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER
|
||||
from transformers.utils import (
|
||||
CONFIG_NAME,
|
||||
FLAX_WEIGHTS_NAME,
|
||||
TF2_WEIGHTS_NAME,
|
||||
@@ -39,7 +40,6 @@ from transformers.file_utils import (
|
||||
has_file,
|
||||
hf_bucket_url,
|
||||
)
|
||||
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER
|
||||
|
||||
|
||||
MODEL_ID = DUMMY_UNKNOWN_IDENTIFIER
|
||||
|
||||
@@ -17,7 +17,7 @@ import unittest
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
|
||||
from transformers.file_utils import ModelOutput
|
||||
from transformers.utils import ModelOutput
|
||||
|
||||
|
||||
@dataclass
|
||||
|
||||
Reference in New Issue
Block a user