Skip to content

Commit a700de0

Browse files
committed
Merge branch 'main' of github.com:vitessce/vitessce-python into keller-mark/kpmp
2 parents 6ace98a + 2542d0a commit a700de0

File tree

7 files changed

+120
-31
lines changed

7 files changed

+120
-31
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()

pyproject.toml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "vitessce"
7-
version = "3.6.1"
7+
version = "3.6.2"
88
authors = [
99
{ name="Mark Keller", email="[email protected]" },
1010
]
@@ -26,20 +26,11 @@ classifiers = [
2626
]
2727
dependencies = [
2828
'scipy>=1.2.1',
29-
'negspy>=0.2.24',
3029
'pandas>=1.1.2',
3130
'black>=21.11b1',
3231
'numpy>=1.21.2',
3332
'zarr>=2.5.0,<3',
3433
'numcodecs>=0.5.7,<0.16.0',
35-
'anndata>=0.7.8',
36-
# scanpy < 1.10.3 does not support numpy >= 2.0.0 and does not
37-
# Reference: https://github.com/scverse/scanpy/pull/3115/files
38-
'scanpy>=1.10.2',
39-
'ome-zarr<0.10.3',
40-
'tifffile>=2020.10.1',
41-
'jsonschema>=3.2',
42-
'tqdm>=4.1.0',
4334
]
4435

4536
[project.optional-dependencies]
@@ -68,6 +59,15 @@ docs = [
6859
'jinja2',
6960
]
7061
all = [
62+
# For data_utils
63+
'negspy>=0.2.24',
64+
'anndata>=0.7.8',
65+
# scanpy < 1.10.3 does not support numpy >= 2.0.0 and does not
66+
# Reference: https://github.com/scverse/scanpy/pull/3115/files
67+
'scanpy>=1.10.2',
68+
'ome-zarr<0.10.3',
69+
'tifffile>=2020.10.1',
70+
7171
'jupyter-server-proxy>=1.5.2',
7272
'oxc-py>=0.1.1',
7373
'anywidget>=0.9.10',
@@ -92,6 +92,7 @@ notebook = [
9292
'dask[dataframe]==2024.11.1',
9393
'marimo',
9494
'starlette>=0.42.0',
95+
'tqdm>=4.1.0',
9596
]
9697
demos = [
9798
"pulp==2.7.0",

src/vitessce/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@
2727
BASE_URL_PLACEHOLDER,
2828
)
2929

30-
from .config_converter import (
31-
CellBrowserToAnndataZarrConverter, # only exported for testing.
32-
convert_cell_browser_project_to_anndata,
33-
)
34-
3530
from .wrappers import AbstractWrapper
3631

3732
# We allow installation without all of the dependencies that the widget requires.

src/vitessce/widget.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,11 @@
22
from urllib.parse import quote_plus
33
import json
44
import sys
5-
6-
# Widget dependencies
7-
import anywidget
8-
from traitlets import Unicode, Dict, List, Int, Bool
95
import time
106
import uuid
7+
import anywidget
8+
from traitlets import Unicode, Dict, List, Int, Bool
119

12-
# Server dependencies
13-
from uvicorn import Config, Server
14-
15-
from starlette.applications import Starlette
16-
from starlette.middleware import Middleware
17-
from starlette.middleware.cors import CORSMiddleware
18-
from threading import Thread
19-
import socket
2010

2111
MAX_PORT_TRIES = 1000
2212
DEFAULT_PORT = 8000
@@ -25,6 +15,10 @@
2515
class BackgroundServer:
2616
# Reference: https://github.com/gosling-lang/gos/blob/main/gosling/data/_background_server.py#L10
2717
def __init__(self, routes):
18+
from starlette.applications import Starlette
19+
from starlette.middleware import Middleware
20+
from starlette.middleware.cors import CORSMiddleware
21+
2822
middleware = [
2923
Middleware(CORSMiddleware, allow_origins=[
3024
'*'], allow_methods=["OPTIONS", "GET"], allow_headers=['Range'])
@@ -47,6 +41,9 @@ def stop(self):
4741
return self
4842

4943
def start(self, port=None, timeout=1, daemon=True, log_level="warning"):
44+
from uvicorn import Config, Server
45+
from threading import Thread
46+
5047
if self.thread is not None:
5148
return self
5249

@@ -87,6 +84,7 @@ def register(self, config):
8784

8885

8986
def is_port_in_use(port):
87+
import socket
9088
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
9189
return s.connect_ex(('localhost', port)) == 0
9290

@@ -602,7 +600,7 @@ class VitessceWidget(anywidget.AnyWidget):
602600

603601
next_port = DEFAULT_PORT
604602

605-
js_package_version = Unicode('3.6.2').tag(sync=True)
603+
js_package_version = Unicode('3.6.3').tag(sync=True)
606604
js_dev_mode = Bool(False).tag(sync=True)
607605
custom_js_url = Unicode('').tag(sync=True)
608606
plugin_esm = List(trait=Unicode(''), default_value=[]).tag(sync=True)
@@ -614,7 +612,7 @@ class VitessceWidget(anywidget.AnyWidget):
614612

615613
store_urls = List(trait=Unicode(''), default_value=[]).tag(sync=True)
616614

617-
def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=False, js_package_version='3.6.2', js_dev_mode=False, custom_js_url='', plugins=None, remount_on_uid_change=True, prefer_local=True, invoke_timeout=300000, invoke_batched=True, page_mode=False, page_esm=None):
615+
def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=False, js_package_version='3.6.3', js_dev_mode=False, custom_js_url='', plugins=None, remount_on_uid_change=True, prefer_local=True, invoke_timeout=300000, invoke_batched=True, page_mode=False, page_esm=None):
618616
"""
619617
Construct a new Vitessce widget.
620618
@@ -749,7 +747,7 @@ def _plugin_command(self, params, buffers):
749747
# Launch Vitessce using plain HTML representation (no ipywidgets)
750748

751749

752-
def ipython_display(config, height=600, theme='auto', base_url=None, host_name=None, uid=None, port=None, proxy=False, js_package_version='3.6.2', js_dev_mode=False, custom_js_url='', plugins=None, remount_on_uid_change=True, page_mode=False, page_esm=None):
750+
def ipython_display(config, height=600, theme='auto', base_url=None, host_name=None, uid=None, port=None, proxy=False, js_package_version='3.6.3', js_dev_mode=False, custom_js_url='', plugins=None, remount_on_uid_change=True, page_mode=False, page_esm=None):
753751
from IPython.display import display, HTML
754752
uid_str = "vitessce" + get_uid_str(uid)
755753

tests/test_config_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from unittest.mock import patch, Mock
33
from copy import deepcopy
44

5-
from vitessce import (
5+
from vitessce.config_converter import (
66
CellBrowserToAnndataZarrConverter,
77
convert_cell_browser_project_to_anndata,
88
)

0 commit comments

Comments
 (0)