Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AutoTest hits an exception if the kernel has no text/plain response #1886

Open
trevorcampbell opened this issue May 24, 2024 · 0 comments
Open

Comments

@trevorcampbell
Copy link
Contributor

When generating a notebook with autotest directives, cells that don't produce a text/plain output will cause AutoTest to crash with output:

      File "/opt/conda/lib/python3.11/site-packages/jupyter_client/client.py", line 551, in _async_execute_interactive
        output_hook(msg)
      File "/opt/conda/lib/python3.11/site-packages/nbgrader/preprocessors/instantiatetests.py", line 430, in _execute_code_snippet_output_hook
        self.execute_result = self.sanitizer(content["data"]["text/plain"])
                                             ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
    KeyError: 'text/plain'

The offending cell that was the source of the key error in my case just rendered an IRdisplay:

IRdisplay::display_html('<iframe width="560" height="315" src="https://www.youtube.com/[youtube video link]" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>')

The fix for this should be fairly easy. When the kernel returns a response, need to check that the content dict has a text/plain entry before trying to use it. If it doesn't, then there's nothing to handle and AutoTest should move on, unless it's specifically expecting a response in which case throw an exception with a more informative error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant