From c7e2f2a8e0d90f97f3e8d7f01e0a9f822e8213fa Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 22 Jan 2025 16:52:00 +0530 Subject: [PATCH 01/21] Add back initial changes from gh-47428 Co-Authored-By: Jeremy Tuloup --- .github/workflows/docbuild-and-upload.yml | 5 +++ web/interactive_terminal/README.md | 36 +++++++++++++++++++ web/interactive_terminal/jupyter-lite.json | 11 ++++++ .../jupyter_lite_config.json | 7 ++++ 4 files changed, 59 insertions(+) create mode 100644 web/interactive_terminal/README.md create mode 100644 web/interactive_terminal/jupyter-lite.json create mode 100644 web/interactive_terminal/jupyter_lite_config.json diff --git a/.github/workflows/docbuild-and-upload.yml b/.github/workflows/docbuild-and-upload.yml index 908baa87815ab..2f40889c36d6f 100644 --- a/.github/workflows/docbuild-and-upload.yml +++ b/.github/workflows/docbuild-and-upload.yml @@ -59,6 +59,11 @@ jobs: - name: Build documentation run: doc/make.py --warnings-are-errors + - name: Build the interactive terminal + run: | + cd web/interactive_terminal + jupyter lite build + - name: Build documentation zip run: doc/make.py zip_html diff --git a/web/interactive_terminal/README.md b/web/interactive_terminal/README.md new file mode 100644 index 0000000000000..71b3d2d456c91 --- /dev/null +++ b/web/interactive_terminal/README.md @@ -0,0 +1,36 @@ +# 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 +``` + +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 + +The interactive `pandas` terminal application enables a couple of optimizations to only include the `repl` app in the generated static assets. + +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 diff --git a/web/interactive_terminal/jupyter-lite.json b/web/interactive_terminal/jupyter-lite.json new file mode 100644 index 0000000000000..53f6d53ad436a --- /dev/null +++ b/web/interactive_terminal/jupyter-lite.json @@ -0,0 +1,11 @@ +{ + "jupyter-lite-schema-version": 0, + "jupyter-config-data": { + "appName": "Pandas REPL", + "appUrl": "./repl", + "disabledExtensions": ["@jupyter-widgets/jupyterlab-manager"], + "enableMemoryStorage": true, + "settingsStorageDrivers": ["memoryStorageDriver"], + "contentsStorageDrivers": ["memoryStorageDriver"] + } +} diff --git a/web/interactive_terminal/jupyter_lite_config.json b/web/interactive_terminal/jupyter_lite_config.json new file mode 100644 index 0000000000000..55e066b5d4ecf --- /dev/null +++ b/web/interactive_terminal/jupyter_lite_config.json @@ -0,0 +1,7 @@ +{ + "LiteBuildConfig": { + "apps": ["repl"], + "no_unused_shared_packages": true, + "output_dir": "../build/lite" + } +} From f8c94e6e6ecc399ef07f402c6bcd3b2595c07ccb Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 22 Jan 2025 16:53:49 +0530 Subject: [PATCH 02/21] Add requirements and compatibility notes --- environment.yml | 9 +++++++++ requirements-dev.txt | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/environment.yml b/environment.yml index 69647a436e3ad..20aae85db83bd 100644 --- a/environment.yml +++ b/environment.yml @@ -116,6 +116,15 @@ dependencies: - requests - pygments # Code highlighting + # web interactive REPL + # Pyodide kernel version 0.5.2 comes with Pyodide 0.27.1 + # 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. + - jupyterlite-core>0.5.0,<0.6.0 + - jupyterlite-pyodide-kernel==0.5.2 + - pip: - adbc-driver-postgresql>=0.10.0 - adbc-driver-sqlite>=0.8.0 diff --git a/requirements-dev.txt b/requirements-dev.txt index fb4d9cdb589ca..380acdd2b8a58 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -84,6 +84,11 @@ markdown feedparser pyyaml requests + +# keep in sync with environment.yml +jupyterlite-core>0.5.0,<0.6,0 +jupyterlite-pyodide-kernel==0.5.2 + pygments adbc-driver-postgresql>=0.10.0 adbc-driver-sqlite>=0.8.0 From 2e2da171391238ae9cb89ad2a37ae58877116412 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 22 Jan 2025 16:54:01 +0530 Subject: [PATCH 03/21] Disable source maps for a smaller build --- web/interactive_terminal/jupyter_lite_config.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/interactive_terminal/jupyter_lite_config.json b/web/interactive_terminal/jupyter_lite_config.json index 55e066b5d4ecf..42e64f26f2356 100644 --- a/web/interactive_terminal/jupyter_lite_config.json +++ b/web/interactive_terminal/jupyter_lite_config.json @@ -2,6 +2,7 @@ "LiteBuildConfig": { "apps": ["repl"], "no_unused_shared_packages": true, - "output_dir": "../build/lite" + "output_dir": "../build/lite", + "no_sourcemaps": true } } From c3a80927ead69b4b4a1187adf5d9334d4f421f82 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 22 Jan 2025 16:54:21 +0530 Subject: [PATCH 04/21] Note Pyodide kernel installation in README --- web/interactive_terminal/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/web/interactive_terminal/README.md b/web/interactive_terminal/README.md index 71b3d2d456c91..62bf2a25e683d 100644 --- a/web/interactive_terminal/README.md +++ b/web/interactive_terminal/README.md @@ -12,6 +12,7 @@ First make sure `jupyterlite` and a kernel are installed: ```bash python -m pip install jupyterlite +python -m pip install jupyterlite-pyodide-kernel ``` Then in `web/interactive_terminal`, run the following command: From c1bd25f4b67f45d72216b92f36c6a4bb6430181b Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 22 Jan 2025 16:54:38 +0530 Subject: [PATCH 05/21] Add terminal back, with "Experimental" heading Co-Authored-By: Jeremy Tuloup --- web/pandas/getting_started.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/web/pandas/getting_started.md b/web/pandas/getting_started.md index 801081a9ef391..1f3b6855f9f63 100644 --- a/web/pandas/getting_started.md +++ b/web/pandas/getting_started.md @@ -30,3 +30,17 @@ allowfullscreen> ## Cheat sheet [pandas cheat sheet](https://pandas.pydata.org/Pandas_Cheat_Sheet.pdf) + +## (Experimental): try `pandas` in your browser + +You can try `pandas` in your browser with the following interactive shell +without needing to install anything on your computer. + +*Please note it can take a while before the shell is initialised and ready to run commands.* + + + From 9c9023df19b40e231d708322ab8c08710ebe2b0c Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 22 Jan 2025 19:07:31 +0530 Subject: [PATCH 06/21] Fix minimum pin for `jupyterlite-core` --- environment.yml | 2 +- requirements-dev.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/environment.yml b/environment.yml index 20aae85db83bd..89b56d8e70069 100644 --- a/environment.yml +++ b/environment.yml @@ -122,7 +122,7 @@ dependencies: # 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. - - jupyterlite-core>0.5.0,<0.6.0 + - jupyterlite-core>=0.5.0,<0.6.0 - jupyterlite-pyodide-kernel==0.5.2 - pip: diff --git a/requirements-dev.txt b/requirements-dev.txt index 380acdd2b8a58..edfabcccaafbc 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -86,7 +86,7 @@ pyyaml requests # keep in sync with environment.yml -jupyterlite-core>0.5.0,<0.6,0 +jupyterlite-core>=0.5.0,<0.6,0 jupyterlite-pyodide-kernel==0.5.2 pygments From a1d18860136c5f728d27dd3539fffd7687fcb96b Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 22 Jan 2025 19:40:23 +0530 Subject: [PATCH 07/21] Add note about disabling of source maps --- web/interactive_terminal/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/interactive_terminal/README.md b/web/interactive_terminal/README.md index 62bf2a25e683d..8e4ede7573d59 100644 --- a/web/interactive_terminal/README.md +++ b/web/interactive_terminal/README.md @@ -28,7 +28,8 @@ This folder contains configuration files for the interactive terminal powered by - `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 -The interactive `pandas` terminal application enables a couple of optimizations to only include the `repl` app in the generated static assets. +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: From 3ce9723c35fdc663e3bf58d9e36ee98885c0aae1 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 22 Jan 2025 19:50:36 +0530 Subject: [PATCH 08/21] Use `working-directory:` instead of `cd` --- .github/workflows/docbuild-and-upload.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docbuild-and-upload.yml b/.github/workflows/docbuild-and-upload.yml index 2f40889c36d6f..294334ca1d54b 100644 --- a/.github/workflows/docbuild-and-upload.yml +++ b/.github/workflows/docbuild-and-upload.yml @@ -60,9 +60,8 @@ jobs: run: doc/make.py --warnings-are-errors - name: Build the interactive terminal - run: | - cd web/interactive_terminal - jupyter lite build + working-directory: web/interactive_terminal + run: jupyter lite build - name: Build documentation zip run: doc/make.py zip_html From 4d56ceac6526bb70fda7d7631aa8bc802a29db40 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 22 Jan 2025 19:57:16 +0530 Subject: [PATCH 09/21] Properly generate dev requirements file --- environment.yml | 2 +- requirements-dev.txt | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/environment.yml b/environment.yml index 89b56d8e70069..1cdca186fd211 100644 --- a/environment.yml +++ b/environment.yml @@ -123,7 +123,7 @@ dependencies: # 2. https://pyodide.org/en/stable/usage/packages-in-pyodide.html # We constrain/pin here to avoid breaking changes on rebuilds. - jupyterlite-core>=0.5.0,<0.6.0 - - jupyterlite-pyodide-kernel==0.5.2 + - jupyterlite-pyodide-kernel=0.5.2 - pip: - adbc-driver-postgresql>=0.10.0 diff --git a/requirements-dev.txt b/requirements-dev.txt index edfabcccaafbc..a5756eb6cbcc8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -84,12 +84,9 @@ markdown feedparser pyyaml requests - -# keep in sync with environment.yml -jupyterlite-core>=0.5.0,<0.6,0 -jupyterlite-pyodide-kernel==0.5.2 - pygments +jupyterlite-core>=0.5.0,<0.6.0 +jupyterlite-pyodide-kernel==0.5.2 adbc-driver-postgresql>=0.10.0 adbc-driver-sqlite>=0.8.0 typing_extensions; python_version<"3.11" From 63a075d74e2fae9c502ca741f5a1b86e4de93fd9 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 22 Jan 2025 19:58:01 +0530 Subject: [PATCH 10/21] Disable REPL code auto-execution --- web/pandas/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/pandas/getting_started.md b/web/pandas/getting_started.md index 1f3b6855f9f63..8a02628dbdcd2 100644 --- a/web/pandas/getting_started.md +++ b/web/pandas/getting_started.md @@ -39,7 +39,7 @@ without needing to install anything on your computer. *Please note it can take a while before the shell is initialised and ready to run commands.* From b7d27da9f10c91993fd634f1a236197e81b39051 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 22 Jan 2025 20:03:34 +0530 Subject: [PATCH 11/21] Display DataFrame with starter code, fix encoding --- web/pandas/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/pandas/getting_started.md b/web/pandas/getting_started.md index 8a02628dbdcd2..ef09bc9ccccc2 100644 --- a/web/pandas/getting_started.md +++ b/web/pandas/getting_started.md @@ -39,7 +39,7 @@ without needing to install anything on your computer. *Please note it can take a while before the shell is initialised and ready to run commands.* From 0ceedca75cb6deff2017dc1aaaa08bb2c9e7dfb7 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Wed, 22 Jan 2025 20:05:54 +0530 Subject: [PATCH 12/21] Add note about bandwidth usage, embolden --- web/pandas/getting_started.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web/pandas/getting_started.md b/web/pandas/getting_started.md index ef09bc9ccccc2..926d3d1dc716c 100644 --- a/web/pandas/getting_started.md +++ b/web/pandas/getting_started.md @@ -36,7 +36,8 @@ allowfullscreen> You can try `pandas` in your browser with the following interactive shell without needing to install anything on your computer. -*Please note it can take a while before the shell is initialised and ready to run commands.* +**Please note it can take a while before the shell is initialised and ready to run commands.** +**Running it requires a reasonable amount of bandwidth and resources, so it may not work properly on all devices or networks.** - From c9b3d61e6a745bdfc8ae911af79ce2b2fe892f19 Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 23 Jan 2025 01:08:16 +0530 Subject: [PATCH 14/21] Reword "Try pandas" title and message --- web/pandas/getting_started.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/web/pandas/getting_started.md b/web/pandas/getting_started.md index 1122f25cb856d..f9d63c7a924d2 100644 --- a/web/pandas/getting_started.md +++ b/web/pandas/getting_started.md @@ -31,12 +31,13 @@ allowfullscreen> [pandas cheat sheet](https://pandas.pydata.org/Pandas_Cheat_Sheet.pdf) -## (Experimental): try `pandas` in your browser +## 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 computer. +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.** + **Running it requires a reasonable amount of bandwidth and resources, so it may not work properly on all devices or networks.** From 54470b72bfff9d31fe127030d4fc0ae2fdacaecf Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 23 Jan 2025 01:11:22 +0530 Subject: [PATCH 16/21] Fix broken auto-scaling for YouTube video --- web/pandas/getting_started.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/web/pandas/getting_started.md b/web/pandas/getting_started.md index 506d5ca044ba0..c687d5f3a3ed4 100644 --- a/web/pandas/getting_started.md +++ b/web/pandas/getting_started.md @@ -22,10 +22,13 @@ by [Wes McKinney](https://wesmckinney.com/), creator of pandas. ## Videos - + ## Cheat sheet From 27aac16ebfb7d3a95423b93d9bdfa3063bd72b2f Mon Sep 17 00:00:00 2001 From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com> Date: Thu, 23 Jan 2025 01:36:49 +0530 Subject: [PATCH 17/21] Fix another pre-commit failure --- web/pandas/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/pandas/getting_started.md b/web/pandas/getting_started.md index c687d5f3a3ed4..75c76e38151b7 100644 --- a/web/pandas/getting_started.md +++ b/web/pandas/getting_started.md @@ -22,7 +22,7 @@ by [Wes McKinney](https://wesmckinney.com/), creator of pandas. ## Videos -