Skip to content

Commit 8759f5b

Browse files
authored
Merge pull request #484 from EducationalTestingService/471-update-template-for-latest-nbconvert
Update report generation to work with latest nbconvert
2 parents c712987 + 7a0d414 commit 8759f5b

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ jupyter
33
ipython<7.17
44
nose
55
notebook
6-
nbconvert<6.0
76
numpy
87
pandas
98
seaborn

rsmtool/notebooks/templates/report.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{%- extends 'full.tpl' -%}
1+
{%- extends 'index.html.j2' -%}
22

33
{% block input %}
44
{%- endblock input %}

rsmtool/reporter.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
"""
1010

1111
import argparse
12+
import asyncio
1213
import logging
1314
import json
1415
import os
16+
import sys
1517

1618
from os.path import (abspath,
1719
basename,
@@ -317,11 +319,21 @@ def convert_ipynb_to_html(notebook_file, html_file):
317319
:ref:`render_notebook <render_notebook>` command-line utility.
318320
"""
319321

322+
# `nbconvert` uses `asyncio` which uses an entirely default
323+
# implemention of the event loop on Windows for Cpython 3.8
324+
# which breaks the report generation unless we include the
325+
# following workaround
326+
if (sys.version_info[0] == 3 and
327+
sys.version_info[1] >= 8 and
328+
sys.platform.startswith('win')):
329+
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
330+
320331
# set a high timeout for datasets with a large number of features
321332
report_config = Config({'ExecutePreprocessor': {'enabled': True,
322333
'timeout': 3600},
323-
'HTMLExporter': {'template_path': [template_path],
324-
'template_file': 'report.tpl'}})
334+
'HTMLExporter': {"template_name": "classic",
335+
"template_file": join(template_path,
336+
'report.tpl')}})
325337

326338
exportHtml = HTMLExporter(config=report_config)
327339
output, _ = exportHtml.from_filename(notebook_file)

0 commit comments

Comments
 (0)