mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 18:22:34 +06:00
parent
309e87e25e
commit
bb7949b35a
9
.github/workflows/add-model-like.yml
vendored
9
.github/workflows/add-model-like.yml
vendored
@ -12,7 +12,8 @@ on:
|
|||||||
types: [opened, synchronize, reopened]
|
types: [opened, synchronize, reopened]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
run_tests_templates:
|
run_tests_templates_like:
|
||||||
|
name: "Add new model like template tests"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
@ -42,7 +43,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Run all PyTorch modeling test
|
- name: Run all PyTorch modeling test
|
||||||
run: |
|
run: |
|
||||||
python -m pytest -n 2 --dist=loadfile -s --make-reports=tests_new_models tests/test_modeling_bert_new.py
|
python -m pytest -n 2 --dist=loadfile -s --make-reports=tests_new_models tests/bert_new/test_modeling_bert_new.py
|
||||||
|
|
||||||
- name: Run style changes
|
- name: Run style changes
|
||||||
run: |
|
run: |
|
||||||
@ -50,11 +51,11 @@ jobs:
|
|||||||
|
|
||||||
- name: Failure short reports
|
- name: Failure short reports
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
run: cat reports/tests_new_models_failures_short.txt
|
run: cat reports/tests_new_models/failures_short.txt
|
||||||
|
|
||||||
- name: Test suite reports artifacts
|
- name: Test suite reports artifacts
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: run_all_tests_new_models_test_reports
|
name: run_all_tests_new_models_test_reports
|
||||||
path: reports
|
path: reports/tests_new_models
|
||||||
|
4
.github/workflows/model-templates.yml
vendored
4
.github/workflows/model-templates.yml
vendored
@ -65,11 +65,11 @@ jobs:
|
|||||||
|
|
||||||
- name: Failure short reports
|
- name: Failure short reports
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
run: cat reports/tests_templates_failures_short.txt
|
run: cat reports/tests_templates/failures_short.txt
|
||||||
|
|
||||||
- name: Test suite reports artifacts
|
- name: Test suite reports artifacts
|
||||||
if: ${{ always() }}
|
if: ${{ always() }}
|
||||||
uses: actions/upload-artifact@v2
|
uses: actions/upload-artifact@v2
|
||||||
with:
|
with:
|
||||||
name: run_all_tests_templates_test_reports
|
name: run_all_tests_templates_test_reports
|
||||||
path: reports
|
path: reports/tests_templates
|
||||||
|
@ -102,6 +102,11 @@ class AddNewModelCommand(BaseTransformersCLICommand):
|
|||||||
|
|
||||||
model_dir = f"{path_to_transformer_root}/src/transformers/models/{lowercase_model_name}"
|
model_dir = f"{path_to_transformer_root}/src/transformers/models/{lowercase_model_name}"
|
||||||
os.makedirs(model_dir, exist_ok=True)
|
os.makedirs(model_dir, exist_ok=True)
|
||||||
|
os.makedirs(f"{path_to_transformer_root}/tests/{lowercase_model_name}", exist_ok=True)
|
||||||
|
|
||||||
|
# Tests require submodules as they have parent imports
|
||||||
|
with open(f"{path_to_transformer_root}/tests/{lowercase_model_name}/__init__.py", "w"):
|
||||||
|
pass
|
||||||
|
|
||||||
shutil.move(
|
shutil.move(
|
||||||
f"{directory}/__init__.py",
|
f"{directory}/__init__.py",
|
||||||
|
@ -1199,11 +1199,16 @@ def create_new_model_like(
|
|||||||
|
|
||||||
disabled_fx_test = False
|
disabled_fx_test = False
|
||||||
|
|
||||||
|
tests_folder = REPO_PATH / "tests" / new_model_patterns.model_lower_cased
|
||||||
|
os.makedirs(tests_folder, exist_ok=True)
|
||||||
|
with open(tests_folder / "__init__.py", "w"):
|
||||||
|
pass
|
||||||
|
|
||||||
for test_file in files_to_adapt:
|
for test_file in files_to_adapt:
|
||||||
new_test_file_name = test_file.name.replace(
|
new_test_file_name = test_file.name.replace(
|
||||||
old_model_patterns.model_lower_cased, new_model_patterns.model_lower_cased
|
old_model_patterns.model_lower_cased, new_model_patterns.model_lower_cased
|
||||||
)
|
)
|
||||||
dest_file = test_file.parent / new_test_file_name
|
dest_file = test_file.parent.parent / new_model_patterns.model_lower_cased / new_test_file_name
|
||||||
duplicate_module(
|
duplicate_module(
|
||||||
test_file,
|
test_file,
|
||||||
old_model_patterns,
|
old_model_patterns,
|
||||||
|
@ -490,7 +490,7 @@ from transformers.file_utils import cached_property
|
|||||||
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
|
from transformers.testing_utils import require_sentencepiece, require_tokenizers, require_torch, slow, torch_device
|
||||||
|
|
||||||
from ..test_configuration_common import ConfigTester
|
from ..test_configuration_common import ConfigTester
|
||||||
from ..test_generation_utils import GenerationTesterMixin
|
from ..generation.test_generation_utils import GenerationTesterMixin
|
||||||
from ..test_modeling_common import ModelTesterMixin, ids_tensor
|
from ..test_modeling_common import ModelTesterMixin, ids_tensor
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user