Skip to content

Commit f28a6a3

Browse files
authored
Merge pull request #43 from ThomasBouche/hotfix/upgrade_dependencies
Hotfix/upgrade dependencies
2 parents 31ab98b + 641eb7f commit f28a6a3

File tree

11 files changed

+49
-133
lines changed

11 files changed

+49
-133
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
strategy:
99
max-parallel: 1
1010
matrix:
11-
python-version: ["3.7", "3.8", "3.9", "3.10"]
11+
python-version: ["3.8", "3.9", "3.10"]
1212
steps:
1313
- uses: actions/checkout@v2
1414
- name: Set up Python ${{ matrix.python-version }}

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ sd.generate_report(
102102

103103
## 🛠 Installation
104104

105-
Eurybia is intended to work with Python versions 3.7 to 3.10. Installation can be done with pip:
105+
Eurybia is intended to work with Python versions 3.8 to 3.10. Installation can be done with pip:
106106

107107
```
108108
pip install eurybia

docs/source/installation-instructions/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Installation instructions
44
Installing
55
----------
66

7-
**Eurybia** is intended to work with Python versions 3.7 to 3.9. Installation can be done with pip:
7+
**Eurybia** is intended to work with Python versions 3.8 to 3.10. Installation can be done with pip:
88

99
.. code:: bash
1010

eurybia/assets/report_template.html

-58
This file was deleted.

eurybia/core/smartdrift.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def generate_report(
382382
project_info_file=project_info_file,
383383
explainer=self.xpl,
384384
smartdrift=self,
385-
config=dict(title_story=title_story, title_description=title_description),
385+
config_report=dict(title_story=title_story, title_description=title_description),
386386
output_file=output_file,
387387
)
388388
finally:

eurybia/report/generation.py

+20-44
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,18 @@
11
"""
22
Report generation helper module.
33
"""
4-
from base64 import b64encode
54
from datetime import datetime
65
from typing import Optional
76

87
import datapane as dp
9-
import importlib_resources as ir
108
import pandas as pd
11-
from jinja2 import Environment, FileSystemLoader
129
from shapash.explainer.smart_explainer import SmartExplainer
1310

1411
from eurybia import SmartDrift
1512
from eurybia.report.project_report import DriftReport
1613

1714

18-
def _load_custom_template(report: dp.Report) -> dp.Report:
19-
"""
20-
This function feeds a customised html template to Datapane
21-
22-
Parameters
23-
----------
24-
report : datapane.Report
25-
Report object
26-
Returns
27-
----------
28-
datapane.Report
29-
"""
30-
report._local_writer.assets = ir.files("eurybia.assets")
31-
logo_img = (report._local_writer.assets / "logo_eurybia_dp.png").read_bytes()
32-
report._local_writer.logo = f"data:image/png;base64,{b64encode(logo_img).decode('ascii')}"
33-
template_loader = FileSystemLoader(report._local_writer.assets)
34-
template_env = Environment(loader=template_loader)
35-
template_env.globals["include_raw"] = dp.client.api.report.core.include_raw
36-
report._local_writer.template = template_env.get_template("report_template.html")
37-
return report
38-
39-
40-
def _get_index(dr: DriftReport, project_info_file: str, config: Optional[dict]) -> dp.Page:
15+
def _get_index(dr: DriftReport, project_info_file: str, config_report: Optional[dict]) -> dp.Page:
4116
"""
4217
This function generates and returns a Datapane page containing the Eurybia report index
4318
@@ -47,7 +22,7 @@ def _get_index(dr: DriftReport, project_info_file: str, config: Optional[dict])
4722
DriftReport object
4823
project_info_file : str
4924
Path to the file used to display some information about the project in the report.
50-
config : dict, optional
25+
config_report : dict, optional
5126
Report configuration options.
5227
Returns
5328
----------
@@ -66,8 +41,12 @@ def _get_index(dr: DriftReport, project_info_file: str, config: Optional[dict])
6641
# Title and logo
6742
index_block += [dp.Group(dp.HTML(eurybia_logo), dp.Text(f"# {dr.title_story}"), columns=2)]
6843

69-
if config is not None and "title_description" in config.keys() and config["title_description"] != "":
70-
raw_title = config["title_description"]
44+
if (
45+
config_report is not None
46+
and "title_description" in config_report.keys()
47+
and config_report["title_description"] != ""
48+
):
49+
raw_title = config_report["title_description"]
7150
index_block += [dp.Text(f"## {raw_title}")]
7251
index_str = "## Eurybia Report contents \n"
7352

@@ -317,8 +296,8 @@ def _get_datadrift(dr: DriftReport) -> dp.Page:
317296
Features are sorted according to their respective importance in the datadrift classifier.
318297
For categorical features, the possible values are sorted by descending difference between the two datasets."""
319298
),
320-
dp.Select(blocks=plot_dataset_analysis),
321-
dp.Select(blocks=table_dataset_analysis),
299+
dp.Select(blocks=plot_dataset_analysis, type=dp.SelectType.DROPDOWN),
300+
dp.Select(blocks=table_dataset_analysis, type=dp.SelectType.DROPDOWN),
322301
]
323302
if dr.smartdrift.deployed_model is not None:
324303
blocks += [
@@ -350,7 +329,7 @@ def _get_datadrift(dr: DriftReport) -> dp.Page:
350329
This representation constitutes a support to understand the drift when the analysis of the dataset is unclear.
351330
In the drop-down menu, features are sorted by importance in the data drift detection."""
352331
),
353-
dp.Select(blocks=plot_datadrift_contribution),
332+
dp.Select(blocks=plot_datadrift_contribution, type=dp.SelectType.DROPDOWN),
354333
]
355334
if dr.smartdrift.historical_auc is not None:
356335
blocks += [
@@ -387,7 +366,7 @@ def _get_modeldrift(dr: DriftReport) -> dp.Page:
387366
else:
388367
for i in range(len(labels)):
389368
plot_modeldrift.append(dp.Plot(fig_list[i], label=labels[i]))
390-
modeldrift_plot = dp.Select(blocks=plot_modeldrift, label="reference_columns")
369+
modeldrift_plot = dp.Select(blocks=plot_modeldrift, label="reference_columns", type=dp.SelectType.DROPDOWN)
391370
else:
392371
modeldrift_plot = dp.Text("## Smartdrift.data_modeldrift is None")
393372
blocks = [
@@ -409,7 +388,7 @@ def execute_report(
409388
explainer: SmartExplainer,
410389
project_info_file: str,
411390
output_file: str,
412-
config: Optional[dict] = None,
391+
config_report: Optional[dict] = None,
413392
):
414393
"""
415394
Creates the report
@@ -422,33 +401,30 @@ def execute_report(
422401
Compiled shapash explainer.
423402
project_info_file : str
424403
Path to the file used to display some information about the project in the report.
425-
config : dict, optional
404+
config_report : dict, optional
426405
Report configuration options.
427406
output_file : str
428407
Path to the HTML file to write
429408
"""
430409

431-
if config is None:
432-
config = {}
410+
if config_report is None:
411+
config_report = {}
433412

434413
dr = DriftReport(
435414
smartdrift=smartdrift,
436415
explainer=explainer, # rename to match kwarg
437416
project_info_file=project_info_file,
438-
config=config,
417+
config_report=config_report,
439418
)
440419

441420
pages = []
442-
pages.append(_get_index(dr, project_info_file, config))
421+
pages.append(_get_index(dr, project_info_file, config_report))
443422
if project_info_file is not None:
444423
pages.append(_get_project_info(dr))
445424
pages.append(_get_consistency_analysis(dr))
446425
pages.append(_get_datadrift(dr))
447426
if dr.smartdrift.data_modeldrift is not None:
448427
pages.append(_get_modeldrift(dr))
449428

450-
report = dp.Report(blocks=pages)
451-
report = _load_custom_template(report)
452-
report._save(
453-
path=output_file, open=False, formatting=dp.ReportFormatting(light_prose=False, width=dp.ReportWidth.MEDIUM)
454-
)
429+
report = dp.View(blocks=pages)
430+
dp.save_report(report, path=output_file, open=False, name="report.html")

eurybia/report/project_report.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class DriftReport:
4646
Dataframe of predicted values computed on both df_baseline and df_current
4747
feature_importance : pd.DataFrame, optional (default: None)
4848
Dataframe of feature importance from production model and drift model
49-
config : dict, optional
49+
config_report : dict, optional
5050
Configuration options for the report
5151
"""
5252

@@ -55,7 +55,7 @@ def __init__(
5555
smartdrift: SmartDrift,
5656
explainer: SmartExplainer,
5757
project_info_file: Optional[str] = None,
58-
config: Optional[Dict] = None,
58+
config_report: Optional[Dict] = None,
5959
):
6060
"""
6161
Parameters
@@ -66,7 +66,7 @@ def __init__(
6666
A shapash SmartExplainer object that has already be compiled
6767
project_info_file : str
6868
Path to the yml file containing information about the project (author, description, ...)
69-
config : dict, optional
69+
config_report : dict, optional
7070
Contains configuration options for the report
7171
features_imp_list : list
7272
list of features order by importance
@@ -79,7 +79,7 @@ def __init__(
7979
if self.explainer.features_imp is None:
8080
self.explainer.compute_features_import(force=True)
8181
self.features_imp_list = self.explainer.features_imp[0].sort_values(ascending=False).index.to_list() # type: ignore
82-
self.config = config if config is not None else dict()
82+
self.config_report = config_report if config_report is not None else dict()
8383

8484
self.data_concat = self._create_data_drift(
8585
df_current=self.smartdrift.df_current,
@@ -92,8 +92,8 @@ def __init__(
9292
else:
9393
self.metadata = load_yml(path=project_info_file)
9494

95-
if "title_story" in self.config.keys():
96-
self.title_story = self.config["title_story"]
95+
if "title_story" in self.config_report.keys():
96+
self.title_story = self.config_report["title_story"]
9797
else:
9898
self.title_story = "Eurybia report"
9999

requirements.dev.txt

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
pip>=21.1
2-
catboost>=0.22
3-
category-encoders==2.1.0
4-
lightgbm==2.3.1
5-
numpy>1.18.0
6-
pandas>1.0.2
2+
catboost>=1.0.1
3+
category-encoders>=2.6.0
4+
lightgbm>=2.3.1
5+
numpy>=1.18.0
6+
pandas>=1.0.2
77
plotly>=4.12.0
88
shapash>=2.0.0
99
Sphinx==4.5.0
@@ -17,17 +17,16 @@ nbsphinx==0.8.8
1717
sphinx_material==0.0.35
1818
pytest>=5.2.3
1919
pytest-cov==2.8.1
20-
scikit-learn>=0.24.2
20+
scikit-learn>=1.0.1
2121
xgboost>=1.0.0
2222
nbformat>4.2.0
2323
numba>=0.53.0
2424
nbconvert>=6.3
2525
papermill>=2.0.0
2626
matplotlib>=3.3.0
27-
seaborn==0.11.1
27+
seaborn>=0.12.2
2828
notebook>=6.0.0
2929
Jinja2>=2.11.0
3030
scipy>=1.1.0
31-
types-PyYAML==6.0.5
32-
datapane==0.14.0
31+
datapane>=0.16.7
3332
pre-commit==2.18.1

setup.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
exec(f.read(), version_d)
1717

1818
requirements = [
19-
"catboost>=0.22",
20-
"datapane==0.14.0",
19+
"catboost>=1.0.1",
20+
"datapane>=0.16.7",
2121
"ipywidgets>=7.4.2",
2222
"jinja2>=2.11.0",
2323
"scipy>=1.4.0",
@@ -38,7 +38,7 @@
3838
setup(
3939
name="eurybia", # Replace with your own username
4040
version=version_d["__version__"],
41-
python_requires=">3.6, < 3.11",
41+
python_requires=">3.7, < 3.11",
4242
url="https://github.com/MAIF/eurybia",
4343
author="Nicolas Roux, Johann Martin, Thomas Bouché",
4444
author_email="[email protected]",
@@ -47,7 +47,6 @@
4747
long_description_content_type="text/markdown",
4848
classifiers=[
4949
"Programming Language :: Python :: 3",
50-
"Programming Language :: Python :: 3.7",
5150
"Programming Language :: Python :: 3.8",
5251
"Programming Language :: Python :: 3.9",
5352
"Programming Language :: Python :: 3.10",
@@ -84,7 +83,6 @@
8483
"eurybia/assets/local-report-base.css",
8584
"eurybia/assets/local-report-base.js",
8685
"eurybia/assets/logo_eurybia_dp.png",
87-
"eurybia/assets/report_template.html",
8886
],
8987
),
9088
],

0 commit comments

Comments
 (0)