Skip to content

Table.show_in_notebook doesn't work in jupyter lab 3 and up #15566

Closed

Description

@mwcraig

Description

When I run show_in_notebook() on a table I get a full plain text listing of the table, not a paginated one.

Expected behavior

Paginated table

How to Reproduce

  1. GEt astropy 5.3.x
  2. Then run the code below
  3. No pagination occurs. There is an error in the javascript browser console, included below the code snippet.
from astropy.table import Table
t = Table()
t['name'] = ['larry', 'curly', 'moe', 'shemp']
t['flux'] = [1.2, 2.2, 3.1, 4.3]
t.show_in_notebook(display_length=2)

javascript console

VM157:15 Uncaught ReferenceError: require is not defined
    at <anonymous>:15:1
    at t.attachWidget (jlab_core.6144df8e3fe03e33f880.js?v=6144df8e3fe03e33f880:2:1594563)
    at t.insertWidget (jlab_core.6144df8e3fe03e33f880.js?v=6144df8e3fe03e33f880:2:1593914)
    at j._insertOutput (jlab_core.6144df8e3fe03e33f880.js?v=6144df8e3fe03e33f880:2:925250)
    at j.onModelChanged (jlab_core.6144df8e3fe03e33f880.js?v=6144df8e3fe03e33f880:2:922427)
    at m (jlab_core.6144df8e3fe03e33f880.js?v=6144df8e3fe03e33f880:2:1560565)
    at Object.l [as emit] (jlab_core.6144df8e3fe03e33f880.js?v=6144df8e3fe03e33f880:2:1560225)
    at e.emit (jlab_core.6144df8e3fe03e33f880.js?v=6144df8e3fe03e33f880:2:1558470)
    at c._onListChanged (jlab_core.6144df8e3fe03e33f880.js?v=6144df8e3fe03e33f880:2:918850)
    at m (jlab_core.6144df8e3fe03e33f880.js?v=6144df8e3fe03e33f880:2:1560565)

Versions

macOS-13.5.2-arm64-arm-64bit
Python 3.10.13 | packaged by conda-forge | (main, Oct 26 2023, 18:09:17) [Clang 16.0.6 ]
astropy 5.3.4
Numpy 1.26.0
pyerfa 2.0.1.1
Scipy 1.11.3
Matplotlib 3.8.0

Activity

  1. changed the title [-]Table.show_in_notebook doesn't work in jupuyter lab 3 and up[/-] [+]Table.show_in_notebook doesn't work in jupyter lab 3 and up[/+] on Nov 1, 2023
  2. pllim commented on Nov 1, 2023

    @pllim
    Member

    What are the versions of your Jupyter stack? Also did you try with 6.0.dev? Thanks!

  3. saimn commented on Nov 2, 2023

    @saimn
    Contributor

    I think recent versions of jupyter notebook are based on jupyter lab, which doesn't use requirejs to load JavaScript libraries...

  4. rag-hav commented on Dec 4, 2023

    @rag-hav

    Unable to reproduce with 6.0.0 dev

  5. taldcroft commented on Dec 7, 2023

    @taldcroft
    Member

    I can reproduce this on Mac using astropy main 6.1.dev151+g7ab3296cb3 and jupyter lab 3.5.2. However, using VS code notebook the show_in_notebook() method works as expected.

  6. taldcroft commented on Dec 7, 2023

    @taldcroft
    Member

    Triage:

    • priority-medium

    This affects user experience in a particular environment but does not cause a crash or incorrect code results. Users can typically examine the table in a different way if need be.

  7. neutrinoceros commented on Dec 13, 2023

    @neutrinoceros
    Contributor

    I couldn't reproduce this so far. I've tried:

    • macOS + Python 3.12.0 + Jupyterlab 4.0.9 + astropy 6.1.dev203+gc80869eac2
    • macOS + Python 3.9.18 + Jupyterlab 3.6.6 + astropy 6.1.dev203+gc80869eac2
    • macOS + Python 3.9.18 + Jupyterlab 3.5.3 + astropy 6.1.dev203+gc80869eac2
    • macOS + Python 3.9.18 + Jupyterlab 3.5.3 + astropy 6.1.dev151+g7ab3296cb3 (supposedly this is very close to last time Tom checked and reproduced)

    I got the correct behaviour every time. I don't have a clear idea what could be the relevant differences left.
    @taldcroft, can you share a little bit more details ?
    I'm on macOS 14.2 (running on an M2 arch), and used Safari 17.2 .

  8. saimn commented on Dec 13, 2023

    @saimn
    Contributor

    I got the correct behaviour every time.

    @neutrinoceros - hmm do you get a clickable/searchable table ? you can try t.show_in_browser(jsviewer=True) which gives an interactive table in a new HTML page, show_in_notebook should give the same in the notebook.
    And I get the same js error as above (require is not defined), because as I said jupyterlab doesn't use requirejs.

  9. neutrinoceros commented on Dec 14, 2023

    @neutrinoceros
    Contributor

    hmm do you get a clickable/searchable table ?

    @saimn 🤦🏻‍♂️ ... I didn't get that was the problem. In fact I don't get pagination in any of the envs I reported yesterday !

    you can try t.show_in_browser(jsviewer=True) which gives an interactive table in a new HTML page

    Excellent, thank you !

    And I get the same js error as above (require is not defined), because as I said jupyterlab doesn't use requirejs.

    same here. To be exact the error I see in my setup is ReferenceError: Can't find variable: require but this seems to be the exact same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions