Skip to content

Commit a6bb86e

Browse files
committed
WASM
1 parent cfbf4c5 commit a6bb86e

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

.github/workflows/test_widget.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ jobs:
3232
run: uv run jupyter nbconvert --to=html --execute docs/notebooks/widget_from_dict.ipynb
3333
- name: Export Marimo notebook to HTML
3434
run: uv run marimo export html docs/notebooks/marimo.py -o docs/notebooks/marimo.html
35+
- name: Export Marimo notebook to HTML-WASM
36+
run: uv run marimo export html-wasm docs/notebooks/marimo-wasm.py -o docs/notebooks/marimo-wasm.html --mode edit
3537
- name: Check that widget renders in HTML output using Playwright
3638
run: pnpm exec playwright test
3739
working-directory: ./tests-widget

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ tests/data/*
1111
!tests/data/test.ome.tif
1212
./notebooks/
1313
docs/notebooks/data/
14+
docs/notebooks/*.html
1415
__pycache__/
1516
.snakemake/
1617
.coverage

docs/notebooks/marimo-wasm.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
import marimo
2+
3+
__generated_with = "0.13.15"
4+
app = marimo.App()
5+
6+
7+
@app.cell
8+
def _():
9+
import marimo as mo
10+
return (mo,)
11+
12+
13+
@app.cell
14+
def _():
15+
import anywidget
16+
from vitessce import (
17+
VitessceConfig,
18+
ViewType as vt,
19+
CoordinationType as ct,
20+
ImageOmeTiffWrapper,
21+
ImageOmeZarrWrapper,
22+
AnnDataWrapper,
23+
SpatialDataWrapper,
24+
CoordinationLevel as CL,
25+
get_initial_coordination_scope_prefix,
26+
hconcat,
27+
vconcat,
28+
)
29+
return VitessceConfig, ImageOmeTiffWrapper, get_initial_coordination_scope_prefix
30+
31+
32+
@app.cell
33+
def _(VitessceConfig, ImageOmeTiffWrapper, get_initial_coordination_scope_prefix):
34+
vc = VitessceConfig(
35+
schema_version="1.0.17",
36+
name='My configuration',
37+
description='Data from https://portal.hubmapconsortium.org/browse/collection/6a6efd0c1a2681dc7d2faab8e4ab0bca'
38+
)
39+
dataset = vc.add_dataset(name='My dataset').add_object(
40+
ImageOmeTiffWrapper(
41+
img_url="https://assets.hubmapconsortium.org/f4188a148e4c759092d19369d310883b/ometiff-pyramids/processedMicroscopy/VAN0006-LK-2-85-PAS_images/VAN0006-LK-2-85-PAS_registered.ome.tif"
42+
)
43+
)
44+
45+
spatial = vc.add_view("spatialBeta", dataset=dataset)
46+
lc = vc.add_view("layerControllerBeta", dataset=dataset)
47+
48+
vc.link_views_by_dict([spatial, lc], {
49+
"photometricInterpretation": "RGB"
50+
}, meta=True, scope_prefix=get_initial_coordination_scope_prefix("A", "image"))
51+
52+
vc.layout(spatial | lc);
53+
return (vc,)
54+
55+
56+
@app.cell
57+
def _(mo, vc):
58+
vw = mo.ui.anywidget(vc.widget())
59+
vw
60+
return (vw,)
61+
62+
63+
@app.cell(hide_code=True)
64+
def _(mo):
65+
mo.md(r"""As you interact with the widget above, watch as the Vitessce configuration below dynamically updates. For instance, as you zoom in the spatial view, check the value of `coordinationSpace.spatialZoom`""")
66+
return
67+
68+
69+
@app.cell
70+
def _(vw):
71+
vw.config
72+
return
73+
74+
75+
@app.cell
76+
def _(vw):
77+
vw.config["coordinationSpace"]["spatialZoom"]
78+
return
79+
80+
@app.cell
81+
def _(vc):
82+
import json
83+
print(json.dumps(vc.to_dict(), indent=2))
84+
return
85+
86+
@app.cell
87+
def _():
88+
return
89+
90+
91+
if __name__ == "__main__":
92+
app.run()

0 commit comments

Comments
 (0)