[Test refactor 1/5] Per-folder tests reorganization (#15725)
* Per-folder tests reorganization Co-authored-by: sgugger <sylvain.gugger@gmail.com> Co-authored-by: Stas Bekman <stas@stason.org>
This commit is contained in:
parent
fecb08c2b8
commit
29c10a41d0
|
@ -16,6 +16,8 @@ env:
|
|||
MKL_NUM_THREADS: 16
|
||||
PYTEST_TIMEOUT: 600
|
||||
SIGOPT_API_TOKEN: ${{ secrets.SIGOPT_API_TOKEN }}
|
||||
TF_FORCE_GPU_ALLOW_GROWTH: true
|
||||
RUN_PT_TF_CROSS_TESTS: 1
|
||||
|
||||
jobs:
|
||||
run_all_tests_torch_gpu:
|
||||
|
|
|
@ -22,7 +22,7 @@ from os.path import abspath, dirname, join
|
|||
|
||||
# allow having multiple repository checkouts and not needing to remember to rerun
|
||||
# 'pip install -e .[dev]' when switching between checkouts and running tests.
|
||||
git_repo_path = abspath(join(dirname(dirname(__file__)), "src"))
|
||||
git_repo_path = abspath(join(dirname(__file__), "src"))
|
||||
sys.path.insert(1, git_repo_path)
|
||||
|
||||
# silence FutureWarning warnings in tests since often we can't act on them until
|
|
@ -131,7 +131,7 @@ class AddNewModelCommand(BaseTransformersCLICommand):
|
|||
|
||||
shutil.move(
|
||||
f"{directory}/test_modeling_{lowercase_model_name}.py",
|
||||
f"{path_to_transformer_root}/tests/test_modeling_{lowercase_model_name}.py",
|
||||
f"{path_to_transformer_root}/tests/{lowercase_model_name}/test_modeling_{lowercase_model_name}.py",
|
||||
)
|
||||
else:
|
||||
os.remove(f"{directory}/modeling_{lowercase_model_name}.py")
|
||||
|
@ -148,7 +148,7 @@ class AddNewModelCommand(BaseTransformersCLICommand):
|
|||
|
||||
shutil.move(
|
||||
f"{directory}/test_modeling_tf_{lowercase_model_name}.py",
|
||||
f"{path_to_transformer_root}/tests/test_modeling_tf_{lowercase_model_name}.py",
|
||||
f"{path_to_transformer_root}/tests/{lowercase_model_name}/test_modeling_tf_{lowercase_model_name}.py",
|
||||
)
|
||||
else:
|
||||
os.remove(f"{directory}/modeling_tf_{lowercase_model_name}.py")
|
||||
|
@ -165,7 +165,7 @@ class AddNewModelCommand(BaseTransformersCLICommand):
|
|||
|
||||
shutil.move(
|
||||
f"{directory}/test_modeling_flax_{lowercase_model_name}.py",
|
||||
f"{path_to_transformer_root}/tests/test_modeling_flax_{lowercase_model_name}.py",
|
||||
f"{path_to_transformer_root}/tests/{lowercase_model_name}/test_modeling_flax_{lowercase_model_name}.py",
|
||||
)
|
||||
else:
|
||||
os.remove(f"{directory}/modeling_flax_{lowercase_model_name}.py")
|
||||
|
|
|
@ -554,7 +554,7 @@ def get_model_files(model_type: str, frameworks: Optional[List[str]] = None) ->
|
|||
]
|
||||
test_files = filter_framework_files(test_files, frameworks=frameworks)
|
||||
# Add the test directory
|
||||
test_files = [REPO_PATH / "tests" / f for f in test_files]
|
||||
test_files = [REPO_PATH / "tests" / module_name / f for f in test_files]
|
||||
# Filter by existing files
|
||||
test_files = [f for f in test_files if f.exists()]
|
||||
|
||||
|
|
|
@ -689,6 +689,10 @@ def get_tests_dir(append_path=None):
|
|||
# this function caller's __file__
|
||||
caller__file__ = inspect.stack()[1][1]
|
||||
tests_dir = os.path.abspath(os.path.dirname(caller__file__))
|
||||
|
||||
while not tests_dir.endswith("tests"):
|
||||
tests_dir = os.path.dirname(tests_dir)
|
||||
|
||||
if append_path:
|
||||
return os.path.join(tests_dir, append_path)
|
||||
else:
|
||||
|
@ -1270,10 +1274,10 @@ def pytest_terminal_summary_main(tr, id):
|
|||
orig_tbstyle = config.option.tbstyle
|
||||
orig_reportchars = tr.reportchars
|
||||
|
||||
dir = "reports"
|
||||
dir = f"reports/{id}"
|
||||
Path(dir).mkdir(parents=True, exist_ok=True)
|
||||
report_files = {
|
||||
k: f"{dir}/{id}_{k}.txt"
|
||||
k: f"{dir}/{k}.txt"
|
||||
for k in [
|
||||
"durations",
|
||||
"errors",
|
||||
|
|
|
@ -20,8 +20,8 @@ import unittest
|
|||
from transformers import is_flax_available, {{cookiecutter.camelcase_modelname}}Config
|
||||
from transformers.testing_utils import require_flax, slow
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor
|
||||
|
||||
if is_flax_available():
|
||||
import numpy as np
|
||||
|
@ -345,8 +345,8 @@ from transformers import (
|
|||
)
|
||||
from transformers.testing_utils import require_sentencepiece, require_flax, require_tokenizers, slow
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor
|
||||
|
||||
|
||||
if is_flax_available():
|
||||
|
|
|
@ -20,8 +20,8 @@ import unittest
|
|||
from transformers import is_tf_available, {{cookiecutter.camelcase_modelname}}Config
|
||||
from transformers.testing_utils import require_tf, slow
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
|
||||
|
||||
|
||||
if is_tf_available():
|
||||
|
@ -360,8 +360,8 @@ from transformers import (
|
|||
)
|
||||
from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
|
||||
|
||||
|
||||
if is_tf_available():
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
{% if cookiecutter.is_encoder_decoder_model == "False" -%}
|
||||
import unittest
|
||||
|
||||
from tests.test_modeling_common import floats_tensor
|
||||
from ..test_modeling_common import floats_tensor
|
||||
from transformers import is_torch_available
|
||||
from transformers.testing_utils import require_torch, slow, torch_device
|
||||
|
||||
from transformers import {{cookiecutter.camelcase_modelname}}Config
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
|
||||
|
||||
|
||||
if is_torch_available():
|
||||
|
@ -489,9 +489,9 @@ from transformers import is_torch_available
|
|||
from transformers.file_utils import cached_property
|
||||
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_generation_utils import GenerationTesterMixin
|
||||
from .test_modeling_common import ModelTesterMixin, ids_tensor
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_generation_utils import GenerationTesterMixin
|
||||
from ..test_modeling_common import ModelTesterMixin, ids_tensor
|
||||
|
||||
|
||||
if is_torch_available():
|
||||
|
|
|
@ -20,8 +20,8 @@ from transformers import AlbertConfig, is_torch_available
|
|||
from transformers.models.auto import get_values
|
||||
from transformers.testing_utils import require_torch, slow, torch_device
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -19,7 +19,7 @@ import numpy as np
|
|||
from transformers import AlbertConfig, is_flax_available
|
||||
from transformers.testing_utils import require_flax, slow
|
||||
|
||||
from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask
|
||||
from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask
|
||||
|
||||
|
||||
if is_flax_available():
|
|
@ -20,8 +20,8 @@ from transformers import AlbertConfig, is_tf_available
|
|||
from transformers.models.auto import get_values
|
||||
from transformers.testing_utils import require_tf, slow
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
|
||||
|
||||
|
||||
if is_tf_available():
|
|
@ -15,14 +15,15 @@
|
|||
|
||||
import os
|
||||
import unittest
|
||||
from os.path import dirname
|
||||
|
||||
from transformers import AlbertTokenizer, AlbertTokenizerFast
|
||||
from transformers.testing_utils import require_sentencepiece, require_tokenizers, slow
|
||||
|
||||
from .test_tokenization_common import TokenizerTesterMixin
|
||||
from ..test_tokenization_common import TokenizerTesterMixin
|
||||
|
||||
|
||||
SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/spiece.model")
|
||||
SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/spiece.model")
|
||||
|
||||
|
||||
@require_sentencepiece
|
|
@ -27,12 +27,12 @@ from transformers.models.roberta.configuration_roberta import RobertaConfig
|
|||
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER
|
||||
|
||||
|
||||
sys.path.append(str(Path(__file__).parent.parent / "utils"))
|
||||
sys.path.append(str(Path(__file__).parent.parent.parent / "utils"))
|
||||
|
||||
from test_module.custom_configuration import CustomConfig # noqa E402
|
||||
|
||||
|
||||
SAMPLE_ROBERTA_CONFIG = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/dummy-config.json")
|
||||
SAMPLE_ROBERTA_CONFIG = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fixtures/dummy-config.json")
|
||||
|
||||
|
||||
class AutoConfigTest(unittest.TestCase):
|
|
@ -31,17 +31,17 @@ from transformers import (
|
|||
from transformers.testing_utils import DUMMY_UNKNOWN_IDENTIFIER
|
||||
|
||||
|
||||
sys.path.append(str(Path(__file__).parent.parent / "utils"))
|
||||
sys.path.append(str(Path(__file__).parent.parent.parent / "utils"))
|
||||
|
||||
from test_module.custom_configuration import CustomConfig # noqa E402
|
||||
from test_module.custom_feature_extraction import CustomFeatureExtractor # noqa E402
|
||||
|
||||
|
||||
SAMPLE_FEATURE_EXTRACTION_CONFIG_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures")
|
||||
SAMPLE_FEATURE_EXTRACTION_CONFIG_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fixtures")
|
||||
SAMPLE_FEATURE_EXTRACTION_CONFIG = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "fixtures/dummy_feature_extractor_config.json"
|
||||
os.path.dirname(os.path.abspath(__file__)), "../fixtures/dummy_feature_extractor_config.json"
|
||||
)
|
||||
SAMPLE_CONFIG = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/dummy-config.json")
|
||||
SAMPLE_CONFIG = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fixtures/dummy-config.json")
|
||||
|
||||
|
||||
class AutoFeatureExtractorTest(unittest.TestCase):
|
|
@ -29,10 +29,10 @@ from transformers.testing_utils import (
|
|||
slow,
|
||||
)
|
||||
|
||||
from .test_modeling_bert import BertModelTester
|
||||
from ..bert.test_modeling_bert import BertModelTester
|
||||
|
||||
|
||||
sys.path.append(str(Path(__file__).parent.parent / "utils"))
|
||||
sys.path.append(str(Path(__file__).parent.parent.parent / "utils"))
|
||||
|
||||
from test_module.custom_configuration import CustomConfig # noqa E402
|
||||
|
|
@ -26,7 +26,7 @@ from transformers.testing_utils import (
|
|||
slow,
|
||||
)
|
||||
|
||||
from .test_modeling_bert import BertModelTester
|
||||
from ..bert.test_modeling_bert import BertModelTester
|
||||
|
||||
|
||||
if is_tf_available():
|
|
@ -41,7 +41,7 @@ from transformers.testing_utils import PASS, USER, is_staging_test
|
|||
from transformers.tokenization_utils import TOKENIZER_CONFIG_FILE
|
||||
|
||||
|
||||
sys.path.append(str(Path(__file__).parent.parent / "utils"))
|
||||
sys.path.append(str(Path(__file__).parent.parent.parent / "utils"))
|
||||
|
||||
from test_module.custom_configuration import CustomConfig # noqa E402
|
||||
from test_module.custom_feature_extraction import CustomFeatureExtractor # noqa E402
|
||||
|
@ -50,11 +50,11 @@ from test_module.custom_tokenization import CustomTokenizer # noqa E402
|
|||
|
||||
|
||||
SAMPLE_PROCESSOR_CONFIG = os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)), "fixtures/dummy_feature_extractor_config.json"
|
||||
os.path.dirname(os.path.abspath(__file__)), "../fixtures/dummy_feature_extractor_config.json"
|
||||
)
|
||||
SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/vocab.json")
|
||||
SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fixtures/vocab.json")
|
||||
|
||||
SAMPLE_PROCESSOR_CONFIG_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures")
|
||||
SAMPLE_PROCESSOR_CONFIG_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../fixtures")
|
||||
|
||||
|
||||
class AutoFeatureExtractorTest(unittest.TestCase):
|
|
@ -25,9 +25,9 @@ from transformers import BartConfig, is_torch_available
|
|||
from transformers.file_utils import cached_property
|
||||
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_generation_utils import GenerationTesterMixin
|
||||
from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
|
||||
from ..generation.test_generation_utils import GenerationTesterMixin
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -20,8 +20,8 @@ import timeout_decorator # noqa
|
|||
from transformers import BartConfig, is_flax_available
|
||||
from transformers.testing_utils import require_flax, slow
|
||||
|
||||
from .test_generation_flax_utils import FlaxGenerationTesterMixin
|
||||
from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor
|
||||
from ..generation.test_generation_flax_utils import FlaxGenerationTesterMixin
|
||||
from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor
|
||||
|
||||
|
||||
if is_flax_available():
|
|
@ -21,9 +21,9 @@ from transformers import BartConfig, BartTokenizer, is_tf_available
|
|||
from transformers.file_utils import cached_property
|
||||
from transformers.testing_utils import require_tf, slow
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor
|
||||
from .test_modeling_tf_core import TFCoreModelTesterMixin
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
|
||||
from ..utils.test_modeling_tf_core import TFCoreModelTesterMixin
|
||||
|
||||
|
||||
if is_tf_available():
|
|
@ -20,7 +20,7 @@ from transformers.file_utils import cached_property
|
|||
from transformers.models.roberta.tokenization_roberta import VOCAB_FILES_NAMES
|
||||
from transformers.testing_utils import require_tokenizers, require_torch
|
||||
|
||||
from .test_tokenization_common import TokenizerTesterMixin, filter_roberta_detectors
|
||||
from ..test_tokenization_common import TokenizerTesterMixin, filter_roberta_detectors
|
||||
|
||||
|
||||
@require_tokenizers
|
|
@ -18,7 +18,7 @@ import unittest
|
|||
from transformers import BarthezTokenizer, BarthezTokenizerFast, BatchEncoding
|
||||
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow
|
||||
|
||||
from .test_tokenization_common import TokenizerTesterMixin
|
||||
from ..test_tokenization_common import TokenizerTesterMixin
|
||||
|
||||
|
||||
@require_tokenizers
|
|
@ -15,13 +15,14 @@
|
|||
|
||||
import os
|
||||
import unittest
|
||||
from os.path import dirname
|
||||
|
||||
from transformers.models.bartpho.tokenization_bartpho import VOCAB_FILES_NAMES, BartphoTokenizer
|
||||
|
||||
from .test_tokenization_common import TokenizerTesterMixin
|
||||
from ..test_tokenization_common import TokenizerTesterMixin
|
||||
|
||||
|
||||
SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece_bpe.model")
|
||||
SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece_bpe.model")
|
||||
|
||||
|
||||
class BartphoTokenizerTest(TokenizerTesterMixin, unittest.TestCase):
|
|
@ -22,7 +22,7 @@ from datasets import load_dataset
|
|||
from transformers.file_utils import is_torch_available, is_vision_available
|
||||
from transformers.testing_utils import require_torch, require_vision
|
||||
|
||||
from .test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs
|
||||
from ..test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -25,8 +25,8 @@ from transformers.file_utils import cached_property, is_torch_available, is_visi
|
|||
from transformers.models.auto import get_values
|
||||
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -21,8 +21,8 @@ from transformers import BeitConfig
|
|||
from transformers.file_utils import cached_property, is_flax_available, is_vision_available
|
||||
from transformers.testing_utils import require_flax, require_vision, slow
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor
|
||||
|
||||
|
||||
if is_flax_available():
|
|
@ -20,9 +20,9 @@ from transformers import BertConfig, is_torch_available
|
|||
from transformers.models.auto import get_values
|
||||
from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_generation_utils import GenerationTesterMixin
|
||||
from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
|
||||
from ..generation.test_generation_utils import GenerationTesterMixin
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -19,7 +19,7 @@ import numpy as np
|
|||
from transformers import BertConfig, is_flax_available
|
||||
from transformers.testing_utils import require_flax, slow
|
||||
|
||||
from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask
|
||||
from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask
|
||||
|
||||
|
||||
if is_flax_available():
|
|
@ -20,9 +20,9 @@ from transformers import BertConfig, is_tf_available
|
|||
from transformers.models.auto import get_values
|
||||
from transformers.testing_utils import require_tf, slow
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
|
||||
from .test_modeling_tf_core import TFCoreModelTesterMixin
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor
|
||||
from ..utils.test_modeling_tf_core import TFCoreModelTesterMixin
|
||||
|
||||
|
||||
if is_tf_available():
|
|
@ -29,7 +29,7 @@ from transformers.models.bert.tokenization_bert import (
|
|||
)
|
||||
from transformers.testing_utils import require_tokenizers, slow
|
||||
|
||||
from .test_tokenization_common import TokenizerTesterMixin, filter_non_english
|
||||
from ..test_tokenization_common import TokenizerTesterMixin, filter_non_english
|
||||
|
||||
|
||||
@require_tokenizers
|
|
@ -19,9 +19,9 @@ import unittest
|
|||
from transformers import BertGenerationConfig, is_torch_available
|
||||
from transformers.testing_utils import require_torch, slow, torch_device
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_generation_utils import GenerationTesterMixin
|
||||
from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
|
||||
from ..generation.test_generation_utils import GenerationTesterMixin
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -15,17 +15,18 @@
|
|||
|
||||
import os
|
||||
import unittest
|
||||
from os.path import dirname
|
||||
|
||||
from transformers import BertGenerationTokenizer
|
||||
from transformers.file_utils import cached_property
|
||||
from transformers.testing_utils import require_sentencepiece, require_torch, slow
|
||||
|
||||
from .test_tokenization_common import TokenizerTesterMixin
|
||||
from ..test_tokenization_common import TokenizerTesterMixin
|
||||
|
||||
|
||||
SPIECE_UNDERLINE = "▁"
|
||||
|
||||
SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model")
|
||||
SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model")
|
||||
|
||||
|
||||
@require_sentencepiece
|
|
@ -29,7 +29,7 @@ from transformers.models.bert_japanese.tokenization_bert_japanese import (
|
|||
)
|
||||
from transformers.testing_utils import custom_tokenizers
|
||||
|
||||
from .test_tokenization_common import TokenizerTesterMixin
|
||||
from ..test_tokenization_common import TokenizerTesterMixin
|
||||
|
||||
|
||||
@custom_tokenizers
|
|
@ -18,7 +18,7 @@ import unittest
|
|||
|
||||
from transformers.models.bertweet.tokenization_bertweet import VOCAB_FILES_NAMES, BertweetTokenizer
|
||||
|
||||
from .test_tokenization_common import TokenizerTesterMixin
|
||||
from ..test_tokenization_common import TokenizerTesterMixin
|
||||
|
||||
|
||||
class BertweetTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
|
|
@ -17,14 +17,13 @@
|
|||
|
||||
import unittest
|
||||
|
||||
from tests.test_modeling_common import floats_tensor
|
||||
from transformers import BigBirdConfig, is_torch_available
|
||||
from transformers.models.auto import get_values
|
||||
from transformers.models.big_bird.tokenization_big_bird import BigBirdTokenizer
|
||||
from transformers.testing_utils import require_torch, slow, torch_device
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -19,7 +19,7 @@ import numpy as np
|
|||
from transformers import BigBirdConfig, is_flax_available
|
||||
from transformers.testing_utils import require_flax, slow
|
||||
|
||||
from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask
|
||||
from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor, random_attention_mask
|
||||
|
||||
|
||||
if is_flax_available():
|
|
@ -15,17 +15,18 @@
|
|||
|
||||
import os
|
||||
import unittest
|
||||
from os.path import dirname
|
||||
|
||||
from transformers import BigBirdTokenizer, BigBirdTokenizerFast
|
||||
from transformers.file_utils import cached_property
|
||||
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow
|
||||
|
||||
from .test_tokenization_common import TokenizerTesterMixin
|
||||
from ..test_tokenization_common import TokenizerTesterMixin
|
||||
|
||||
|
||||
SPIECE_UNDERLINE = "▁"
|
||||
|
||||
SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model")
|
||||
SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model")
|
||||
|
||||
|
||||
@require_sentencepiece
|
|
@ -22,9 +22,9 @@ import unittest
|
|||
from transformers import BigBirdPegasusConfig, is_torch_available
|
||||
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_generation_utils import GenerationTesterMixin
|
||||
from .test_modeling_common import ModelTesterMixin, ids_tensor
|
||||
from ..generation.test_generation_utils import GenerationTesterMixin
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_common import ModelTesterMixin, ids_tensor
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -21,9 +21,9 @@ from transformers import BlenderbotConfig, is_torch_available
|
|||
from transformers.file_utils import cached_property
|
||||
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_generation_utils import GenerationTesterMixin
|
||||
from .test_modeling_common import ModelTesterMixin, ids_tensor
|
||||
from ..generation.test_generation_utils import GenerationTesterMixin
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_common import ModelTesterMixin, ids_tensor
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -20,8 +20,8 @@ import timeout_decorator # noqa
|
|||
from transformers import BlenderbotConfig, is_flax_available
|
||||
from transformers.testing_utils import jax_device, require_flax, slow
|
||||
|
||||
from .test_generation_flax_utils import FlaxGenerationTesterMixin
|
||||
from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor
|
||||
from ..generation.test_generation_flax_utils import FlaxGenerationTesterMixin
|
||||
from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor
|
||||
|
||||
|
||||
if is_flax_available():
|
|
@ -20,8 +20,8 @@ from transformers import BlenderbotConfig, BlenderbotTokenizer, is_tf_available
|
|||
from transformers.file_utils import cached_property
|
||||
from transformers.testing_utils import require_tf, require_tokenizers, slow
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
|
||||
|
||||
|
||||
if is_tf_available():
|
|
@ -21,9 +21,9 @@ from transformers import BlenderbotSmallConfig, is_torch_available
|
|||
from transformers.file_utils import cached_property
|
||||
from transformers.testing_utils import require_torch, slow, torch_device
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_generation_utils import GenerationTesterMixin
|
||||
from .test_modeling_common import ModelTesterMixin, ids_tensor
|
||||
from ..generation.test_generation_utils import GenerationTesterMixin
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_common import ModelTesterMixin, ids_tensor
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -20,8 +20,8 @@ import timeout_decorator # noqa
|
|||
from transformers import BlenderbotSmallConfig, is_flax_available
|
||||
from transformers.testing_utils import require_flax, slow
|
||||
|
||||
from .test_generation_flax_utils import FlaxGenerationTesterMixin
|
||||
from .test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor
|
||||
from ..generation.test_generation_flax_utils import FlaxGenerationTesterMixin
|
||||
from ..test_modeling_flax_common import FlaxModelTesterMixin, ids_tensor
|
||||
|
||||
|
||||
if is_flax_available():
|
|
@ -20,8 +20,8 @@ from transformers import BlenderbotSmallConfig, BlenderbotSmallTokenizer, is_tf_
|
|||
from transformers.file_utils import cached_property
|
||||
from transformers.testing_utils import require_tf, require_tokenizers, slow
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
|
||||
|
||||
|
||||
if is_tf_available():
|
|
@ -23,7 +23,7 @@ from transformers.models.blenderbot_small.tokenization_blenderbot_small import (
|
|||
BlenderbotSmallTokenizer,
|
||||
)
|
||||
|
||||
from .test_tokenization_common import TokenizerTesterMixin
|
||||
from ..test_tokenization_common import TokenizerTesterMixin
|
||||
|
||||
|
||||
class BlenderbotSmallTokenizerTest(TokenizerTesterMixin, unittest.TestCase):
|
|
@ -24,7 +24,7 @@ from typing import Tuple
|
|||
from transformers import AddedToken, BatchEncoding, ByT5Tokenizer
|
||||
from transformers.file_utils import cached_property, is_tf_available, is_torch_available
|
||||
|
||||
from .test_tokenization_common import TokenizerTesterMixin
|
||||
from ..test_tokenization_common import TokenizerTesterMixin
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -15,16 +15,17 @@
|
|||
|
||||
import os
|
||||
import unittest
|
||||
from os.path import dirname
|
||||
|
||||
from transformers import CamembertTokenizer, CamembertTokenizerFast
|
||||
from transformers.file_utils import is_torch_available
|
||||
from transformers.testing_utils import require_sentencepiece, require_tokenizers, slow
|
||||
|
||||
from .test_tokenization_common import TokenizerTesterMixin
|
||||
from ..test_tokenization_common import TokenizerTesterMixin
|
||||
|
||||
|
||||
SAMPLE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece.model")
|
||||
SAMPLE_BPE_VOCAB = os.path.join(os.path.dirname(os.path.abspath(__file__)), "fixtures/test_sentencepiece_bpe.model")
|
||||
SAMPLE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece.model")
|
||||
SAMPLE_BPE_VOCAB = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures/test_sentencepiece_bpe.model")
|
||||
|
||||
FRAMEWORK = "pt" if is_torch_available() else "tf"
|
||||
|
|
@ -21,8 +21,8 @@ from typing import List, Tuple
|
|||
from transformers import CanineConfig, is_torch_available
|
||||
from transformers.testing_utils import require_torch, slow, torch_device
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_common import ModelTesterMixin, _config_zero_init, global_rng, ids_tensor, random_attention_mask
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_common import ModelTesterMixin, _config_zero_init, global_rng, ids_tensor, random_attention_mask
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -24,7 +24,7 @@ from transformers.file_utils import cached_property
|
|||
from transformers.testing_utils import require_tokenizers, require_torch
|
||||
from transformers.tokenization_utils import AddedToken
|
||||
|
||||
from .test_tokenization_common import TokenizerTesterMixin
|
||||
from ..test_tokenization_common import TokenizerTesterMixin
|
||||
|
||||
|
||||
class CanineTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
|
|
@ -21,7 +21,7 @@ import numpy as np
|
|||
from transformers.file_utils import is_torch_available, is_vision_available
|
||||
from transformers.testing_utils import require_torch, require_vision
|
||||
|
||||
from .test_feature_extraction_common import FeatureExtractionSavingTestMixin
|
||||
from ..test_feature_extraction_common import FeatureExtractionSavingTestMixin
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -36,8 +36,14 @@ from transformers.testing_utils import (
|
|||
torch_device,
|
||||
)
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_common import ModelTesterMixin, _config_zero_init, floats_tensor, ids_tensor, random_attention_mask
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_common import (
|
||||
ModelTesterMixin,
|
||||
_config_zero_init,
|
||||
floats_tensor,
|
||||
ids_tensor,
|
||||
random_attention_mask,
|
||||
)
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -8,7 +8,7 @@ import transformers
|
|||
from transformers import CLIPConfig, CLIPTextConfig, CLIPVisionConfig, is_flax_available, is_torch_available
|
||||
from transformers.testing_utils import is_pt_flax_cross_test, require_flax, slow
|
||||
|
||||
from .test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
|
||||
from ..test_modeling_flax_common import FlaxModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
|
||||
|
||||
|
||||
if is_flax_available():
|
|
@ -26,8 +26,8 @@ from transformers import CLIPConfig, CLIPTextConfig, CLIPVisionConfig
|
|||
from transformers.file_utils import is_tf_available, is_vision_available
|
||||
from transformers.testing_utils import is_pt_tf_cross_test, require_tf, require_vision, slow
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_tf_common import TFModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
|
||||
|
||||
|
||||
if is_tf_available():
|
|
@ -22,7 +22,7 @@ from transformers import CLIPTokenizer, CLIPTokenizerFast
|
|||
from transformers.models.clip.tokenization_clip import VOCAB_FILES_NAMES
|
||||
from transformers.testing_utils import require_ftfy, require_tokenizers
|
||||
|
||||
from .test_tokenization_common import TokenizerTesterMixin
|
||||
from ..test_tokenization_common import TokenizerTesterMixin
|
||||
|
||||
|
||||
@require_tokenizers
|
|
@ -17,13 +17,12 @@ import os
|
|||
import tempfile
|
||||
import unittest
|
||||
|
||||
from tests.test_modeling_common import floats_tensor
|
||||
from transformers import ConvBertConfig, is_torch_available
|
||||
from transformers.models.auto import get_values
|
||||
from transformers.testing_utils import require_torch, require_torch_gpu, slow, torch_device
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor, random_attention_mask
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -19,8 +19,8 @@ import unittest
|
|||
from transformers import ConvBertConfig, is_tf_available
|
||||
from transformers.testing_utils import require_tf, slow
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
|
||||
|
||||
|
||||
if is_tf_available():
|
|
@ -21,7 +21,7 @@ import numpy as np
|
|||
from transformers.file_utils import is_torch_available, is_vision_available
|
||||
from transformers.testing_utils import require_torch, require_vision
|
||||
|
||||
from .test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs
|
||||
from ..test_feature_extraction_common import FeatureExtractionSavingTestMixin, prepare_image_inputs
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -23,8 +23,8 @@ from transformers import ConvNextConfig
|
|||
from transformers.file_utils import cached_property, is_torch_available, is_vision_available
|
||||
from transformers.testing_utils import require_torch, require_vision, slow, torch_device
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_common import ModelTesterMixin, floats_tensor, ids_tensor
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -16,7 +16,7 @@
|
|||
from transformers.models.cpm.tokenization_cpm import CpmTokenizer
|
||||
from transformers.testing_utils import custom_tokenizers
|
||||
|
||||
from .test_modeling_xlnet import XLNetModelTest
|
||||
from ..xlnet.test_modeling_xlnet import XLNetModelTest
|
||||
|
||||
|
||||
@custom_tokenizers
|
|
@ -18,9 +18,9 @@ import unittest
|
|||
from transformers import CTRLConfig, is_torch_available
|
||||
from transformers.testing_utils import require_torch, slow, torch_device
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_generation_utils import GenerationTesterMixin
|
||||
from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
|
||||
from ..generation.test_generation_utils import GenerationTesterMixin
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
|
||||
|
||||
|
||||
if is_torch_available():
|
|
@ -19,8 +19,8 @@ import unittest
|
|||
from transformers import CTRLConfig, is_tf_available
|
||||
from transformers.testing_utils import require_tf, slow
|
||||
|
||||
from .test_configuration_common import ConfigTester
|
||||
from .test_modeling_tf_common import TFModelTesterMixin, ids_tensor
|
||||
from ..test_configuration_common import ConfigTester
|
||||
from ..test_modeling_tf_common import TFModelTesterMixin, ids_tensor
|
||||
|
||||
|
||||
if is_tf_available():
|
|
@ -19,7 +19,7 @@ import unittest
|
|||
|
||||
from transformers.models.ctrl.tokenization_ctrl import VOCAB_FILES_NAMES, CTRLTokenizer
|
||||
|
||||
from .test_tokenization_common import TokenizerTesterMixin
|
||||
from ..test_tokenization_common import TokenizerTesterMixin
|
||||
|
||||
|
||||
class CTRLTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue