Skip to content

Commit

Permalink
Colab prettier suite view (deepchecks#717)
Browse files Browse the repository at this point in the history
* collab_html_view

* collab_html_view

* collab_html_view

* collab_html_view

* collab_html_view

* added_allow
  • Loading branch information
JKL98ISR authored Jan 23, 2022
1 parent ed57d2e commit ddf1a43
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion deepchecks/base/display_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@ def _display_suite_no_widgets(summary: str,
others_df = dataframe_to_html(others_table.style.hide_index())
display_html(others_h2 + others_df, raw=True)

display_html(f'<br><a href="#summary_{unique_id}" style="font-size: 14px">Go to top</a>', raw=True)
if unique_id:
display_html(f'<br><a href="#summary_{unique_id}" style="font-size: 14px">Go to top</a>', raw=True)


def display_suite_result(suite_name: str, results: List[Union[CheckResult, CheckFailure]],
Expand Down
11 changes: 10 additions & 1 deletion deepchecks/base/suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
"""Module containing the Suite object, used for running a set of checks together."""
# pylint: disable=broad-except
import abc
import io
from collections import OrderedDict
from typing import Union, List, Optional, Tuple, Any, Container, Mapping

from IPython.core.display import display_html
from IPython.core.getipython import get_ipython
import jsonpickle

from deepchecks.base.display_suite import display_suite_result, ProgressBar
Expand Down Expand Up @@ -43,7 +46,13 @@ def __repr__(self):
return self.name

def _ipython_display_(self):
display_suite_result(self.name, self.results)
# google colab has no support for widgets but good support for viewing html pages in the output
if 'google.colab' in str(get_ipython()):
html_out = io.StringIO()
display_suite_result(self.name, self.results, html_out=html_out)
display_html(html_out.getvalue(), raw=True)
else:
display_suite_result(self.name, self.results)

def show(self):
"""Display suite result."""
Expand Down
1 change: 1 addition & 0 deletions spelling-allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ r2
tqdm
nan
kaggle
colab

0 comments on commit ddf1a43

Please sign in to comment.