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 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c7e2f2a
Add back initial changes from gh-47428
agriyakhetarpal Jan 22, 2025
f8c94e6
Add requirements and compatibility notes
agriyakhetarpal Jan 22, 2025
2e2da17
Disable source maps for a smaller build
agriyakhetarpal Jan 22, 2025
c3a8092
Note Pyodide kernel installation in README
agriyakhetarpal Jan 22, 2025
c1bd25f
Add terminal back, with "Experimental" heading
agriyakhetarpal Jan 22, 2025
9c9023d
Fix minimum pin for `jupyterlite-core`
agriyakhetarpal Jan 22, 2025
a1d1886
Add note about disabling of source maps
agriyakhetarpal Jan 22, 2025
3ce9723
Use `working-directory:` instead of `cd`
agriyakhetarpal Jan 22, 2025
4d56cea
Properly generate dev requirements file
agriyakhetarpal Jan 22, 2025
63a075d
Disable REPL code auto-execution
agriyakhetarpal Jan 22, 2025
b7d27da
Display DataFrame with starter code, fix encoding
agriyakhetarpal Jan 22, 2025
0ceedca
Add note about bandwidth usage, embolden
agriyakhetarpal Jan 22, 2025
9674bfc
Fix pre-commit failure
agriyakhetarpal Jan 22, 2025
c9b3d61
Reword "Try pandas" title and message
agriyakhetarpal Jan 22, 2025
02d7ae3
Don't set a fixed width, autoscale, add border
agriyakhetarpal Jan 22, 2025
54470b7
Fix broken auto-scaling for YouTube video
agriyakhetarpal Jan 22, 2025
27aac16
Fix another pre-commit failure
agriyakhetarpal Jan 22, 2025
59f3e16
Don't disable `jupyterlab-manager` widget
agriyakhetarpal Jan 22, 2025
582deb0
Mention time taken to initialise shell
agriyakhetarpal Feb 13, 2025
391ce1e
Unpin jupyterlite-pyodide-kernel and JupyterLite
agriyakhetarpal Feb 13, 2025
96eb3db
Merge branch 'main' into feat/add-back-jupyterlite-repl
agriyakhetarpal Feb 13, 2025
9470bf4
Suggestions from Jeremy
agriyakhetarpal Feb 14, 2025
75aeb9e
Merge branch 'main' into feat/add-back-jupyterlite-repl
agriyakhetarpal Feb 20, 2025
2a8acae
Mention approximate amount of bandwidth consumed
agriyakhetarpal Feb 20, 2025
3d9e65c
Move the shell to `try.html`
agriyakhetarpal Feb 21, 2025
186ddbb
Re-enable "Try pandas online" button, move it down
agriyakhetarpal Feb 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/docbuild-and-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ jobs:
- name: Build documentation
run: doc/make.py --warnings-are-errors

- name: Build the interactive terminal
working-directory: web/interactive_terminal
run: jupyter lite build

- name: Build documentation zip
run: doc/make.py zip_html

Expand Down
7 changes: 7 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ dependencies:
- requests
- pygments # Code highlighting

# web interactive REPL
# see the following links for more context:
# 1. https://jupyterlite-pyodide-kernel.readthedocs.io/en/stable/#compatibility
# 2. https://pyodide.org/en/stable/usage/packages-in-pyodide.html
- jupyterlite-core
- jupyterlite-pyodide-kernel

- pip:
- adbc-driver-postgresql>=0.10.0
- adbc-driver-sqlite>=0.8.0
Expand Down
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ feedparser
pyyaml
requests
pygments
jupyterlite-core
jupyterlite-pyodide-kernel
adbc-driver-postgresql>=0.10.0
adbc-driver-sqlite>=0.8.0
typing_extensions; python_version<"3.11"
Expand Down
38 changes: 38 additions & 0 deletions web/interactive_terminal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# The interactive `pandas` REPL

An interactive REPL to easily try `pandas` in the browser, powered by JupyterLite.

![image](https://user-images.githubusercontent.com/591645/175000291-e8c69f6f-5f2c-48d7-817c-cff05ab2cde9.png)

## Build

The interactive REPL is built with the `jupyter lite` CLI.

First make sure `jupyterlite` and a kernel are installed:

```bash
python -m pip install jupyterlite-core
python -m pip install jupyterlite-pyodide-kernel
```

Then in `web/interactive_terminal`, run the following command:

```bash
jupyter lite build
```

## Configuration

This folder contains configuration files for the interactive terminal powered by JupyterLite:

- `jupyter_lite_config.json`: build time configuration, used when building the assets with the `jupyter lite build` command
- `jupyter-lite.json` run time configuration applied when launching the application in the browser

This interactive `pandas` JupyterLite deployment enables a couple of optimizations to only include the `repl` app in the generated static assets, and disables source maps, which can make the assets smaller and faster to load, at the cost of
debugging capabilities.

To learn more about it, check out the JupyterLite documentation:

- Optimizations: https://jupyterlite.readthedocs.io/en/latest/howto/configure/advanced/optimizations.html
- JupyterLite schema: https://jupyterlite.readthedocs.io/en/latest/reference/schema-v0.html
- CLI reference: https://jupyterlite.readthedocs.io/en/latest/reference/cli.html
10 changes: 10 additions & 0 deletions web/interactive_terminal/jupyter-lite.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"jupyter-lite-schema-version": 0,
"jupyter-config-data": {
"appName": "Pandas REPL",
"appUrl": "./repl",
"enableMemoryStorage": true,
"settingsStorageDrivers": ["memoryStorageDriver"],
"contentsStorageDrivers": ["memoryStorageDriver"]
}
}
8 changes: 8 additions & 0 deletions web/interactive_terminal/jupyter_lite_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"LiteBuildConfig": {
"apps": ["repl"],
"no_unused_shared_packages": true,
"output_dir": "../build/lite",
"no_sourcemaps": true
}
}
20 changes: 16 additions & 4 deletions web/pandas/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,23 @@ by [Wes McKinney](https://wesmckinney.com/), creator of pandas.

## Videos

<iframe width="560" height="315" frameborder="0"
src="https://www.youtube.com/embed/_T8LGqJtuGc"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen></iframe>
<iframe
src="https://www.youtube.com/embed/_T8LGqJtuGc"
style="width: 100%; max-width: 560px; height: 315px;"
frameborder="0"
allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen
></iframe>

## Cheat sheet

[pandas cheat sheet](https://pandas.pydata.org/Pandas_Cheat_Sheet.pdf)

## Try pandas in your browser (experimental)

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

<p>
<a class="btn btn-primary" href="{{ base_url }}try.html">Try it in your browser</a>
</p>
2 changes: 1 addition & 1 deletion web/pandas/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ <h1>pandas</h1>
<div class="col-md-4">
<h5>Getting started</h5>
<ul>
<!-- <li><a href="{{ base_url }}/try.html">Try pandas online</a></li> -->
<li><a href="{{ base_url }}getting_started.html">Install pandas</a></li>
<li><a href="{{ base_url }}docs/getting_started/index.html">Getting started</a></li>
<li><a href="{{ base_url }}try.html">Try pandas online</a></li>
</ul>
</div>
<div class="col-md-4">
Expand Down
12 changes: 12 additions & 0 deletions web/pandas/try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Try pandas in your browser (experimental)

Try our experimental [JupyterLite](https://jupyterlite.readthedocs.io/en/stable/) live shell with `pandas`, powered by [Pyodide](https://pyodide.org/en/stable/).

**Please note it can take a while (>30 seconds) before the shell is initialized and ready to run commands.**

**Running it requires a reasonable amount of bandwidth and resources (>70 MiB on the first load), so it may not work properly on all devices or networks.**

<iframe
src="./lite/repl/index.html?toolbar=1&kernel=python&execute=0&code=import%20pandas%20as%20pd%0Adf%20%3D%20pd.DataFrame%28%7B%22num_legs%22%3A%20%5B2%2C%204%5D%2C%20%22num_wings%22%3A%20%5B2%2C%200%5D%7D%2C%20index%3D%5B%22falcon%22%2C%20%22dog%22%5D%29%0Adf"
style="width: 100%; max-width: 650px; height: 600px; border: 1px solid #130753;"
></iframe>
Loading