Skip to content

Commit

Permalink
Merge pull request #484 from EducationalTestingService/471-update-tem…
Browse files Browse the repository at this point in the history
…plate-for-latest-nbconvert

Update report generation to work with latest nbconvert
  • Loading branch information
desilinguist committed Oct 29, 2020
2 parents c712987 + 7a0d414 commit 8759f5b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
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
# 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

0 comments on commit 8759f5b

Please sign in to comment.