Skip to content

Add standalone application #2

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

Merged
merged 31 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
899a949
First scaffolding of a standalone application
fcollonval Oct 31, 2024
7343232
Fix adding support for yarn workspaces
fcollonval Oct 31, 2024
41863bc
Working build script
fcollonval Oct 31, 2024
7d5c7ff
Fix simple app with notebook viewer
fcollonval Oct 31, 2024
ab683ed
Use MercuryFactory for rendering notebook in app
fcollonval Nov 1, 2024
cd73399
Improve message if input file is missing or wrong
fcollonval Nov 1, 2024
545d7a3
Fix checking file exists
fcollonval Nov 1, 2024
0fc504b
Fix extensions required for loading ipywidgets and mercury plugins in…
fcollonval Nov 1, 2024
bf898fc
Prevent removing logo on clean
fcollonval Nov 3, 2024
62bfbe7
Render widget
fcollonval Nov 3, 2024
cb60711
Dependencies clean up
fcollonval Nov 3, 2024
d477b8b
Code clean up
fcollonval Nov 3, 2024
4b1d245
Defer loading @jupyterlab/console for ipywidgets
fcollonval Nov 4, 2024
c381e34
Load source map for all mercury extensions
fcollonval Nov 4, 2024
2fb0d69
Lint the code
fcollonval Nov 4, 2024
f187863
Format Python code with Ruff
fcollonval Nov 4, 2024
e820731
Add documentation
fcollonval Nov 4, 2024
c69e828
Homogenize the version
fcollonval Nov 4, 2024
ce67a34
Auto-execute cell below ipywidgets
fcollonval Nov 21, 2024
e330297
Play with mercury mimerenderer
fcollonval Dec 15, 2024
4e3909b
Allow to specify which widget should be a controller
fcollonval Dec 15, 2024
31de85b
Mercury mimetype is serialized JSON
fcollonval Dec 15, 2024
573b44f
Execute the notebook prior to first user render
fcollonval Dec 15, 2024
bb4a384
Better example
fcollonval Dec 15, 2024
3cbfcf1
Add syntax highlighting
fcollonval Dec 15, 2024
9bebef2
Clear the notebook
fcollonval Dec 15, 2024
55c42d7
Always emit `onCellExecuted`
fcollonval Dec 16, 2024
4879b48
Simplify placing item in the sidebar
fcollonval Dec 16, 2024
9bbaf65
Improve the spinner
fcollonval Dec 16, 2024
1048dfe
Use mercury cell executor to prevent flickering
fcollonval Dec 16, 2024
0684af1
Improve documentation
fcollonval Dec 16, 2024
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
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ node_modules/
*.egg-info/
.ipynb_checkpoints
*.tsbuildinfo
mercuryextension/labextension
mercury_app/labextension
# Version file is handled by hatchling
mercuryextension/_version.py
mercury_app/_version.py
mercury_app/schemas
mercury_app/static/*
!mercury_app/static/logo

# Integration tests
ui-tests/test-results/
Expand Down Expand Up @@ -122,4 +125,5 @@ dmypy.json
.DS_Store

# Yarn cache
.yarn/
.yarn/*
!.yarn/plugins
7 changes: 7 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
**/node_modules
**/lib
**/package.json
!/package.json
mercury_app
app/build
28 changes: 28 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
65 changes: 56 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
# mercuryextension
# mercury_app

[![Github Actions Status](https://github.com/mljar/mercury-extension/workflows/Build/badge.svg)](https://github.com/mljar/mercury-extension/actions/workflows/build.yml)

Run notebooks as web apps with Mercury inside JupyterLab.

## Requirements
This repository contains two parts:

- JupyterLab >= 4.0.0
- A standalone application to display a Jupyter notebook as Mercury dashboard on top of a Jupyter Server
- A JupyterLab extension to render a Jupyter notebook as Mercury dashboard; the extension is consumed by the application.

## Install

To install the extension, execute:

```bash
pip install mercuryextension
pip install mercury_app
```

## Usage

### Standalone application

You can open a notebook with the standalone application by executing:

```sh
python -m mercury_app <path/to/notebook.ipynb>
```

### JupyterLab extension

The new renderer should be available right away.

## Uninstall

To remove the extension, execute:

```bash
pip uninstall mercuryextension
pip uninstall mercury_app
```

## Contributing
Expand All @@ -35,7 +51,7 @@ The `jlpm` command is JupyterLab's pinned version of

```bash
# Clone the repo to your local environment
# Change directory to the mercuryextension directory
# Change directory to the mercury_app directory
# Install package in development mode
pip install -e "."
# Link your development version of the extension with JupyterLab
Expand All @@ -44,11 +60,42 @@ jupyter labextension develop . --overwrite
jlpm build
```

### Code structure

- `app` folder: `mercury-app` NPM package containing the webpack configuration and start-up scripts for the standalone application
- `packages/application` folder: `mercury-application` NPM package defining the specific element for the standalone application front-end.
- `packages/lab` folder: `@mljar/mercury-extension` NPM package defining the JupyterLab extension.

> [!NOTE]
> The repository uses yarn _workspaces_ to handle multiple packages within a single repository. It requires a yarn
> plugin that is installed by default in this repository (in `.yarn/plugins` folder). In case you need to
> update it or install it again, you should refer to the [Yarn documentation](https://yarnpkg.com/cli/plugin/import).

### Watch mode

#### Standalone application

You can watch the source directory of the stand alone application by running in two different terminals the following commands:

```sh
# Watch the application source and automatically rebuilding it when needed
jlpm watch:app
# Run the standalone app in another terminal
python -m mercury_app example.ipynb
```

> [!NOTE]
> Be sure to disable the cache on your web browser and to refresh
> the standalone application web page each time you update the
> code.

#### JupyterLab extension

You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.

```bash
# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm watch
jlpm watch:lib
# Run JupyterLab in another terminal
jupyter lab
```
Expand All @@ -64,12 +111,12 @@ jupyter lab build --minimize=False
### Development uninstall

```bash
pip uninstall mercuryextension
pip uninstall mercury_app
```

In development mode, you will also need to remove the symlink created by `jupyter labextension develop`
command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions`
folder is located. Then you can remove the symlink named `@mljar/mercuryextension` within that folder.
folder is located. Then you can remove the symlink named `@mljar/mercury-extension` within that folder.

### Testing the extension

Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ Develop web apps from Python notebooks with Mercury directly in JupyterLab.
To install the extension, execute:

```bash
pip install mercuryextension
pip install mercury_app
```

## Uninstall

To remove the extension, execute:

```bash
pip uninstall mercuryextension
pip uninstall mercury_app
```

2 changes: 1 addition & 1 deletion RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Making a new release of mercuryextension
# Making a new release of mercury_app

The extension can be published to `PyPI` and `npm` manually or using the [Jupyter Releaser](https://github.com/jupyter-server/jupyter_releaser).

Expand Down
Loading