Skip to content

Commit 798dce8

Browse files
authored
fix: flaky test test_transformers_image_embedder_other (#5130)
## Changes Made This test keeps failing in CI. Adding a retry here so that it succeeds. ## Related Issues <!-- Link to related GitHub issues, e.g., "Closes #123" --> ## Checklist - [ ] Documented in API Docs (if applicable) - [ ] Documented in User Guide (if applicable) - [ ] If adding a new documentation page, doc is added to `docs/mkdocs.yml` navigation - [ ] Documentation builds and is formatted properly (tag @/ccmao1130 for docs review)
1 parent ef36735 commit 798dce8

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

tests/ai/test_transformers.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
pytest.importorskip("PIL")
88

99

10+
import time
11+
1012
import numpy as np
1113
import torch
1214

@@ -46,7 +48,20 @@ def test_transformers_image_embedder_other(model_name, dimensions, run_model_in_
4648
assert descriptor.get_options() == mock_options
4749

4850
if not IS_CI or run_model_in_ci:
49-
embedder = descriptor.instantiate()
51+
retry_delay = 5 # seconds
52+
max_retries = 5
53+
54+
# retry instantiation because Hugging Face is flaky
55+
for attempt in range(max_retries):
56+
try:
57+
embedder = descriptor.instantiate()
58+
except OSError as e:
59+
if attempt < max_retries - 1:
60+
time.sleep(retry_delay)
61+
else:
62+
raise e
63+
else:
64+
break
5065

5166
# Test with a variety of image sizes and shapes that should be preprocessed correctly.
5267
# TODO(desmond): This doesn't work with greyscale images. I wonder if we should require users to cast

0 commit comments

Comments
 (0)