Skip to content

Commit 89e4de9

Browse files
Enable Python API in the JupyterLite deployment (#412)
* Don't change paths to absolute backend paths * Enable jupytergis_lab in WASM platform * Make the model collaborative in JupyterLite * Deploy JupyterLite with collaborative drive * Review * Pin python=3.12 Co-authored-by: martinRenou <[email protected]> * Pin micromamba v2.0.5 * Install myst-parser from conda * Fix typo * Fix paths * Show error message in the front-end when there is no collaborative drive * Linter * Handle file operations in the front-end * Up * Update yjs widgets * Remove unwanted test * Cleanup * Remove Github pages build * Show console as early as possible * More docs building removal * Unpin my-jupyter-shared-drive --------- Co-authored-by: martinRenou <[email protected]>
1 parent aa2ef32 commit 89e4de9

File tree

17 files changed

+92
-187
lines changed

17 files changed

+92
-187
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -250,74 +250,3 @@ jobs:
250250
- uses: jupyterlab/maintainer-tools/.github/actions/check-links@v1
251251
with:
252252
ignore_links: 'lite/'
253-
254-
build-docs-and-lite:
255-
name: Build docs with JupyterLite deployment
256-
needs: build
257-
runs-on: ubuntu-latest
258-
259-
steps:
260-
- name: Checkout
261-
uses: actions/checkout@v4
262-
263-
- name: Install Conda environment with Micromamba
264-
uses: mamba-org/setup-micromamba@v2
265-
with:
266-
micromamba-version: '1.5.5-0'
267-
environment-name: build-env
268-
create-args: >-
269-
python=3.10
270-
pip
271-
jupyterlite-core>=0.4.0,<0.6.0
272-
jupyterlite-xeus>=2,<3
273-
jupyterlite-sphinx
274-
sphinx
275-
sphinx-tabs
276-
pydata-sphinx-theme
277-
sphinx-autodoc-typehints
278-
sphinx-exercise
279-
sphinx-togglebutton
280-
myst-parser<4.0.0
281-
282-
- name: Download extension package
283-
uses: actions/download-artifact@v4
284-
with:
285-
name: extension-artifacts
286-
287-
- name: Install the extension
288-
shell: bash -l {0}
289-
run: |
290-
set -eux
291-
cp ./jupytergis_core/dist/jupytergis*.whl ./jupytergis_lab/dist/jupytergis*.whl ./jupytergis_qgis/dist/jupytergis*.whl .
292-
python -m pip install jupytergis*.whl
293-
294-
- name: Build the docs site
295-
shell: bash -l {0}
296-
working-directory: docs
297-
run: |
298-
set -eux
299-
sphinx-build . dist
300-
301-
- name: Upload artifact
302-
id: upload-docs-artifact
303-
uses: actions/upload-pages-artifact@v3
304-
with:
305-
path: ./docs/dist
306-
retention-days: 30
307-
308-
deploy:
309-
needs: build-docs-and-lite
310-
if: github.ref == 'refs/heads/main'
311-
permissions:
312-
pages: write
313-
id-token: write
314-
315-
environment:
316-
name: github-pages
317-
url: ${{ steps.deployment.outputs.page_url }}
318-
319-
runs-on: ubuntu-latest
320-
steps:
321-
- name: Deploy to GitHub Pages
322-
id: deployment
323-
uses: actions/deploy-pages@v4

.readthedocs.yaml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ build:
2020
# Override the create_environment step (undocumented feature) to create
2121
# multiple environments.
2222
create_environment:
23+
# Pin micromamba
24+
- /bin/bash --login -c "micromamba self-update --version 2.0.5"
2325
# Create the env for building the docs
2426
- /bin/bash --login -c "micromamba env create -n jupytergis-docs -f docs/environment-docs.yml"
2527
# Create the isolated env for building JupyterGIS
26-
- /bin/bash --login -c "micromamba create -n jupytergis-build -c conda-forge yarn=3 hatch pip python=3.12"
27-
- /bin/bash --login -c "micromamba run -n jupytergis-build pip install -r requirements-build.txt"
28+
- /bin/bash --login -c "micromamba create -n jupytergis-build -c conda-forge nodejs hatch pip python=3.13"
29+
- /bin/bash --login -c "micromamba run -n jupytergis-build pip install 'jupyterlab==4.3' 'datamodel-code-generator>=0.23.0'"
2830

2931
# Override the install step to do nothing - we already created the envs
3032
install:
@@ -33,18 +35,8 @@ build:
3335
# Before building the docs, build JupyterGIS in its isolated environment,
3436
# then install the wheels into the docs environment.
3537
pre_build:
36-
- /bin/bash --login -c "micromamba run -n jupytergis-build yarn install"
37-
- /bin/bash --login -c "micromamba run -n jupytergis-build yarn dev"
38-
- /bin/bash --login -c "micromamba run -n jupytergis-build jupyter labextension list 2>&1 | grep -ie 'jupytergis-core.*OK'"
39-
- /bin/bash --login -c "micromamba run -n jupytergis-build jupyter labextension list 2>&1 | grep -ie 'jupytergis-lab.*OK'"
40-
- /bin/bash --login -c "micromamba run -n jupytergis-build yarn build:packages"
41-
42-
- |-
43-
/bin/bash --login -c "micromamba run -n jupytergis-docs \
44-
python -m pip install \
45-
$(ls ./python/jupytergis_core/dist/jupytergis*.whl) \
46-
$(ls ./python/jupytergis_lab/dist/jupytergis*.whl) \
47-
$(ls ./python/jupytergis_qgis/dist/jupytergis*.whl)"
38+
- /bin/bash --login -c "micromamba run -n jupytergis-build jlpm install"
39+
- /bin/bash --login -c "micromamba run -n jupytergis-build jlpm build"
4840

4941
build:
5042
html:

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
[![lite-badge]][lite] [![docs-badge]][docs]
55

66
[lite-badge]: https://jupyterlite.rtfd.io/en/latest/_static/badge.svg
7-
[lite]: https://geojupyter.github.io/jupytergis/lite/lab/index.html?path=france_hiking.jGIS/
7+
[lite]: https://jupytergis.readthedocs.io/en/latest/lite/lab/index.html?path=france_hiking.jGIS/
88
[docs-badge]: https://readthedocs.org/projects/jupytergis/badge/?version=latest
9-
[docs]: https://geojupyter.github.io/jupytergis
9+
[docs]: https://jupytergis.readthedocs.io
1010

1111
⚠️ This extension is work in progress. Features and APIs are subject to change quickly. ⚠️
1212

@@ -18,7 +18,7 @@
1818
- **QGIS File Support**: Load, visualize, and manipulate QGIS project files (`.qgs`, `.qgz`), and other GIS data formats.
1919
- **Interactive Maps**: Render interactive maps and geospatial visualizations within Jupyter notebooks using the JupyterGIS Python API.
2020

21-
## [🪄 Try JupyterGIS now! ✨](https://geojupyter.github.io/jupytergis/lite/lab/index.html?path=france_hiking.jGIS)
21+
## [🪄 Try JupyterGIS now! ✨](https://jupytergis.readthedocs.io/en/latest/lite/lab/index.html?path=france_hiking.jGIS)
2222

2323
This demo runs a JupyterLab instance entirely in your browser with WebAssembly! 🤯
2424

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"../examples/*.gif",
4141
"../examples/*.geojson",
4242
"../examples/*.tif",
43+
"../examples/*.ipynb",
4344
]
4445
jupyterlite_dir = "."
4546
jupyterlite_config = "jupyter_lite_config.json"

