@@ -233,6 +233,7 @@ def get_uid_str(uid):
233233 const remountOnUidChange = view.model.get('remount_on_uid_change');
234234 const storeUrls = view.model.get('store_urls');
235235 const invokeTimeout = view.model.get('invoke_timeout');
236+ const invokeBatched = view.model.get('invoke_batched');
236237
237238 const pageMode = view.model.get('page_mode');
238239 const pageEsm = view.model.get('page_esm');
@@ -319,23 +320,25 @@ def get_uid_str(uid):
319320 storeUrl,
320321 {
321322 async get(key) {
322- return enqueue([storeUrl, key]);
323- /*
324- const [data, buffers] = await view.experimental.invoke("_zarr_get", [storeUrl, key], {
325- signal: AbortSignal.timeout(invokeTimeout),
326- });
327- if (!data.success) return undefined;
328-
329- if (key.includes("spatialdata_attrs") && key.endsWith("0") && !ArrayBuffer.isView(buffers[0].buffer)) {
330- // For some reason, the Zarrita.js UnicodeStringArray does not seem to work with
331- // ArrayBuffers (throws a TypeError), so here we convert to Uint8Array if needed.
332- // This error is occurring specifically for the arr.getChunk call within the AnnDataSource._loadString function.
333- // TODO: figure out a more long-term solution.
334- return new Uint8Array(buffers[0].buffer);
335- }
323+ if (invokeBatched) {
324+ return enqueue([storeUrl, key]);
325+ } else {
326+ // Do not submit zarr gets in batches. Instead, submit individually.
327+ const [data, buffers] = await view.experimental.invoke("_zarr_get", [storeUrl, key], {
328+ signal: AbortSignal.timeout(invokeTimeout),
329+ });
330+ if (!data.success) return undefined;
331+
332+ if (key.includes("spatialdata_attrs") && key.endsWith("0") && !ArrayBuffer.isView(buffers[0].buffer)) {
333+ // For some reason, the Zarrita.js UnicodeStringArray does not seem to work with
334+ // ArrayBuffers (throws a TypeError), so here we convert to Uint8Array if needed.
335+ // This error is occurring specifically for the arr.getChunk call within the AnnDataSource._loadString function.
336+ // TODO: figure out a more long-term solution.
337+ return new Uint8Array(buffers[0].buffer);
338+ }
336339
337- return buffers[0].buffer;
338- */
340+ return buffers[0].buffer;
341+ }
339342 },
340343 }
341344 ])),
@@ -603,10 +606,11 @@ class VitessceWidget(anywidget.AnyWidget):
603606 page_mode = Bool (False ).tag (sync = True )
604607 page_esm = Unicode ('' ).tag (sync = True )
605608 invoke_timeout = Int (300000 ).tag (sync = True )
609+ invoke_batched = Bool (True ).tag (sync = True )
606610
607611 store_urls = List (trait = Unicode ('' ), default_value = []).tag (sync = True )
608612
609- def __init__ (self , config , height = 600 , theme = 'auto' , uid = None , port = None , proxy = False , js_package_version = '3.5.11' , js_dev_mode = False , custom_js_url = '' , plugins = None , remount_on_uid_change = True , prefer_local = True , invoke_timeout = 300000 , page_mode = False , page_esm = None ):
613+ def __init__ (self , config , height = 600 , theme = 'auto' , uid = None , port = None , proxy = False , js_package_version = '3.5.11' , 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 ):
610614 """
611615 Construct a new Vitessce widget.
612616
@@ -623,6 +627,7 @@ def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=
623627 :param bool remount_on_uid_change: Passed to the remountOnUidChange prop of the <Vitessce/> React component. By default, True.
624628 :param bool prefer_local: Should local data be preferred (only applies to `*_artifact` data objects)? By default, True.
625629 :param int invoke_timeout: The timeout in milliseconds for invoking Python functions from JavaScript. By default, 300000.
630+ :param bool invoke_batched: Should invocations (Zarr gets) be submitted in batch, or individually? By default, True.
626631 :param bool page_mode: Whether to render the <Vitessce/> component in grid-mode or page-mode. By default, False.
627632 :param str page_esm: The ES module string for the page component creation function. Optional.
628633
@@ -658,7 +663,7 @@ def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=
658663 js_package_version = js_package_version , js_dev_mode = js_dev_mode , custom_js_url = custom_js_url ,
659664 plugin_esm = plugin_esm , remount_on_uid_change = remount_on_uid_change ,
660665 page_mode = page_mode , page_esm = ('' if page_esm is None else page_esm ),
661- invoke_timeout = invoke_timeout ,
666+ invoke_timeout = invoke_timeout , invoke_batched = invoke_batched ,
662667 uid = uid_str , store_urls = list (self ._stores .keys ())
663668 )
664669
0 commit comments