Skip to content

Commit

Permalink
Add JupyterLab warnings to report notebooks
Browse files Browse the repository at this point in the history
  • Loading branch information
sserita committed Aug 11, 2023
1 parent 79a16ad commit a0e4d5d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
4 changes: 3 additions & 1 deletion jupyter_notebooks/Tutorials/reporting/ReportGeneration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@
"In addition to the standard HTML-page reports demonstrated above, pyGSTi is able to generate a Jupyter notebook containing the Python commands to create the figures and tables within a general report. This is facilitated\n",
"by `Workspace` objects, which are factories for figures and tables (see previous tutorials). By calling `Report.write_notebook`, all of the relevant `Workspace` initialization and calls are dumped to a new notebook file, which can be run (either fully or partially) by the user at their convenience. Creating such \"report notebooks\" has the advantage that the user may insert Python code amidst the figure and table generation calls to inspect or modify what is display in a highly customizable fashion. The chief disadvantages of report notebooks is that they require the user to 1) have a Jupyter server up and running and 2) to run the notebook before any figures are displayed.\n",
"\n",
"<font color='red'>Note that interactive cells in report notebooks require JavaScript, and therefore do not work with JupyterLab. Please continue to use to track this issue, see https://github.com/pyGSTio/pyGSTi/issues/205.</font>\n",
"\n",
"The line below demonstrates how to create a report notebook using `write_notebook`. Note that the argument list is very similar to the other `Report` output methods."
]
},
Expand Down Expand Up @@ -365,7 +367,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.10.10"
}
},
"nbformat": 4,
Expand Down
16 changes: 16 additions & 0 deletions pygsti/report/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ def write_notebook(self, path, auto_open=False, connected=False, verbosity=0):
who want to tinker with the standard analysis presented in the static
HTML or LaTeX format reports.
Note that interactive cells in report notebooks require JavaScript,
and therefore do not work with JupyterLab. Please continue to use
classic Jupyter notebooks for PyGSTi report notebooks. To track this issue,
see https://github.com/pyGSTio/pyGSTi/issues/205.
Parameters
----------
path : str or path-like object
Expand Down Expand Up @@ -249,6 +254,12 @@ def write_notebook(self, path, auto_open=False, connected=False, verbosity=0):
nb = _Notebook()
nb.add_markdown('# {title}\n(Created on {date})'.format(
title=title, date=_time.strftime("%B %d, %Y")))

nb.add_markdown("## JupyterLab Incompatibility Warning\n" +
"<font color='red'>Note that interactive cells in report notebooks require JavaScript, " +
"and therefore do not work with JupyterLab. Please continue to use " +
"classic Jupyter notebooks for PyGSTi report notebooks. To track this issue, " +
"see https://github.com/pyGSTio/pyGSTi/issues/205.</font>")

nb.add_code("""\
import pickle
Expand Down Expand Up @@ -353,6 +364,11 @@ def write_notebook(self, path, auto_open=False, connected=False, verbosity=0):

printer.log("Report Notebook created as %s" % path)

printer.warning("""Note that interactive cells in report notebooks require JavaScript,
and therefore do not work with JupyterLab. Please continue to use
classic Jupyter notebooks for PyGSTi report notebooks. To track this issue,
see https://github.com/pyGSTio/pyGSTi/issues/205.""")

if auto_open:
port = "auto" if auto_open is True else int(auto_open)
nb.launch(str(path), port=port)
Expand Down

0 comments on commit a0e4d5d

Please sign in to comment.