🔥Rework pipeline testing by removing PipelineTestCaseMeta 🚀 (#21516)
* Add PipelineTesterMixin * remove class PipelineTestCaseMeta * move validate_test_components * Add for ViT * Add to SPECIAL_MODULE_TO_TEST_MAP * style and quality * Add feature-extraction * update * raise instead of skip * add tiny_model_summary.json * more explicit * skip tasks not in mapping * add availability check * Add Copyright * A way to diable irrelevant tests * update with main * remove disable_irrelevant_tests * skip tests * better skip message * better skip message * Add all pipeline task tests * revert * Import PipelineTesterMixin * subclass test classes with PipelineTesterMixin * Add pipieline_model_mapping * Fix import after adding pipieline_model_mapping * Fix style and quality after adding pipieline_model_mapping * Fix one more import after adding pipieline_model_mapping * Fix style and quality after adding pipieline_model_mapping * Fix test issues * Fix import requirements * Fix mapping for MobileViTModelTest * Update * Better skip message * pipieline_model_mapping could not be None * Remove some PipelineTesterMixin * Fix typo * revert tests_fetcher.py * update * rename * revert * Remove PipelineTestCaseMeta from ZeroShotAudioClassificationPipelineTests * style and quality * test fetcher for all pipeline/model tests --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
This commit is contained in:
@@ -21,6 +21,7 @@ from transformers.testing_utils import require_torch, require_torch_gpu, slow, t
|
||||
|
||||
from ...test_configuration_common import ConfigTester
|
||||
from ...test_modeling_common import ModelTesterMixin, ids_tensor, random_attention_mask
|
||||
from ...test_pipeline_mixin import PipelineTesterMixin
|
||||
|
||||
|
||||
if is_torch_available():
|
||||
@@ -362,7 +363,7 @@ class FlaubertModelTester(object):
|
||||
|
||||
|
||||
@require_torch
|
||||
class FlaubertModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
class FlaubertModelTest(ModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (
|
||||
(
|
||||
FlaubertModel,
|
||||
@@ -376,6 +377,18 @@ class FlaubertModelTest(ModelTesterMixin, unittest.TestCase):
|
||||
if is_torch_available()
|
||||
else ()
|
||||
)
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"feature-extraction": FlaubertModel,
|
||||
"fill-mask": FlaubertWithLMHeadModel,
|
||||
"question-answering": FlaubertForQuestionAnsweringSimple,
|
||||
"text-classification": FlaubertForSequenceClassification,
|
||||
"token-classification": FlaubertForTokenClassification,
|
||||
"zero-shot": FlaubertForSequenceClassification,
|
||||
}
|
||||
if is_torch_available()
|
||||
else {}
|
||||
)
|
||||
|
||||
# Flaubert has 2 QA models -> need to manually set the correct labels for one of them here
|
||||
def _prepare_for_class(self, inputs_dict, model_class, return_labels=False):
|
||||
|
||||
@@ -20,6 +20,7 @@ from transformers.testing_utils import require_sentencepiece, require_tf, requir
|
||||
|
||||
from ...test_configuration_common import ConfigTester
|
||||
from ...test_modeling_tf_common import TFModelTesterMixin, ids_tensor, random_attention_mask
|
||||
from ...test_pipeline_mixin import PipelineTesterMixin
|
||||
|
||||
|
||||
if is_tf_available():
|
||||
@@ -274,7 +275,7 @@ class TFFlaubertModelTester:
|
||||
|
||||
|
||||
@require_tf
|
||||
class TFFlaubertModelTest(TFModelTesterMixin, unittest.TestCase):
|
||||
class TFFlaubertModelTest(TFModelTesterMixin, PipelineTesterMixin, unittest.TestCase):
|
||||
all_model_classes = (
|
||||
(
|
||||
TFFlaubertModel,
|
||||
@@ -290,6 +291,18 @@ class TFFlaubertModelTest(TFModelTesterMixin, unittest.TestCase):
|
||||
all_generative_model_classes = (
|
||||
(TFFlaubertWithLMHeadModel,) if is_tf_available() else ()
|
||||
) # TODO (PVP): Check other models whether language generation is also applicable
|
||||
pipeline_model_mapping = (
|
||||
{
|
||||
"feature-extraction": TFFlaubertModel,
|
||||
"fill-mask": TFFlaubertWithLMHeadModel,
|
||||
"question-answering": TFFlaubertForQuestionAnsweringSimple,
|
||||
"text-classification": TFFlaubertForSequenceClassification,
|
||||
"token-classification": TFFlaubertForTokenClassification,
|
||||
"zero-shot": TFFlaubertForSequenceClassification,
|
||||
}
|
||||
if is_tf_available()
|
||||
else {}
|
||||
)
|
||||
test_head_masking = False
|
||||
test_onnx = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user