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

Add a JupyterLite-powered interactive shell for the pandas website (reprise of #47428) #60758

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

agriyakhetarpal
Copy link
Contributor

@agriyakhetarpal agriyakhetarpal commented Jan 22, 2025

This pull request aims to reinstate the machinery for adding a JupyterLite shell for the pandas website, based on discussions in #60747 and on Slack, please see them for a rationale on this change (short answer: it's been a while in 2025 and things might be smoother now).

An interactive shell was first discussed in #46682 and later removed in #49807. There was a request to reinstate this in #49807 (comment) which might not have been noticed, so I hope #60747 and this PR bring more visibility to the proposal.

In particular, this PR adds back the previous changes from #47428, with only minor differences in the configuration. I've used (and pinned) the jupyterlite-pyodide-kernel for the REPL, which in-turn provides Pyodide version 0.5.2, which comes with pandas version 2.2.3.

The differences in the changes from the previous PR are as follows:

  • newer versions of JupyterLite and jupyterlite-pyodide-kernel have been incorporated, i.e., 0.5.0 and 0.5.2 respectively
  • source maps have been disabled when building JuptyerLite, which should reduce the size of static assets significantly and allow for faster load times
  • the word "Experimental" has been added to the REPL's Markdown heading to indicate it as such

As mentioned in #60747, it is also possible to use the https://jupyterlite.github.io/demo/ REPL in the iframe to remove dependencies, however, it would come at the cost of disabled optimisations and a general lack of control for how the REPL is built.

cc: @jtpio, please feel free to add any suggestions!

@mroeschke mroeschke added the Web pandas website label Jan 22, 2025
@agriyakhetarpal
Copy link
Contributor Author

Well, looking at the website from the downloaded artifact, having it at 100% width definitely doesn't look great:

pandas website displayed from the documentation build artifact from the build from gh-60758. This image is that of the Getting Started section, where a heading 'Experimental, try pandas in your browser' is displayed, with an interactive shell to run pandas code in the browser. It occupies the entire width of the website area from the left margin to the right

and reducing the width to 50% would affect mobile devices and/or narrower screen sizes. I'll try to fix this by adding some inline CSS.

@agriyakhetarpal
Copy link
Contributor Author

I hope it looks better now:

pandas website displayed from the documentation build artifact from the build from gh-60758. This image is that of the Getting Started section, where a heading 'Experimental, try pandas in your browser' is displayed, with an interactive shell to run pandas code in the browser. It now occupies a smaller portion of the screen and stays true to its given width, with a maximum width of 650px. This retains the aspect ratio and makes the REPL look cleaner. There is also a dark blue border around the REPL, as it is

I also fixed a scaling issue for narrower screens for the YouTube video a few sections above this, which also affected how the REPL looked on mobile devices.

@rhshadrach
Copy link
Member

cc @datapythonista if you're interested in taking a look, I plan to review in the next few days.

Copy link
Member

@rhshadrach rhshadrach left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

You can try pandas in your browser with the following interactive shell
without needing to install anything on your system.

**Please note it can take a while before the shell is initialised and ready to run commands.**
Copy link
Member

Choose a reason for hiding this comment

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

Instead of a while can we give a estimate of how long.


**Running it requires a reasonable amount of bandwidth and resources, so it may not work properly on all devices or networks.**

<iframe
Copy link
Member

Choose a reason for hiding this comment

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

This will start loading on the Getting Started page, is that right? If so, I think we should perhaps move to its own page so that users don't have to spend the bandwidth.

# which in-turn comes with pandas 2.2.3:
# 1. https://jupyterlite-pyodide-kernel.readthedocs.io/en/stable/#compatibility
# 2. https://pyodide.org/en/stable/usage/packages-in-pyodide.html
# We constrain/pin here to avoid breaking changes on rebuilds.
Copy link
Member

Choose a reason for hiding this comment

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

We typically do not do this because hard pinning for some time and then doing a major upgrade is often harder than addressing each break as it comes in. Is there a reason we should take a different approach here?

Comment on lines +120 to +121
# Pyodide kernel version 0.5.2 comes with Pyodide 0.27.1
# which in-turn comes with pandas 2.2.3:
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what this comment is attempting to convey - is there a reason this is important? Also, not sure if it's relevant but what comes with pandas 2.2.3 doesn't seem important here; this is used for dev envs, not releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Web pandas website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC: Reinstate the JupyterLite-based live shell for the pandas website
4 participants