diff --git a/notebooks/individual-dashboards/erroranalysis-dashboard/erroranalysis-dashboard-regression-superconductor.ipynb b/notebooks/individual-dashboards/erroranalysis-dashboard/erroranalysis-dashboard-regression-superconductor.ipynb index cfed83d1b6..d7dea4013d 100644 --- a/notebooks/individual-dashboards/erroranalysis-dashboard/erroranalysis-dashboard-regression-superconductor.ipynb +++ b/notebooks/individual-dashboards/erroranalysis-dashboard/erroranalysis-dashboard-regression-superconductor.ipynb @@ -61,6 +61,7 @@ "import pandas as pd\n", "\n", "from urllib.request import urlretrieve\n", + "import requests\n", "import zipfile\n", "\n", "# Imports for SHAP MimicExplainer with LightGBM surrogate model\n", @@ -86,7 +87,13 @@ "source": [ "outdirname = 'superconduct'\n", "zipfilename = outdirname + '.zip'\n", - "urlretrieve('https://archive.ics.uci.edu/static/public/464/superconductivty+data.zip', zipfilename)\n", + "url = 'https://archive.ics.uci.edu/static/public/464/superconductivty+data.zip'\n", + "# temporary workaround for UCI repository until website SSL certificate\n", + "# is renewed with requests instead of urlretrieve\n", + "# urlretrieve(url, zipfilename)\n", + "content = requests.get(url, verify=False).content\n", + "with open(zipfilename, mode='wb') as localfile:\n", + " localfile.write(content)\n", "with zipfile.ZipFile(zipfilename, 'r') as unzip:\n", " unzip.extractall('.')\n", "df = pd.read_csv(r'./train.csv')\n", @@ -167,9 +174,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "predictions = model.predict(X_test)\n", @@ -244,9 +249,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "scrolled": false - }, + "metadata": {}, "outputs": [], "source": [ "ErrorAnalysisDashboard(global_explanation, model, dataset=X_test,\n", @@ -262,7 +265,7 @@ } ], "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, @@ -276,9 +279,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.13" + "version": "3.10.11" } }, "nbformat": 4, - "nbformat_minor": 2 + "nbformat_minor": 4 } diff --git a/responsibleai/tests/common_utils.py b/responsibleai/tests/common_utils.py index 3c131a53d0..d0441f5583 100644 --- a/responsibleai/tests/common_utils.py +++ b/responsibleai/tests/common_utils.py @@ -3,6 +3,7 @@ import json import random +import ssl import numpy as np import pandas as pd @@ -87,6 +88,9 @@ def fetch(self): def create_adult_income_dataset(create_small_dataset=True): + # workaround for SSL expiration error from UCI website + default_http_context = ssl._create_default_https_context + ssl._create_default_https_context = ssl._create_unverified_context fetcher = FetchDiceAdultCensusIncomeDataset() action_name = "Adult dataset download" err_msg = "Failed to download adult dataset" @@ -122,6 +126,7 @@ def create_adult_income_dataset(create_small_dataset=True): data_train, data_test, y_train, y_test = train_test_split( dataset, target, test_size=5000, random_state=7, stratify=target ) + ssl._create_default_https_context = default_http_context return ( data_train, data_test, diff --git a/responsibleai_text/tests/test_rai_text_insights_save_and_load_scenarios.py b/responsibleai_text/tests/test_rai_text_insights_save_and_load_scenarios.py index 1bdf127b0b..b0ddf6f4c5 100644 --- a/responsibleai_text/tests/test_rai_text_insights_save_and_load_scenarios.py +++ b/responsibleai_text/tests/test_rai_text_insights_save_and_load_scenarios.py @@ -3,6 +3,7 @@ import os import shutil +import sys from pathlib import Path from tempfile import TemporaryDirectory @@ -14,6 +15,7 @@ create_text_classification_pipeline, load_covid19_emergency_event_dataset, load_emotion_dataset) +from huggingface_hub.utils._validators import HFValidationError from rai_text_insights_validator import validate_rai_text_insights from responsibleai._internal.constants import ManagerNames @@ -128,8 +130,13 @@ def test_loading_rai_insights_without_model_file(self): model_name = 'text-classification-model' model_pkl_path = Path(tmpdir) / "rai_insights" / model_name shutil.rmtree(model_pkl_path) - match_msg = 'Can\'t load the configuration' - with pytest.raises(OSError, match=match_msg): + if sys.version_info[:2] == (3, 7): + match_msg = 'Can\'t load the configuration' + expected_error = OSError + else: + match_msg = 'Repo id must be in the form' + expected_error = HFValidationError + with pytest.raises(expected_error, match=match_msg): without_model_rai_insights = RAITextInsights.load(save_path) assert without_model_rai_insights.model is None