From 6f88dace960e73768b4a3735bedd8483fd9d02d2 Mon Sep 17 00:00:00 2001 From: Bradley Dice Date: Wed, 11 Dec 2024 08:57:05 -0600 Subject: [PATCH] Fix SSL error. --- conda/environments/all_cuda-118_arch-x86_64.yaml | 1 + conda/environments/all_cuda-125_arch-x86_64.yaml | 1 + dependencies.yaml | 1 + python/cuml/cuml/tests/conftest.py | 11 +++++++++++ python/cuml/cuml/tests/dask/conftest.py | 10 ++++++++++ python/cuml/pyproject.toml | 1 + 6 files changed, 25 insertions(+) diff --git a/conda/environments/all_cuda-118_arch-x86_64.yaml b/conda/environments/all_cuda-118_arch-x86_64.yaml index c3f0e2ad61..f7cad28ce8 100644 --- a/conda/environments/all_cuda-118_arch-x86_64.yaml +++ b/conda/environments/all_cuda-118_arch-x86_64.yaml @@ -8,6 +8,7 @@ channels: - nvidia dependencies: - c-compiler +- certifi - cmake>=3.26.4,!=3.30.0 - cuda-python>=11.7.1,<12.0a0,<=11.8.3 - cuda-version=11.8 diff --git a/conda/environments/all_cuda-125_arch-x86_64.yaml b/conda/environments/all_cuda-125_arch-x86_64.yaml index 118b9cfb4f..4e8b339842 100644 --- a/conda/environments/all_cuda-125_arch-x86_64.yaml +++ b/conda/environments/all_cuda-125_arch-x86_64.yaml @@ -8,6 +8,7 @@ channels: - nvidia dependencies: - c-compiler +- certifi - cmake>=3.26.4,!=3.30.0 - cuda-cudart-dev - cuda-nvcc diff --git a/dependencies.yaml b/dependencies.yaml index 454b8a8038..a3b5b87cd8 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -510,6 +510,7 @@ dependencies: common: - output_types: [conda, requirements, pyproject] packages: + - certifi - *cython - dask-ml - hdbscan>=0.8.39,<0.8.40 diff --git a/python/cuml/cuml/tests/conftest.py b/python/cuml/cuml/tests/conftest.py index 1522b27983..a48adbf6a9 100644 --- a/python/cuml/cuml/tests/conftest.py +++ b/python/cuml/cuml/tests/conftest.py @@ -24,6 +24,9 @@ from sklearn.utils import Bunch from datetime import timedelta from math import ceil +from ssl import create_default_context +from urllib.request import build_opener, HTTPSHandler, install_opener +import certifi import hypothesis from cuml.internals.safe_imports import gpu_only_import import pytest @@ -41,6 +44,14 @@ # Add the import here for any plugins that should be loaded EVERY TIME pytest_plugins = "cuml.testing.plugins.quick_run_plugin" + +# Install SSL certificates +def pytest_sessionstart(session): + ssl_context = create_default_context(cafile=certifi.where()) + https_handler = HTTPSHandler(context=ssl_context) + install_opener(build_opener(https_handler)) + + CI = os.environ.get("CI") in ("true", "1") HYPOTHESIS_ENABLED = os.environ.get("HYPOTHESIS_ENABLED") in ( "true", diff --git a/python/cuml/cuml/tests/dask/conftest.py b/python/cuml/cuml/tests/dask/conftest.py index bdaf591538..1e5005cf1e 100644 --- a/python/cuml/cuml/tests/dask/conftest.py +++ b/python/cuml/cuml/tests/dask/conftest.py @@ -1,6 +1,9 @@ # Copyright (c) 2020-2024, NVIDIA CORPORATION. +import certifi import pytest +from ssl import create_default_context +from urllib.request import build_opener, HTTPSHandler, install_opener from dask_cuda import initialize from dask_cuda import LocalCUDACluster @@ -12,6 +15,13 @@ enable_infiniband = False +# Install SSL certificates +def pytest_sessionstart(session): + ssl_context = create_default_context(cafile=certifi.where()) + https_handler = HTTPSHandler(context=ssl_context) + install_opener(build_opener(https_handler)) + + @pytest.fixture(scope="module") def cluster(): diff --git a/python/cuml/pyproject.toml b/python/cuml/pyproject.toml index 933f073384..5035decfcc 100644 --- a/python/cuml/pyproject.toml +++ b/python/cuml/pyproject.toml @@ -121,6 +121,7 @@ classifiers = [ [project.optional-dependencies] test = [ + "certifi", "cython>=3.0.0", "dask-ml", "hdbscan>=0.8.39,<0.8.40",