Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update report generation to work with latest nbconvert #484

Merged
merged 4 commits into from
Oct 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ jupyter
ipython<7.17
nose
notebook
nbconvert<6.0
numpy
pandas
seaborn
Expand Down
2 changes: 1 addition & 1 deletion rsmtool/notebooks/templates/report.tpl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{%- extends 'full.tpl' -%}
{%- extends 'index.html.j2' -%}

{% block input %}
{%- endblock input %}
Expand Down
16 changes: 14 additions & 2 deletions rsmtool/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
"""

import argparse
import asyncio
import logging
import json
import os
import sys

from os.path import (abspath,
basename,
Expand Down Expand Up @@ -317,11 +319,21 @@ def convert_ipynb_to_html(notebook_file, html_file):
:ref:`render_notebook <render_notebook>` command-line utility.
"""

# `nbconvert` uses `asyncio` which uses an entirely default
desilinguist marked this conversation as resolved.
Show resolved Hide resolved
# implemention of the event loop on Windows for Cpython 3.8
# which breaks the report generation unless we include the
# following workaround
if (sys.version_info[0] == 3 and
sys.version_info[1] >= 8 and
sys.platform.startswith('win')):
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())

# set a high timeout for datasets with a large number of features
report_config = Config({'ExecutePreprocessor': {'enabled': True,
'timeout': 3600},
'HTMLExporter': {'template_path': [template_path],
'template_file': 'report.tpl'}})
'HTMLExporter': {"template_name": "classic",
"template_file": join(template_path,
'report.tpl')}})

exportHtml = HTMLExporter(config=report_config)
output, _ = exportHtml.from_filename(notebook_file)
Expand Down