Skip to content

Allow init_notebook_mode to redefine/reinitialize plotly.js each time it's run #1452

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

Merged
merged 2 commits into from
Mar 6, 2019

Conversation

jonmmease
Copy link
Contributor

@jonmmease jonmmease commented Mar 6, 2019

Work towards addressing #1448

I don't think this addresses the root of the problem, but hopefully it will make it possible for users to call init_notebook_mode to reinitialize plotly.js in the notebook after the issue appears.

I haven't been able to reproduce the error message naturally, but after some research an experimenting it looks like what's happening is that for some reason the requirejs infrastructure is forgetting that a library called plotly has been defined (which happens in init_notebook_mode). I can force the same error by manually calling require.undef('plotly') in the JavaScript console and then running iplot again.

screenshot_20190305_185521

I don't have any leads at this point on what might be causing requirejs to "forget" about a registered module.

But this PR updates the init_nodebook_mode logic to take this possibility into account. Now, every time init_notebook_mode is called the 'plotly' module is explicitly undefined and redefined and the window._Plotly variable is reinitialized.

Now, when I invoke the error state by calling require.undef('plotly') I can at least recover from it by running init_notebook_mode() a second time. Before this PR we would get stuck in a state where the requirejs 'plotly' module was undefined but the window._Plotly variable was still set and so init_notebook_mode would skip redefining the 'plotly' module.

Checking !window._Plotly doesn't save any time and it prevents
init_notebook_mode from reinitializing plotly.js in the notebook
if things somehow got messed up
@jonmmease jonmmease merged commit df3ea19 into master Mar 6, 2019
@nicolaskruchten nicolaskruchten deleted the bug_1448 branch June 19, 2020 16:14
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

Successfully merging this pull request may close these issues.

1 participant