Skip to content

Commit 35f7afb

Browse files
Yosua Michael Maranathafacebook-github-bot
authored andcommitted
[fbsync] improve download tests and fix SBU (#7013)
Summary: * improve download tests * move SBU to xfailed * add SSL version output to CI Reviewed By: datumbox Differential Revision: D41836891 fbshipit-source-id: 69e89766867df8ab47dc057404c988d73c4117c5
1 parent 05bb93e commit 35f7afb

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

.github/workflows/tests-schedule.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ jobs:
2323
- name: Upgrade system packages
2424
run: python -m pip install --upgrade pip setuptools wheel
2525

26+
- name: SSL
27+
run: python -c 'import ssl; print(ssl.OPENSSL_VERSION)'
28+
2629
- name: Checkout repository
2730
uses: actions/checkout@v2
2831

test/test_datasets_download.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import itertools
33
import tempfile
44
import time
5+
import traceback
56
import unittest.mock
67
import warnings
78
from datetime import datetime
@@ -127,19 +128,23 @@ def add_mock(stack, name, file, **kwargs):
127128

128129

129130
def retry(fn, times=1, wait=5.0):
130-
msgs = []
131+
tbs = []
131132
for _ in range(times + 1):
132133
try:
133134
return fn()
134135
except AssertionError as error:
135-
msgs.append(str(error))
136+
tbs.append("".join(traceback.format_exception(type(error), error, error.__traceback__)))
136137
time.sleep(wait)
137138
else:
138139
raise AssertionError(
139140
"\n".join(
140141
(
141-
f"Assertion failed {times + 1} times with {wait:.1f} seconds intermediate wait time.\n",
142-
*(f"{idx}: {error}" for idx, error in enumerate(msgs, 1)),
142+
"\n",
143+
*[f"{'_' * 40} {idx:2d} {'_' * 40}\n\n{tb}" for idx, tb in enumerate(tbs, 1)],
144+
(
145+
f"Assertion failed {times + 1} times with {wait:.1f} seconds intermediate wait time. "
146+
f"You can find the the full tracebacks above."
147+
),
143148
)
144149
)
145150
)
@@ -149,10 +154,12 @@ def retry(fn, times=1, wait=5.0):
149154
def assert_server_response_ok():
150155
try:
151156
yield
152-
except URLError as error:
153-
raise AssertionError("The request timed out.") from error
154157
except HTTPError as error:
155158
raise AssertionError(f"The server returned {error.code}: {error.reason}.") from error
159+
except URLError as error:
160+
raise AssertionError(
161+
"Connection not possible due to SSL." if "SSL" in str(error) else "The request timed out."
162+
) from error
156163
except RecursionError as error:
157164
raise AssertionError(str(error)) from error
158165

@@ -448,7 +455,6 @@ def make_parametrize_kwargs(download_configs):
448455
omniglot(),
449456
phototour(),
450457
sbdataset(),
451-
sbu(),
452458
semeion(),
453459
stl10(),
454460
svhn(),
@@ -472,6 +478,7 @@ def test_url_is_accessible(url, md5):
472478
**make_parametrize_kwargs(
473479
itertools.chain(
474480
places365(), # https://github.com/pytorch/vision/issues/6268
481+
sbu(), # https://github.com/pytorch/vision/issues/7005
475482
)
476483
)
477484
)

0 commit comments

Comments
 (0)