docs/environment-docs.yml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@ dependencies:
77
- pip # Needed to install jupytergis wheels in RTD build
88

99
# Build docs & JupyterLite
10-
- jupyterlite-core>=0.4.0,<0.6.0
11-
- jupyterlite-xeus>=2,<3
10+
- jupyterlite-core
11+
- jupyterlite-xeus>=3.1.3,<4
1212
- jupyterlite-sphinx
1313
- sphinx
1414
- sphinx-tabs
1515
- pydata-sphinx-theme
1616
- sphinx-autodoc-typehints
1717
- sphinx-exercise
1818
- sphinx-togglebutton
19-
19+
- myst-parser
2020
- xeus-python # TODO: Do we need this?
21-
22-
# Install myst-parser via pip
23-
- pip:
24-
- myst-parser<4.0.0

docs/environment.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
name: xeus-python-kernel
22
channels:
3-
- https://repo.mamba.pm/emscripten-forge
3+
- https://prefix.dev/emscripten-forge-dev
44
- conda-forge
55
dependencies:
6+
- python=3.13
7+
- pip
68
- xeus-python
9+
- requests
10+
- jupyter_ydoc=2.1.5
11+
- ypywidgets>=0.9.6,<0.10.0
12+
- comm>=0.1.2,<0.2.0
13+
- pydantic>=2,<3
14+
- pip:
15+
- yjs-widgets>=0.4,<0.5
16+
- my-jupyter-shared-drive
17+
- ../python/jupytergis_lab
18+
- ../python/jupytergis_core

docs/jupyter-lite.json

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11
{
22
"jupyter-lite-schema-version": 0,
3-
"jupyter-config-data": {
4-
"appName": "JupyterGIS App",
5-
"disabledExtensions": [
6-
"@jupyter/collaboration-extension",
7-
"@jupyter/docprovider-extension"
8-
]
9-
}
3+
"jupyter-config-data": {}
104
}

packages/base/src/widget.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,12 @@ export class JupyterGISPanel extends SplitPanel {
197197

198198
(this._consoleTracker.widgetAdded as any).emit(consolePanel);
199199
await consolePanel.sessionContext.ready;
200-
await consolePanel.console.inject(
201-
`from jupytergis_lab import GISDocument\ndoc = GISDocument("${jgisPath}")`
202-
);
203200
this.addWidget(this._consoleView);
204201
this.setRelativeSizes([2, 1]);
205202
this._consoleOpened = true;
203+
await consolePanel.console.inject(
204+
`from jupytergis_lab import GISDocument\ndoc = GISDocument("${jgisPath}")`
205+
);
206206
consolePanel.console.sessionContext.kernelChanged.connect((_, arg) => {
207207
if (!arg.newValue) {
208208
this.removeConsole();

python/jupytergis_core/src/jgisplugin/modelfactory.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ export class JupyterGISModelFactory
1818
/**
1919
* Whether the model is collaborative or not.
2020
*/
21-
readonly collaborative =
22-
document.querySelectorAll('[data-jupyter-lite-root]')[0] === undefined;
21+
readonly collaborative = true;
2322

2423
/**
2524
* The name of the model.

python/jupytergis_lab/jupytergis_lab/__init__.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@
88

99
__version__ = "dev"
1010

11-
import sys
12-
13-
if sys.platform == "emscripten":
14-
raise ImportError(
15-
"Cannot use the JupyterGIS Python API in a JupyterLite kernel yet"
16-
)
17-
1811
from .notebook import GISDocument # noqa
1912

2013

0 commit comments

Comments
 (0)