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

Widget with plotly figure stalls otter assign #842

Open
bdsomer opened this issue Sep 26, 2024 · 1 comment
Open

Widget with plotly figure stalls otter assign #842

bdsomer opened this issue Sep 26, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@bdsomer
Copy link
Contributor

bdsomer commented Sep 26, 2024

Describe the bug
Any cell in a notebook that has a plotly.graph_objs.Figure in an ipywidgets.interacting causes otter assign to never finish running. For example, this cell stalls otter assign:

import ipywidgets
import plotly

slider = ipywidgets.FloatSlider()
def on_slider_change(val):
    fig = plotly.graph_objs.Figure()
    plotly.offline.iplot(fig)

display(ipywidgets.interactive(on_slider_change, val = slider))

To Reproduce
Steps to reproduce the behavior:
Run otter assign on the following notebook:

{
 "cells": [
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "# BEGIN QUESTION\n",
    "name: q1"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "# BEGIN SOLUTION"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "q1 = 1 # SOLUTION"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "# END SOLUTION"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "# BEGIN TESTS"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "assert q1 == 1"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "# END TESTS"
   ]
  },
  {
   "cell_type": "raw",
   "metadata": {},
   "source": [
    "# END QUESTION"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import ipywidgets\n",
    "import plotly\n",
    "\n",
    "slider = ipywidgets.FloatSlider()\n",
    "def on_slider_change(val):\n",
    "    fig = plotly.graph_objs.Figure()\n",
    "    plotly.offline.iplot(fig)\n",
    "\n",
    "display(ipywidgets.interactive(on_slider_change, val = slider))"
   ]
  }
 ],
 "metadata": {
  "@webio": {
   "lastCommId": null,
   "lastKernelId": null
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}

Expected behavior
otter assign completes normally (like it does without the problematic cell in the example)

Versions
Python version: 3.12.2
Otter-Grader version: 5.6.0

Additional context
Otter version 5.0.0 is the first version in which this bug exists. The line of code on which otter assign stalls appears to be

executed_nb, _ = ep.preprocess(nb)

Based on this, this issue may actually be an issue with nbconvert.

@bdsomer bdsomer added the bug Something isn't working label Sep 26, 2024
@chrispyles
Copy link
Member

This sounds similar to #755. Can you try that fix and see if it works?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants