nteract/papermill

nbclient.exceptions.DeadKernelError if Python Warnings Filter set to 'default'

Open

#660 opened on Apr 6, 2022

View on GitHub
 (0 comments) (2 reactions) (0 assignees)Python (402 forks)batch import
bughelp wanted

Repository metrics

Stars
 (5,381 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Question

:wave: Hi. While trying to get a nightly notebook pytest test working again with modern papermill and scrapbook (c.f. https://github.com/scikit-hep/pyhf/pull/1841) I noticed that if I have Python filter warnings set to 'default', I can get a nbclient.exceptions.DeadKernelError from papermill if the notebook being executed has any IPython/Jupyter magics like shell evaluation with !.

Example from https://github.com/scikit-hep/pyhf/pull/1841:

    - name: Test example notebooks
      shell: bash
      run: |
        # Override the ini option for filterwarnings with an empty list to disable error
        # on filterwarnings as testing for notebooks to run with the latest API, not if
        # Jupyter infrastructure is warning free.
        # Though still show warnings by setting warning control to 'default'.
        export PYTHONWARNINGS='default'
        pytest --override-ini filterwarnings= tests/test_notebooks.py

Do you have any ideas why setting PYTHONWARNINGS='default' which will

print the first occurrence of matching warnings for each location (module + line number) where the warning is issued

would cause a nbclient.exceptions.DeadKernelError, which goes away if PYTHONWARNINGS is not set?

Log files

There is a log file for

$ PYTHONWARNINGS='default' pytest --override-ini filterwarnings= tests/test_notebooks.py -k test_xml_importexport &> /tmp/pythonwarnings_log.txt

at https://github.com/scikit-hep/pyhf/issues/1840#issuecomment-1089982787, which I can link here: https://github.com/scikit-hep/pyhf/files/8425002/pythonwarnings_log.txt

Related Issues and PRs

Contributor guide