[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:
0
tests/deepspeed/__init__.py
Normal file
0
tests/deepspeed/__init__.py
Normal file
@@ -27,7 +27,6 @@ from transformers.testing_utils import (
|
||||
CaptureLogger,
|
||||
CaptureStd,
|
||||
CaptureStderr,
|
||||
ExtendSysPath,
|
||||
LoggingLevel,
|
||||
TestCasePlus,
|
||||
execute_subprocess_async,
|
||||
@@ -40,14 +39,11 @@ from transformers.testing_utils import (
|
||||
)
|
||||
from transformers.trainer_utils import get_last_checkpoint, set_seed
|
||||
|
||||
from ..trainer.test_trainer import TrainerIntegrationCommon # noqa
|
||||
|
||||
tests_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
root_dir = os.path.dirname(tests_dir)
|
||||
with ExtendSysPath(tests_dir):
|
||||
from test_trainer import TrainerIntegrationCommon # noqa
|
||||
|
||||
if is_torch_available():
|
||||
from test_trainer import RegressionModelConfig, RegressionPreTrainedModel, get_regression_trainer # noqa
|
||||
if is_torch_available():
|
||||
from ..trainer.test_trainer import RegressionModelConfig, RegressionPreTrainedModel, get_regression_trainer # noqa
|
||||
|
||||
|
||||
set_seed(42)
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
import itertools
|
||||
import os
|
||||
import subprocess
|
||||
from os.path import dirname
|
||||
|
||||
from parameterized import parameterized
|
||||
from transformers import is_torch_available
|
||||
from transformers.testing_utils import (
|
||||
ExtendSysPath,
|
||||
TestCasePlus,
|
||||
execute_subprocess_async,
|
||||
get_gpu_count,
|
||||
@@ -29,14 +29,11 @@ from transformers.testing_utils import (
|
||||
)
|
||||
from transformers.trainer_utils import set_seed
|
||||
|
||||
from ..trainer.test_trainer import TrainerIntegrationCommon # noqa
|
||||
|
||||
tests_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
root_dir = os.path.dirname(tests_dir)
|
||||
with ExtendSysPath(tests_dir):
|
||||
from test_trainer import TrainerIntegrationCommon # noqa
|
||||
|
||||
if is_torch_available():
|
||||
from test_trainer import RegressionModelConfig, RegressionPreTrainedModel, get_regression_trainer # noqa
|
||||
if is_torch_available():
|
||||
from ..trainer.test_trainer import RegressionModelConfig, RegressionPreTrainedModel, get_regression_trainer # noqa
|
||||
|
||||
|
||||
set_seed(42)
|
||||
@@ -70,6 +67,8 @@ ELECTRA_TINY = "hf-internal-testing/tiny-electra"
|
||||
XLNET_TINY = "sshleifer/tiny-xlnet-base-cased"
|
||||
BERT_TINY = "hf-internal-testing/tiny-bert"
|
||||
|
||||
FIXTURE_DIRECTORY = os.path.join(dirname(dirname(os.path.abspath(__file__))), "fixtures")
|
||||
ROOT_DIRECTORY = os.path.join(dirname(dirname(dirname(os.path.abspath(__file__)))))
|
||||
|
||||
# TODO: to add:
|
||||
# albert
|
||||
@@ -97,10 +96,9 @@ def get_launcher(distributed=False):
|
||||
|
||||
|
||||
def make_task_cmds():
|
||||
data_dir_fixtures = f"{tests_dir}/fixtures"
|
||||
data_dir_samples = f"{data_dir_fixtures}/tests_samples"
|
||||
data_dir_wmt = f"{data_dir_samples}/wmt_en_ro"
|
||||
data_dir_xsum = f"{data_dir_samples}/xsum"
|
||||
data_dir_samples = f"{FIXTURE_DIRECTORY}/tests_samples"
|
||||
data_dir_wmt = f"{FIXTURE_DIRECTORY}/wmt_en_ro"
|
||||
data_dir_xsum = f"{FIXTURE_DIRECTORY}/xsum"
|
||||
args_main = """
|
||||
--do_train
|
||||
--max_train_samples 4
|
||||
@@ -143,7 +141,7 @@ def make_task_cmds():
|
||||
],
|
||||
)
|
||||
|
||||
scripts_dir = f"{root_dir}/examples/pytorch"
|
||||
scripts_dir = f"{ROOT_DIRECTORY}/examples/pytorch"
|
||||
|
||||
tasks = dict(
|
||||
trans=f"""
|
||||
@@ -161,12 +159,12 @@ def make_task_cmds():
|
||||
""",
|
||||
clm=f"""
|
||||
{scripts_dir}/language-modeling/run_clm.py
|
||||
--train_file {data_dir_fixtures}/sample_text.txt
|
||||
--train_file {FIXTURE_DIRECTORY}/sample_text.txt
|
||||
--block_size 8
|
||||
""",
|
||||
mlm=f"""
|
||||
{scripts_dir}/language-modeling/run_mlm.py
|
||||
--train_file {data_dir_fixtures}/sample_text.txt
|
||||
--train_file {FIXTURE_DIRECTORY}/sample_text.txt
|
||||
""",
|
||||
qa=f"""
|
||||
{scripts_dir}/question-answering/run_qa.py
|
||||
|
||||
Reference in New Issue
Block a user