Skip to content

Commit fb8628c

Browse files
Rocketknight1ydshieh
authored andcommitted
Skip is_flaky tests in the CI (huggingface#37723)
* No more red flaky tests in the CI! * Remove the CircleCI logic as well * Revert most changes including is_flaky behaviour * make fixup * Move to a more sensible place * Mark a flaky test that failed on this PR! * correct import * update * update * update * update --------- Co-authored-by: ydshieh <ydshieh@users.noreply.github.com>
1 parent 13c73e8 commit fb8628c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.circleci/create_circleci_config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
"TRANSFORMERS_IS_CI": True,
2929
"PYTEST_TIMEOUT": 120,
3030
"RUN_PIPELINE_TESTS": False,
31+
# will be adjust in `CircleCIJob.to_dict`.
32+
"RUN_FLAKY": True,
3133
}
3234
# Disable the use of {"s": None} as the output is way too long, causing the navigation on CircleCI impractical
3335
COMMON_PYTEST_OPTIONS = {"max-worker-restart": 0, "vvv": None, "rsfE":None}
@@ -126,6 +128,8 @@ def __post_init__(self):
126128

127129
def to_dict(self):
128130
env = COMMON_ENV_VARIABLES.copy()
131+
# Do not run tests decorated by @is_flaky on pull requests
132+
env['RUN_FLAKY'] = os.environ.get("CIRCLE_PULL_REQUEST", "") == ""
129133
env.update(self.additional_env)
130134

131135
job = {

src/transformers/testing_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ def parse_int_from_env(key, default=None):
240240

241241

242242
_run_slow_tests = parse_flag_from_env("RUN_SLOW", default=False)
243+
_run_flaky_tests = parse_flag_from_env("RUN_FLAKY", default=True)
243244
_run_custom_tokenizers = parse_flag_from_env("RUN_CUSTOM_TOKENIZERS", default=False)
244245
_run_staging = parse_flag_from_env("HUGGINGFACE_CO_STAGING", default=False)
245246
_run_pipeline_tests = parse_flag_from_env("RUN_PIPELINE_TESTS", default=True)
@@ -2614,7 +2615,7 @@ def wrapper(*args, **kwargs):
26142615

26152616
return test_func_ref(*args, **kwargs)
26162617

2617-
return wrapper
2618+
return unittest.skipUnless(_run_flaky_tests, "test is flaky")(wrapper)
26182619

26192620
return decorator
26202621

0 commit comments

Comments
 (0)