Skip to content

Add notebook extension for automatically adding imports to first cell #16

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

valtron
Copy link

@valtron valtron commented Aug 24, 2019

I made a notebook extension that automatically adds lazy imports to the top cell as they're imported:

anim

How to use it:

  1. Install pyforest from this branch: pip install git+https://github.com/valtron/pyforest.git@nbextension
  2. jupyter nbextension install --py pyforest
  3. jupyter nbextension enable pyforest --py
  4. Run jupyter notebook and import some stuff

The implementation is hacky (this is my first notebook extension and documentation is lacking) but this is a proof-of-concept anyway.

@FlorianWetschoreck
Copy link
Collaborator

Wow, first of all, thank you for your contribution! It looks really nice and is a great improvement of pyforest!

Does the notebook extension also work for JupyterLab? Or what would be necessary to also make it work in Jupyter Lab?
It would be great to have support for both Jupyter Notebook and Jupyter Lab.

@valtron
Copy link
Author

valtron commented Aug 24, 2019

Glad you like it!

I added a labextension. But I'm still trying to figure out a convenient way for users to install it. (I've been using jupyter labextension install . from inside the project dir.)

@valtron
Copy link
Author

valtron commented Aug 25, 2019

Done, and added installation instructions to the README.

@valtron
Copy link
Author

valtron commented Sep 5, 2019

It's now using an "invisible" widget instead of the window.update_imports_cell hack. There's still a few major things I need to do:

  • setup.py is from the widget cookiecutter, but it doesn't handle building the nbextension during install
  • the widget isn't invisible in ipython
  • delimit imports on both sides

@henryiii
Copy link

What's the status of this? Looks very useful in the demo, at least. :)

@valtron
Copy link
Author

valtron commented Oct 23, 2019

@henryiii All the major parts are finished; I never did figure out how to not show the widget in IPython, though:

Clipboard03

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.

3 participants