Skip to content

Use ipytree in .tree representation - #450

Merged
jrbourbeau merged 19 commits into
zarr-developers:masterfrom
jakirkham:use_ipytree
Jan 9, 2020
Merged

Use ipytree in .tree representation#450
jrbourbeau merged 19 commits into
zarr-developers:masterfrom
jakirkham:use_ipytree

Conversation

@jakirkham

@jakirkhamjakirkham commented Jul 4, 2019

Copy link
Copy Markdown
Member

Fixes#259

Reimplements the .tree representation in the Jupyter Notebook using ipytree, a Jupyter-widget wrapped jsTree implementation. This is similar to what we had before in that it still uses jsTree under-the-hood. However this is significantly easier for us to maintain and test. Not to mention it works seamlessly in both the legacy notebook and JupyterLab. This does require an extra installation step on the part of the user though. FWIW this was surprisingly quick to implement. 🙂

It would be good to reference how users should install ipytree. Also still needs a little work to get testing on CI going. That said, this could be handy for a slide or a blogpost while we iron these things out.

TODO:

  • Add unit tests and/or doctests in docstrings
  • Add docstrings and API docs for any new/modified user-facing classes and functions
  • New/modified features documented in docs/tutorial.rst
  • Changes documented in docs/release.rst
  • Docs build locally (e.g., run tox -e docs)
  • AppVeyor and Travis CI passes
  • Test coverage is 100% (Coveralls passes)

For users wishing to have a nice representation of groups in Jupyter
notebooks, `ipytree` is recommended to make these look a bit nicer as
well as enable interactivity. Though it is not a requirement as we can
always fallback to line representations. We make `ipytree` an optional
dependency as there is a little more work to install it depending on the
use case. So we want users to handle this intentionally.
@alimanfoo

Copy link
Copy Markdown
Member

This certainly cleans things up a lot! Very nice.

@jakirkham

Copy link
Copy Markdown
MemberAuthor

Yeah it's also much easier to test. We can inspect nodes and see how they relate to each other. Haven't dug into that, but it is definitely an option. 🙂

For testing purposes, make sure that `_ipython_display_` returns the
tree generated.
As we have replaced `_repr_html_` with `_display_ipython_`, drop tests
related to it.
Make sure that the `ipytree` extension is installed correctly in the
`tox` environment so the `.tree` representation can be tested.
These don't seem to work well with ipytree. So just drop them. Can
always add them back if we or upstream figure out how to make them work.
@jakirkham

Copy link
Copy Markdown
MemberAuthor

Have pushed the notebook with this change for comparison. Can see with nbviewer.

Different icons don't work as well. So just dropped those examples.

@alimanfoo

alimanfoo commented Jul 5, 2019 via email

Copy link
Copy Markdown
Member

@jakirkham

Copy link
Copy Markdown
MemberAuthor

Thanks for the feedback. This seems to be caused by selecting the icons in nbviewer. Doesn't happen in the actual Jupyter notebook.

As the point of our tree display is not to select nodes, disable this
feature. Hopefully works around a bug where icons disappear in nbviewer
upon selection.
Now with all nodes disabled to avoid selection. Hopefully avoids the bug
related to icons disappearing in nbviewer on selection.
@jakirkham

Copy link
Copy Markdown
MemberAuthor

Have pushed a change that disables all nodes so they cannot be selected. This seems to workaround the issue.

@jakirkham

Copy link
Copy Markdown
MemberAuthor

Here's an updated link.

@alimanfoo

alimanfoo commented Jul 5, 2019 via email

Copy link
Copy Markdown
Member

@jakirkham

Copy link
Copy Markdown
MemberAuthor

@alimanfoo, would you have a chance to do a code review?

@alimanfoo

Copy link
Copy Markdown
Member

Hi @jakirkham, code looks good to my eye, however looking at the example notebook I don't think the expand argument is working correctly, because the trees with expand=True, expand=1, expand=2 and expand=3 all look the same.

Fixes an issue where `expand` did not work correctly in subtrees.
Should show the use of `expand` correctly.
@jakirkham

Copy link
Copy Markdown
MemberAuthor

Good catch @alimanfoo! Sorry for the long delay. As with most bugs this was a simple thing 😉

Have rerun on the notebook. Results can be seen on nbviewer.

@jakirkhamjakirkham mentioned this pull request Jan 6, 2020
@jakirkham

Copy link
Copy Markdown
MemberAuthor

Not sure what is up with Coveralls. Tried messing with it last night and this morning, but it still doesn't seem to be working. Otherwise CI passes.

@jrbourbeaujrbourbeau left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The changes here looks good to me, thanks for refactoring @jakirkham! This seems a lot more maintainable now. Is there anything else you'd like to include, or is this good to merge?

@jakirkham

Copy link
Copy Markdown
MemberAuthor

Thanks for the review @jrbourbeau! Nothing more from me. Merge away 😀

@jrbourbeau
jrbourbeau merged commit a9bcafd into zarr-developers:masterJan 9, 2020
@jakirkham
jakirkham deleted the use_ipytree branch January 9, 2020 20:03
@CarreauCarreau added this to the v2.4 milestone Sep 9, 2020
Sign up for freeto 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.

HTML jstree doesn't work in jupyter lab

4 participants

@jakirkham@alimanfoo@jrbourbeau@Carreau