You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As papermill doesn't seem to be actively maintained at the moment we should consider moving off of it and just using the smallest amount of nbclient code that we can do run things ourselves.
A very rough sketch would look something like
importnbformatimportpytestfromnbclientimportNotebookClient# Avoid hanging on with ipywidgets interact by using non-gui backendos.environ["MPLBACKEND"] ="agg"defget_notebook_client(notebook, commons, execution_dir=None):
ifexecution_dir:
commons["resources"]["metadata"]["path"] =execution_direlse:
execution_dir=commons["resources"]["metadata"]["path"]
test_notebook=nbformat.read(execution_dir/notebook, as_version=4)
returnNotebookClient(test_notebook, **commons)
# c.f. https://nbclient.readthedocs.io/en/latest/client.html@pytest.fixture()defcommons():
execution_dir=Path.cwd() /"docs"/"examples"/"notebooks"return {
"timeout": 600,
"kernel_name": "python3",
"reset_kc": True,
"resources": {"metadata": {"path": execution_dir}},
}
deftest_hello_world(commons):
client=get_notebook_client("hello-world.ipynb", commons)
assertclient.execute()
deftest_statisticalanalysis(commons):
# The Binder example uses specific relative pathsclient=get_notebook_client(
"StatisticalAnalysis.ipynb",
commons,
execution_dir=commons["resources"]["metadata"]["path"] /"binderexample",
)
assertclient.execute()
but for some of the notebook tests we want to be able to set variables in the notebook
* As a temporary fix to Issue #2104, downgrade jupyter-client to a
version less than v8.0.0 so that papermill is able to run.
This is not a sufficient fix and an alternative to using papermill
should be considered.
As noted in nteract/papermill#711 and elsewhere,
papermill
v2.4.0
is not compatible withjupyter-client
v8.0.0
+. A temporary fix for this is to downgradejupyter-client
to'jupyter-client<8.0.0'
during
pyhf/.github/workflows/notebooks.yml
Lines 29 to 32 in 3d200b2
but that's not a real solution.
As
papermill
doesn't seem to be actively maintained at the moment we should consider moving off of it and just using the smallest amount ofnbclient
code that we can do run things ourselves.A very rough sketch would look something like
but for some of the notebook tests we want to be able to set variables in the notebook
pyhf/tests/test_notebooks.py
Lines 55 to 60 in 3d200b2
which I'm not sure how to do with
nbclient
yet.For context,
papermill
does this here.Not sure if @agoose77 has any previous experience doing this on the fly (Angus, if not don't waste time looking at this).
The text was updated successfully, but these errors were encountered: