diff --git a/python/cuml/cuml_accel_tests/upstream/scikit-learn/example_collector.py b/python/cuml/cuml_accel_tests/upstream/scikit-learn/example_collector.py index 4b32b00662..be8fb5e46d 100644 --- a/python/cuml/cuml_accel_tests/upstream/scikit-learn/example_collector.py +++ b/python/cuml/cuml_accel_tests/upstream/scikit-learn/example_collector.py @@ -31,14 +31,30 @@ class ExampleNetworkError(UserWarning): _NETWORK_ERROR_PATTERNS = ( "urllib.error.HTTPError", "urllib.error.URLError", + "http.client.RemoteDisconnected", "http.client.IncompleteRead", + "http.client.BadStatusLine", "ConnectionError", + "ConnectionAbortedError", + "ConnectionRefusedError", "ConnectionResetError", + "RemoteDisconnected", "TimeoutError", + "requests.exceptions.ConnectionError", + "requests.exceptions.Timeout", + "socket.gaierror", "socket.timeout", + "ssl.SSLError", ) +def _network_error_pattern(output): + for pattern in _NETWORK_ERROR_PATTERNS: + if pattern in output: + return pattern + return None + + class _FakeModule: """Minimal module-like object so the cuml.accel xfail plugin can read ``item.module.__name__`` without crashing on custom test items.""" @@ -97,14 +113,14 @@ def runtest(self): pytest.xfail(reason=f"Timeout: example exceeded {timeout}s") if result.returncode != 0: stderr = result.stderr - for pattern in _NETWORK_ERROR_PATTERNS: - if pattern in stderr: - warnings.warn( - f"Example {self.path.name} failed due to network error" - f" ({pattern})", - ExampleNetworkError, - ) - pytest.xfail(reason=f"Network error: {pattern}") + pattern = _network_error_pattern(result.stderr + result.stdout) + if pattern: + warnings.warn( + f"Example {self.path.name} failed due to network error" + f" ({pattern})", + ExampleNetworkError, + ) + pytest.xfail(reason=f"Network error: {pattern}") if len(stderr) > 4000: stderr = "...\n" + stderr[-4000:] raise ExampleFailed(stderr)