Warning
This repository contains mostly untested LLM-generated code. It was created as a proof-of-concept for running the datalab Python API in the browser and should not be considered production-ready. Use at your own risk and please contribute improvements if you find issues.
Some experients with some LLM-generated code for running the datalab-api
package in the browser directly (without the notebook interface in front of it).
The aim is to demonstrate how to use the datalab-api
Python package directly in the browser using WebAssembly through Pyodide.
This approach eliminates the need for users to install Python or any dependencies locally.
This repository will be used to test the feasibility of running the datalab-api
package in the browser using Pyodide.
-
Clone this repository:
git clone https://github.com/datalab-org/datalab-api-wasm-plugin.git cd datalab-api-wasm-plugin
-
Install dependencies:
yarn install
-
Start the development server:
yarn start
-
Open your browser to
http://localhost:8080
-
Build the Docker image:
yarn docker:build
-
Run the container:
yarn docker:run
-
Open your browser to
http://localhost:8080
The project includes automated tests that verify Pyodide initialization and package functionality:
yarn test
This runs a series of tests using Playwright:
- Loading the application page
- Initializing Pyodide
- Importing the
datalab-api
package - Running a basic example
-
Pyodide Initialization:
- Loads the Pyodide JavaScript library
- Sets up a Python runtime in the browser
- Installs core dependencies (numpy, pandas, matplotlib)
-
Package Installation:
- Attempts to install the
datalab-api
package using micropip - Falls back to a demo mode if installation fails
- Attempts to install the
-
Code Execution:
- Executes Python code directly in the browser
- Captures output and errors
- Displays visualizations in the UI
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.