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

PR: Use JupyterLab to render notebooks #264

Merged
merged 17 commits into from
May 13, 2020

Conversation

jitseniesen
Copy link
Member

@jitseniesen jitseniesen commented Mar 27, 2020

This is far from ready; I just want to show my progress.

This PR updates the plugin to use the JupyterLab framework instead of the classic notebook interface, because JupyterLab is the future.

To do list:

  • Allow for different notebook names instead of assuming it's called test.ipynb
  • Add the buttons for Save, Insert Cell, Cut, Copy, etc.
  • Fix saving of notebook when user closes it
  • Don't ask user to select kernel when opening a new notebook
  • Remove sidebar? Add menubar? deferred to issue Replace sidebar by menubar in new notebook server #270
  • Make sure unit tests pass
  • Update CI script
  • Write contribution info

Fixes #261

@jitseniesen jitseniesen self-assigned this Mar 27, 2020
@pep8speaks
Copy link

pep8speaks commented Mar 27, 2020

Hello @jitseniesen! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-04-29 10:04:13 UTC

@jitseniesen
Copy link
Member Author

This is just a proof of concept to show off a screen shot:
Screenshot_20200327_160014
This makes me more confident that I can make it work!

@goanpeca
Copy link
Member

Amazing work @jitseniesen !!! Keep it up :-)

@ccordoba12
Copy link
Member

Pretty nice!! I just have one question: is this going to create one server instance per notebook?

@jitseniesen
Copy link
Member Author

Pretty nice!! I just have one question: is this going to create one server instance per notebook?

I am planning to use the same approach as currently at the start, which is one server instance per directory. However, I want to look at whether it is possible to have only one server instance which can render all notebooks regardless of where they are stored. Unless you think it's preferable to have one server instance per notebook.

@ccordoba12
Copy link
Member

I am planning to use the same approach as currently at the start, which is one server instance per directory

The current approach is really one server per user home directory. So if you want to open a notebook in /tmp, you need a new server. I decided to do that to not expose the entire filesystem to the server.

However, I want to look at whether it is possible to have only one server instance which can render all notebooks regardless of where they are stored

That probably won't work on Windows, in case users want to load notebooks from C:\, D:\, etc.

@jitseniesen
Copy link
Member Author

Ok, I won't change that in this PR, let's try to stick to one server per home dir.

@jitseniesen
Copy link
Member Author

Most things seem to work:

spyder-notebook-2020-03-31_13 58 58

@ccordoba12
Copy link
Member

Most things seem to work:

That looks pretty neat!! Thanks @jitseniesen for working on this!

But what about the connection with the IPython console? Is that working?

@jitseniesen
Copy link
Member Author

But what about the connection with the IPython console? Is that working?

I tried it out and the old code still seems to work, which is a big relief. You can open a console, access the variables from the notebook in the console and in the variable explorer, and changes made in the console are reflected in the notebook. Let me know if I need to test anything else.

@codecov-io
Copy link

codecov-io commented Apr 2, 2020

Codecov Report

Merging #264 into master will decrease coverage by 0.05%.
The diff coverage is 100.00%.

Impacted Files Coverage Δ
spyder_notebook/notebookplugin.py 72.38% <100.00%> (+0.17%) ⬆️
spyder_notebook/utils/nbopen.py 80.70% <100.00%> (+0.34%) ⬆️
spyder_notebook/widgets/client.py 72.84% <100.00%> (-0.41%) ⬇️
spyder_notebook/widgets/dom.py 73.68% <100.00%> (-2.51%) ⬇️

@ccordoba12
Copy link
Member

@jitseniesen, you can remove support for Python 2 in version 0.3, if you want.

@jitseniesen jitseniesen force-pushed the jupyterlab branch 2 times, most recently from 96665d4 to cdcac3c Compare April 3, 2020 09:38
Comment on lines +216 to +217
NB: I am not sure whether the save is performed before the function
returns.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably not true because almost all JS operations are asynchronous.

@jitseniesen
Copy link
Member Author

I want to get rid of the side bar on the left with the commands and replace it with a menu bar, accessing the same commands (and more). However, I am thinking to leave that to another PR.

Apart from that, I need to write some documentation while things are still fairly fresh in my mind, and then I think this is ready.

@ccordoba12
Copy link
Member

I want to get rid of the side bar on the left with the commands and replace it with a menu bar, accessing the same commands (and more). However, I am thinking to leave that to another PR.

I'm fine with that.

For a future PR you should also consider to add some extra JupyterLab extensions. For instance, the ones necessary to display Bokeh or Plotly plots.

At the moment, there is no way to specify the file name of the notebook,
it is assumed to be "test.ipynb"
Fix taken from jupyterlab/jupyerlab#218397d1
Update the CSS selector for the save button. Moreover, the save is now
done on mousedown, not on click.
Specify kernelspec, so that user is not asked for it.
The new notebook server under JupyterLab does not include a header
anymore which needs to be hidden, so this function is no longer
needed.
MathJax is not used and the URL is no longer active, generating
a warning.
The prompt has a slightly different format in JupyterLab.
The instructions are more complicated now that the plugin includes a notebook
server written in TypeScript.
@jitseniesen jitseniesen marked this pull request as ready for review April 29, 2020 10:14
@jitseniesen jitseniesen changed the title [WIP] PR: Use JupyterLab to render notebooks PR: Use JupyterLab to render notebooks Apr 29, 2020
@jitseniesen jitseniesen merged commit 024de76 into spyder-ide:master May 13, 2020
@jitseniesen jitseniesen deleted the jupyterlab branch May 13, 2020 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Transition to JupyterLab
5 participants