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

Cookiecutter based tutorial #2731

Closed
jtpio opened this issue Jan 13, 2020 · 19 comments · Fixed by #2919
Closed

Cookiecutter based tutorial #2731

jtpio opened this issue Jan 13, 2020 · 19 comments · Fixed by #2919
Labels

Comments

@jtpio
Copy link
Member

jtpio commented Jan 13, 2020

The previous "Custom Widget" has now been removed from the documentation (see #2677), as it was using patterns specific to the classic notebook.

As mentioned in this comment, we could instead have a tutorial based on the TypeScript tutorial, similar to the Let’s Make an Astronomy Picture of the Day JupyterLab Extension.

@jtpio jtpio added the docs label Jan 13, 2020
@jtpio
Copy link
Member Author

jtpio commented Jul 9, 2020

cc @ianhi who has been taking some notes on the making of custom widgets: https://github.com/ianhi/custom-ipywidget-howto

Maybe we can incorporate some of these notes in the cookiecutter base tutorial?

Also cc @martinRenou who has been updating the Jupyter Widgets tutorial lately: https://github.com/jupyter-widgets/tutorial

(although the Jupyter Widgets tutorial probably doesn't cover the creation of custom widgets?)

@jtpio
Copy link
Member Author

jtpio commented Jul 9, 2020

For reference this is what the current custom widget tutorial looks like (to create widgets in the classic notebook directly):

image

@martinRenou
Copy link
Member

cc @ianhi who has been taking some notes on the making of custom widgets: https://github.com/ianhi/custom-ipywidget-howto
Maybe we can incorporate some of these notes in the cookiecutter base tutorial?

That's a 👍x9999 for me

Also cc @martinRenou who has been updating the Jupyter Widgets tutorial lately: https://github.com/jupyter-widgets/tutorial
(although the Jupyter Widgets tutorial probably doesn't cover the creation of custom widgets?)

Indeed, we simply mention it and give links to the cookiecutters.

@ianhi
Copy link
Contributor

ianhi commented Jul 9, 2020

@jtpio related to this I think fixing images in low level widget docs would be helpful: #2908

Maybe we can incorporate some of these notes in the cookiecutter base tutorial?

👍 I've had mild ambitions of adding small examples to that - but making those for a cookiecutter tutorial sounds better. It sounds as though you're imagining a single large narrative style tutorial? Something else to consider (perhaps in addition) is having many small (standalone) examples that demonstrate specific things. For example I felt that by focusing only on messages in https://github.com/ianhi/widget_message_speed I learned a lot about messages. Small examples like that that deal with messages, serialization etc in isolation could also be helpful.

@jtpio
Copy link
Member Author

jtpio commented Jul 9, 2020

It sounds as though you're imagining a single large narrative style tutorial?

Yes the idea was to replace the one that we removed in a previous PR :)

https://ipywidgets.readthedocs.io/en/stable/examples/Widget%20Custom.html

Something else to consider (perhaps in addition) is having many small (standalone) examples that demonstrate specific things

That sounds like a good idea 👍

Maybe there could be something similar to the JupyterLab extension examples, but focused on custom widgets instead?

https://github.com/jupyterlab/extension-examples

@ianhi
Copy link
Contributor

ianhi commented Jul 9, 2020

Maybe there could be something similar to the JupyterLab extension examples, but focused on custom widgets instead?

That would be awesome. I have multiple times ended up at the widgets-tutorial thinking that it would be just that.

Indeed, we simply mention it and give links to the cookiecutters.

I don't think there's actually a link to the cookiecutter in the readme - might be nice to add that.

Another related thing is that on this page: https://jupyter.org/widgets only the js cookiecutter is linked, probs good to also link the ts cookiecutter

@ianhi
Copy link
Contributor

ianhi commented Jul 9, 2020

In addition to a tutorial I think have an official listing of all the methods availiable to both the model and view objects in both typescript and python would be fantastic. I started this in this md file: https://github.com/ianhi/custom-ipywidget-howto/blob/master/available-methods.md but I'm pretty sure that I haven't gotten all of the methods.

@jtpio
Copy link
Member Author

jtpio commented Jul 13, 2020

Another related thing is that on this page: https://jupyter.org/widgets only the js cookiecutter is linked, probs good to also link the ts cookiecutter

Good catch 👍

We would need to modify this page to link to the TS cookiecutter: https://github.com/jupyter/jupyter.github.io/blob/master/widgets.html

edit: opened jupyter/jupyter.github.io#373

In addition to a tutorial I think have an official listing of all the methods availiable to both the model and view objects in both typescript and python would be fantastic

Those could probably be automatically be generated? (api docs / typedoc)

@ianhi
Copy link
Contributor

ianhi commented Jul 13, 2020

Those could probably be automatically be generated? (api docs / typedoc)

Would this require the widget docstring comments to be formatted the same way as the backbonejs?

For reference this is what the current custom widget tutorial looks like (to create widgets in the classic notebook directly):

How did you take such a long screenshot????

@jtpio
Copy link
Member Author

jtpio commented Jul 13, 2020

Would this require the widget docstring comments to be formatted the same way as the backbonejs?

Not sure about the backbonejs methods yet. Maybe there is a way to reuse the same tooling as in JupyterLab to output API docs like this: https://jupyterlab.github.io/jupyterlab/modules/_coreutils_src_index_.html

How did you take such a long screenshot????

Using Firefox built-in screenshot tool. It's really useful especially for PRs that update the documentation.

image

@jtpio
Copy link
Member Author

jtpio commented Jul 13, 2020

Opened #2919 to start updating the tutorial.

Feedback welcome!

@ianhi
Copy link
Contributor

ianhi commented Jul 16, 2020

Those could probably be automatically be generated? (api docs / typedoc)

I took an existing project and ran typedoc on it to. So model1 and one or two of the methods are from me and not from widgets. Not everything has an explanation but this is way better than nothing. So here is my own very long screenshot of the docs:
image

It's not clear to me where these docs ought to live (and also how to get them to wherever that is). This is maybe a separate concern but I think that the ipywidgets the library of buttons and sliders and the tools for building custom jupyter widgets maybe deserve separate documentation websites? Although it would great to even have docs like the above on the ipywidgets rtd.

@jtpio
Copy link
Member Author

jtpio commented Sep 14, 2020

Not everything has an explanation but this is way better than nothing

Thanks @ianhi for the screenshot, It looks like it could indeed already be helpful 👍

@elliothershberg
Copy link

Just wanted to say as a prospective widget developer, having a basic tutorial would be a huge help. I've been able to get the example JS cookie cutter widget working (ran into issues with the TS cookiecutter tests not working, could open an issue in that repo if it would be helpful), but haven't been able to get much farther so far.

I was actually just getting ready to start the custom widget tutorial, and came here after I saw it was removed on latest.

Tangentially, I'm working to use a React component in the frontend, and working off of some discussion here: #2207

Is there any interest in what @jasongrout mentioned about have a cookiecutter or tutorial for using React in ipywidgets?

@elliothershberg
Copy link

One other question: is it no longer possible in Jupyter Lab to do this kind of JS execution in a notebook? (from removed tutorial)

image

It'd be awesome to be able to prototype a widget entirely in a notebook.

@ianhi
Copy link
Contributor

ianhi commented Dec 13, 2020

@elliothershberg I feel your pain. I figured things out primarily by looking at existing widgets. In particular I'd recommend looking at ipycanvas, the notes i've collected https://github.com/ianhi/custom-ipywidget-howto, and the jupyter-widgets gitter https://gitter.im/jupyter-widgets/Lobby

Also, per #2908, you should read the notebook source of the low level tutorial https://github.com/jupyter-widgets/ipywidgets/blob/master/docs/source/examples/Widget%20Low%20Level.ipynb

ran into issues with the TS cookiecutter tests not working, could open an issue in that repo if it would be helpful)

The tests have at various times broken but it should still generated working widgets. One other thing to maybe be aware of is that given that jlab3 is around the corner it may be worth your while to work off the jlab3 branch of the cookiecutter.

Tangentially, I'm working to use a React component in the frontend, and working off of some discussion here: #2207

See also ianhi/custom-ipywidget-howto#10

One other question: is it no longer possible in Jupyter Lab to do this kind of JS execution in a notebook? (from removed tutorial)

I don't think that this is possible in jupyterlab. If you want the python side of your widget to be automatically reloaded every time you run a method then you can use autoreload

like so:

%load_ext autoreload
%autoreload 2

import my_widget

@jtpio
Copy link
Member Author

jtpio commented Dec 14, 2020

One other question: is it no longer possible in Jupyter Lab to do this kind of JS execution in a notebook? (from removed tutorial)

No, but the new prebuilt (federated) extension system in JupyterLab 3.0 should hopefully improve the workflow on that level (no need to rebuild JupyterLab entirely, just the widget).

@elliothershberg
Copy link

@ianhi Nice, thanks for taking the time to compile those resources, and link them here. That definitely gives me a bit to go on.

@jtpio Got it. I'm looking forward to seeing the new extension system! Thanks.

@MicaelJarniac
Copy link
Contributor

The files deleted on #2677 resulted in some broken links (#3061). Once there's an alternative, I believe those links should be updated.

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 a pull request may close this issue.

5 participants