Unverified Commit f93eb8ff authored by Philip Meier's avatar Philip Meier Committed by GitHub
Browse files

improve download tests and fix SBU (#7013)

* improve download tests

* move SBU to xfailed

* add SSL version output to CI
parent 511924c1
......@@ -23,6 +23,9 @@ jobs:
- name: Upgrade system packages
run: python -m pip install --upgrade pip setuptools wheel
- name: SSL
run: python -c 'import ssl; print(ssl.OPENSSL_VERSION)'
- name: Checkout repository
uses: actions/checkout@v2
......
......@@ -2,6 +2,7 @@ import contextlib
import itertools
import tempfile
import time
import traceback
import unittest.mock
import warnings
from datetime import datetime
......@@ -127,19 +128,23 @@ def log_download_attempts(
def retry(fn, times=1, wait=5.0):
msgs = []
tbs = []
for _ in range(times + 1):
try:
return fn()
except AssertionError as error:
msgs.append(str(error))
tbs.append("".join(traceback.format_exception(type(error), error, error.__traceback__)))
time.sleep(wait)
else:
raise AssertionError(
"\n".join(
(
f"Assertion failed {times + 1} times with {wait:.1f} seconds intermediate wait time.\n",
*(f"{idx}: {error}" for idx, error in enumerate(msgs, 1)),
"\n",
*[f"{'_' * 40} {idx:2d} {'_' * 40}\n\n{tb}" for idx, tb in enumerate(tbs, 1)],
(
f"Assertion failed {times + 1} times with {wait:.1f} seconds intermediate wait time. "
f"You can find the the full tracebacks above."
),
)
)
)
......@@ -149,10 +154,12 @@ def retry(fn, times=1, wait=5.0):
def assert_server_response_ok():
try:
yield
except URLError as error:
raise AssertionError("The request timed out.") from error
except HTTPError as error:
raise AssertionError(f"The server returned {error.code}: {error.reason}.") from error
except URLError as error:
raise AssertionError(
"Connection not possible due to SSL." if "SSL" in str(error) else "The request timed out."
) from error
except RecursionError as error:
raise AssertionError(str(error)) from error
......@@ -448,7 +455,6 @@ def make_parametrize_kwargs(download_configs):
omniglot(),
phototour(),
sbdataset(),
sbu(),
semeion(),
stl10(),
svhn(),
......@@ -472,6 +478,7 @@ def test_url_is_accessible(url, md5):
**make_parametrize_kwargs(
itertools.chain(
places365(), # https://github.com/pytorch/vision/issues/6268
sbu(), # https://github.com/pytorch/vision/issues/7005
)
)
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment