Skip to content

Commit 2c947e0

Browse files
authored
DOC: Add an interactive shell powered by JupyterLite to the website (pandas-dev#47428)
* Add an interactive shell powered by JupyterLite * Update to the dedicated JupyterLite deployment * Add example code * Move build files to the pandas repo * Build the jupyterlite website * Load relative terminal * Update example code * Update wording * Fix trailing spaces * Move build dependencies to the top-level environment.yml * Move to `web/interactive_terminal` * Remove example code * Add note about the loading time * Update instructions in the README * Update build command on CI * Fix typo in .gitignore * Lint environment.yml * Remove unused import * Undo unrelated changes in environment.yml * Fix pre-commit check * Remove unused csv file
1 parent 771f2b1 commit 2c947e0

8 files changed

+84
-0
lines changed

.github/workflows/docbuild-and-upload.yml

+5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ jobs:
4646
- name: Build documentation
4747
run: doc/make.py --warnings-are-errors
4848

49+
- name: Build the interactive terminal
50+
run: |
51+
cd web/interactive_terminal
52+
jupyter lite build
53+
4954
- name: Install ssh key
5055
run: |
5156
mkdir -m 700 -p ~/.ssh

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,7 @@ doc/build/html/index.html
122122
doc/tmp.sv
123123
env/
124124
doc/source/savefig/
125+
126+
# Interactive terminal generated files #
127+
########################################
128+
.jupyterlite.doit.db

environment.yml

+5
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,8 @@ dependencies:
123123
- feedparser
124124
- pyyaml
125125
- requests
126+
127+
# build the interactive terminal
128+
- jupyterlab >=3.4,<4
129+
- pip:
130+
- jupyterlite==0.1.0b9

requirements-dev.txt

+2
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,6 @@ markdown
9696
feedparser
9797
pyyaml
9898
requests
99+
jupyterlab >=3.4,<4
100+
jupyterlite==0.1.0b9
99101
setuptools>=51.0.0

web/interactive_terminal/README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# The interactive `pandas` terminal
2+
3+
An interactive terminal to easily try `pandas` in the browser, powered by JupyterLite.
4+
5+
![image](https://user-images.githubusercontent.com/591645/175000291-e8c69f6f-5f2c-48d7-817c-cff05ab2cde9.png)
6+
7+
## Build
8+
9+
The interactive terminal is built with the `jupyterlite` CLI.
10+
11+
First make sure `jupyterlite` is installed:
12+
13+
```bash
14+
python -m pip install jupyterlite
15+
```
16+
17+
Then in `web/interactive_terminal`, run the following command:
18+
19+
```bash
20+
jupyter lite build
21+
```
22+
23+
## Configuration
24+
25+
This folder contains configuration files for the interactive terminal powered by JupyterLite:
26+
27+
- `jupyter_lite_config.json`: build time configuration, used when building the assets with the `jupyter lite build` command
28+
- `jupyter-lite.json` run time configuration applied when launching the application in the browser
29+
30+
The interactive `pandas` terminal application enables a couple of optimizations to only include the `repl` app in the generated static assets.
31+
To learn more about it, check out the JupyterLite documentation:
32+
33+
- Optimizations: https://jupyterlite.readthedocs.io/en/latest/howto/configure/advanced/optimizations.html
34+
- JupyterLite schema: https://jupyterlite.readthedocs.io/en/latest/reference/schema-v0.html
35+
- CLI reference: https://jupyterlite.readthedocs.io/en/latest/reference/cli.html
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"jupyter-lite-schema-version": 0,
3+
"jupyter-config-data": {
4+
"appName": "Pandas REPL",
5+
"appUrl": "./repl",
6+
"disabledExtensions": [
7+
"@jupyter-widgets/jupyterlab-manager"
8+
],
9+
"enableMemoryStorage": true,
10+
"settingsStorageDrivers": ["memoryStorageDriver"],
11+
"contentsStorageDrivers": ["memoryStorageDriver"]
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"LiteBuildConfig": {
3+
"apps": ["repl"],
4+
"no_unused_shared_packages": true,
5+
"output_dir": "../build/lite"
6+
}
7+
}

web/pandas/getting_started.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Getting started
22

3+
## Try it in your browser
4+
5+
You can try `pandas` in your browser with the following interactive shell
6+
without installing anything on your computer.
7+
8+
*Note it can take up to 30 seconds before the shell finishes loading and is ready to run commands.*
9+
10+
<iframe
11+
src="./lite/repl/index.html?toolbar=1&kernel=python&code=import%20pandas%20as%20pd&code=df%20=%20pd.DataFrame(%7B'num_legs':%20%5B2,%204%5D,%20'num_wings':%20%5B2,%200%5D%7D,%20index=%5B'falcon',%20'dog'%5D)"
12+
width="100%"
13+
height="500px"
14+
></iframe>
15+
316
## Installation instructions
417

518
The next steps provides the easiest and recommended way to set up your

0 commit comments

Comments
 (0)