From 7d1b938fc0a608fe43fb42693ee942033b3763c5 Mon Sep 17 00:00:00 2001 From: Mark Keller <7525285+keller-mark@users.noreply.github.com> Date: Tue, 14 Jan 2025 16:29:45 -0500 Subject: [PATCH 1/2] Fix bug --- pyproject.toml | 2 +- src/vitessce/widget.py | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e69bf79a..527a4fde 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "vitessce" -version = "3.5.0" +version = "3.5.1" authors = [ { name="Mark Keller", email="mark_keller@hms.harvard.edu" }, ] diff --git a/src/vitessce/widget.py b/src/vitessce/widget.py index 4b344739..503d7fe1 100644 --- a/src/vitessce/widget.py +++ b/src/vitessce/widget.py @@ -244,6 +244,15 @@ def get_uid_str(uid): signal: AbortSignal.timeout(invokeTimeout), }); if (!data.success) return undefined; + + if (key.includes("spatialdata_attrs") && key.endsWith("0") && !ArrayBuffer.isView(buffers[0].buffer)) { + // For some reason, the Zarrita.js UnicodeStringArray does not seem to work with + // ArrayBuffers (throws a TypeError), so here we convert to Uint8Array if needed. + // This error is occurring specifically for the arr.getChunk call within the AnnDataSource._loadString function. + // TODO: figure out a more long-term solution. + return new Uint8Array(buffers[0].buffer); + } + return buffers[0].buffer; }, } @@ -454,7 +463,7 @@ class VitessceWidget(anywidget.AnyWidget): next_port = DEFAULT_PORT - js_package_version = Unicode('3.4.14').tag(sync=True) + js_package_version = Unicode('3.5.4').tag(sync=True) js_dev_mode = Bool(False).tag(sync=True) custom_js_url = Unicode('').tag(sync=True) plugin_esm = List(trait=Unicode(''), default_value=[]).tag(sync=True) @@ -463,7 +472,7 @@ class VitessceWidget(anywidget.AnyWidget): store_urls = List(trait=Unicode(''), default_value=[]).tag(sync=True) - def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=False, js_package_version='3.4.14', js_dev_mode=False, custom_js_url='', plugins=None, remount_on_uid_change=True, invoke_timeout=30000): + def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=False, js_package_version='3.5.4', js_dev_mode=False, custom_js_url='', plugins=None, remount_on_uid_change=True, invoke_timeout=30000): """ Construct a new Vitessce widget. @@ -576,7 +585,7 @@ def _plugin_command(self, params, buffers): # Launch Vitessce using plain HTML representation (no ipywidgets) -def ipython_display(config, height=600, theme='auto', base_url=None, host_name=None, uid=None, port=None, proxy=False, js_package_version='3.4.14', js_dev_mode=False, custom_js_url='', plugin_esm=DEFAULT_PLUGIN_ESM, remount_on_uid_change=True): +def ipython_display(config, height=600, theme='auto', base_url=None, host_name=None, uid=None, port=None, proxy=False, js_package_version='3.5.4', js_dev_mode=False, custom_js_url='', plugin_esm=DEFAULT_PLUGIN_ESM, remount_on_uid_change=True): from IPython.display import display, HTML uid_str = "vitessce" + get_uid_str(uid) From 08bcb00c662948a7535e6d8936c1a85e7045c885 Mon Sep 17 00:00:00 2001 From: Mark Keller <7525285+keller-mark@users.noreply.github.com> Date: Tue, 14 Jan 2025 16:31:18 -0500 Subject: [PATCH 2/2] Lint --- src/vitessce/widget.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vitessce/widget.py b/src/vitessce/widget.py index 503d7fe1..ed3b7772 100644 --- a/src/vitessce/widget.py +++ b/src/vitessce/widget.py @@ -244,7 +244,7 @@ def get_uid_str(uid): signal: AbortSignal.timeout(invokeTimeout), }); if (!data.success) return undefined; - + if (key.includes("spatialdata_attrs") && key.endsWith("0") && !ArrayBuffer.isView(buffers[0].buffer)) { // For some reason, the Zarrita.js UnicodeStringArray does not seem to work with // ArrayBuffers (throws a TypeError), so here we convert to Uint8Array if needed.