From d94397abd4981974744c45f92b8a65f87f976720 Mon Sep 17 00:00:00 2001 From: Piotr Date: Fri, 8 Mar 2024 10:28:45 +0100 Subject: [PATCH] fix links for model in report (#714) --- supervised/base_automl.py | 4 +- tests/tests_automl/test_automl_report.py | 49 ++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 tests/tests_automl/test_automl_report.py diff --git a/supervised/base_automl.py b/supervised/base_automl.py index 2e2dfb00..da473d32 100644 --- a/supervised/base_automl.py +++ b/supervised/base_automl.py @@ -2287,7 +2287,7 @@ def from_json(self, json_data): .styled-table td, .styled-table th {{ border: 1px solid #ddd; padding: 8px; -{{ +}} .styled-table tr:nth-child(even){{background-color: #f2f2f2;}} @@ -2389,7 +2389,7 @@ def _md_to_html(self, md_fname, page_type, dir_path, me=None): content_html = "\n".join(new_content) # change links - if page_type == "main": + if page_type == "automl-report-main": for f in os.listdir(dir_path): if os.path.exists(os.path.join(dir_path, f, "README.md")): old = f'href="{f}/README.html"' diff --git a/tests/tests_automl/test_automl_report.py b/tests/tests_automl/test_automl_report.py new file mode 100644 index 00000000..7e6e4b95 --- /dev/null +++ b/tests/tests_automl/test_automl_report.py @@ -0,0 +1,49 @@ +import os +import shutil +import unittest +from pathlib import Path + +import numpy as np +import pandas as pd +import pytest +from sklearn import datasets +from sklearn.decomposition import PCA +from sklearn.pipeline import make_pipeline + +from supervised import AutoML +from supervised.exceptions import AutoMLException + +iris = datasets.load_iris() + +class AutoMLReportTest(unittest.TestCase): + automl_dir = "AutoMLTest" + + def tearDown(self): + shutil.rmtree(self.automl_dir, ignore_errors=True) + + def setUp(self): + shutil.rmtree(self.automl_dir, ignore_errors=True) + + def test_report(self): + """Tests AutoML in the iris dataset (Multiclass classification)""" + model = AutoML( + algorithms=["Baseline"], + explain_level=0, verbose=0, random_state=1, results_path=self.automl_dir + ) + model.fit(iris.data, iris.target) + model.report() + + report_path = os.path.join(self.automl_dir, "README.html") + self.assertTrue(os.path.exists(report_path)) + + content = None + with open(report_path, "r") as fin: + content = fin.read() + + + #print(content) + link = '' + self.assertFalse(link in content) + + +