Simplify soft dependencies and update the dummy-creation process (#36827)
* Reverse dependency map shouldn't be created when test_all is set * [test_all] Remove dummies * Modular fixes * Update utils/check_repo.py Co-authored-by: Pablo Montalvo <39954772+molbap@users.noreply.github.com> * [test_all] Better docs * [test_all] Update src/transformers/commands/chat.py Co-authored-by: Joao Gante <joaofranciscocardosogante@gmail.com> * [test_all] Remove deprecated AdaptiveEmbeddings from the tests * [test_all] Doc builder * [test_all] is_dummy * [test_all] Import utils * [test_all] Doc building should not require all deps --------- Co-authored-by: Pablo Montalvo <39954772+molbap@users.noreply.github.com> Co-authored-by: Joao Gante <joaofranciscocardosogante@gmail.com>
This commit is contained in:
@@ -19,7 +19,8 @@ from huggingface_hub.utils import insecure_hashlib
|
||||
|
||||
from transformers import (
|
||||
MODEL_FOR_MASK_GENERATION_MAPPING,
|
||||
TF_MODEL_FOR_MASK_GENERATION_MAPPING,
|
||||
is_tf_available,
|
||||
is_torch_available,
|
||||
is_vision_available,
|
||||
pipeline,
|
||||
)
|
||||
@@ -34,6 +35,17 @@ from transformers.testing_utils import (
|
||||
)
|
||||
|
||||
|
||||
if is_tf_available():
|
||||
from transformers import TF_MODEL_FOR_MASK_GENERATION_MAPPING
|
||||
else:
|
||||
TF_MODEL_FOR_MASK_GENERATION_MAPPING = None
|
||||
|
||||
if is_torch_available():
|
||||
from transformers import MODEL_FOR_MASK_GENERATION_MAPPING
|
||||
else:
|
||||
MODEL_FOR_MASK_GENERATION_MAPPING = None
|
||||
|
||||
|
||||
if is_vision_available():
|
||||
from PIL import Image
|
||||
else:
|
||||
|
||||
@@ -51,9 +51,9 @@ class QAPipelineTests(unittest.TestCase):
|
||||
model_mapping = MODEL_FOR_QUESTION_ANSWERING_MAPPING
|
||||
tf_model_mapping = TF_MODEL_FOR_QUESTION_ANSWERING_MAPPING
|
||||
|
||||
if model_mapping is not None:
|
||||
if not hasattr(model_mapping, "is_dummy"):
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ not in _TO_SKIP}
|
||||
if tf_model_mapping is not None:
|
||||
if not hasattr(tf_model_mapping, "is_dummy"):
|
||||
tf_model_mapping = {
|
||||
config: model for config, model in tf_model_mapping.items() if config.__name__ not in _TO_SKIP
|
||||
}
|
||||
|
||||
@@ -48,9 +48,9 @@ class TextClassificationPipelineTests(unittest.TestCase):
|
||||
model_mapping = MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
|
||||
tf_model_mapping = TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
|
||||
|
||||
if model_mapping is not None:
|
||||
if not hasattr(model_mapping, "is_dummy"):
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ not in _TO_SKIP}
|
||||
if tf_model_mapping is not None:
|
||||
if not hasattr(tf_model_mapping, "is_dummy"):
|
||||
tf_model_mapping = {
|
||||
config: model for config, model in tf_model_mapping.items() if config.__name__ not in _TO_SKIP
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ class TokenClassificationPipelineTests(unittest.TestCase):
|
||||
model_mapping = MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING
|
||||
tf_model_mapping = TF_MODEL_FOR_TOKEN_CLASSIFICATION_MAPPING
|
||||
|
||||
if model_mapping is not None:
|
||||
if not hasattr(model_mapping, "is_dummy"):
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ not in _TO_SKIP}
|
||||
if tf_model_mapping is not None:
|
||||
if not hasattr(tf_model_mapping, "is_dummy"):
|
||||
tf_model_mapping = {
|
||||
config: model for config, model in tf_model_mapping.items() if config.__name__ not in _TO_SKIP
|
||||
}
|
||||
|
||||
@@ -46,9 +46,9 @@ class ZeroShotClassificationPipelineTests(unittest.TestCase):
|
||||
model_mapping = MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
|
||||
tf_model_mapping = TF_MODEL_FOR_SEQUENCE_CLASSIFICATION_MAPPING
|
||||
|
||||
if model_mapping is not None:
|
||||
if not hasattr(model_mapping, "is_dummy"):
|
||||
model_mapping = {config: model for config, model in model_mapping.items() if config.__name__ not in _TO_SKIP}
|
||||
if tf_model_mapping is not None:
|
||||
if not hasattr(tf_model_mapping, "is_dummy"):
|
||||
tf_model_mapping = {
|
||||
config: model for config, model in tf_model_mapping.items() if config.__name__ not in _TO_SKIP
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user