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: ...@@ -23,6 +23,9 @@ jobs:
- name: Upgrade system packages - name: Upgrade system packages
run: python -m pip install --upgrade pip setuptools wheel run: python -m pip install --upgrade pip setuptools wheel
- name: SSL
run: python -c 'import ssl; print(ssl.OPENSSL_VERSION)'
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v2 uses: actions/checkout@v2
......
...@@ -2,6 +2,7 @@ import contextlib ...@@ -2,6 +2,7 @@ import contextlib
import itertools import itertools
import tempfile import tempfile
import time import time
import traceback
import unittest.mock import unittest.mock
import warnings import warnings
from datetime import datetime from datetime import datetime
...@@ -127,19 +128,23 @@ def log_download_attempts( ...@@ -127,19 +128,23 @@ def log_download_attempts(
def retry(fn, times=1, wait=5.0): def retry(fn, times=1, wait=5.0):
msgs = [] tbs = []
for _ in range(times + 1): for _ in range(times + 1):
try: try:
return fn() return fn()
except AssertionError as error: except AssertionError as error:
msgs.append(str(error)) tbs.append("".join(traceback.format_exception(type(error), error, error.__traceback__)))
time.sleep(wait) time.sleep(wait)
else: else:
raise AssertionError( raise AssertionError(
"\n".join( "\n".join(
( (
f"Assertion failed {times + 1} times with {wait:.1f} seconds intermediate wait time.\n", "\n",
*(f"{idx}: {error}" for idx, error in enumerate(msgs, 1)), *[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): ...@@ -149,10 +154,12 @@ def retry(fn, times=1, wait=5.0):
def assert_server_response_ok(): def assert_server_response_ok():
try: try:
yield yield
except URLError as error:
raise AssertionError("The request timed out.") from error
except HTTPError as error: except HTTPError as error:
raise AssertionError(f"The server returned {error.code}: {error.reason}.") from 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: except RecursionError as error:
raise AssertionError(str(error)) from error raise AssertionError(str(error)) from error
...@@ -448,7 +455,6 @@ def make_parametrize_kwargs(download_configs): ...@@ -448,7 +455,6 @@ def make_parametrize_kwargs(download_configs):
omniglot(), omniglot(),
phototour(), phototour(),
sbdataset(), sbdataset(),
sbu(),
semeion(), semeion(),
stl10(), stl10(),
svhn(), svhn(),
...@@ -472,6 +478,7 @@ def test_url_is_accessible(url, md5): ...@@ -472,6 +478,7 @@ def test_url_is_accessible(url, md5):
**make_parametrize_kwargs( **make_parametrize_kwargs(
itertools.chain( itertools.chain(
places365(), # https://github.com/pytorch/vision/issues/6268 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