@@ -233,6 +233,7 @@ def get_uid_str(uid):
233
233
const remountOnUidChange = view.model.get('remount_on_uid_change');
234
234
const storeUrls = view.model.get('store_urls');
235
235
const invokeTimeout = view.model.get('invoke_timeout');
236
+ const invokeBatched = view.model.get('invoke_batched');
236
237
237
238
const pageMode = view.model.get('page_mode');
238
239
const pageEsm = view.model.get('page_esm');
@@ -319,23 +320,25 @@ def get_uid_str(uid):
319
320
storeUrl,
320
321
{
321
322
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
+ }
336
339
337
- return buffers[0].buffer;
338
- */
340
+ return buffers[0].buffer;
341
+ }
339
342
},
340
343
}
341
344
])),
@@ -413,7 +416,7 @@ def get_uid_str(uid):
413
416
}
414
417
415
418
function VitessceWidget(props) {
416
- const { model } = props;
419
+ const { model, styleContainer } = props;
417
420
418
421
const [config, setConfig] = React.useState(prependBaseUrl(model.get('config'), model.get('proxy'), model.get('has_host_name')));
419
422
const [validateConfig, setValidateConfig] = React.useState(true);
@@ -477,7 +480,7 @@ def get_uid_str(uid):
477
480
height, theme, config, onConfigChange, validateConfig,
478
481
pluginViewTypes, pluginCoordinationTypes,
479
482
pluginFileTypes,pluginJointFileTypes, pluginAsyncFunctions,
480
- remountOnUidChange, stores, pageMode,
483
+ remountOnUidChange, stores, pageMode, styleContainer,
481
484
};
482
485
483
486
return e('div', { ref: divRef, style: { height: height + 'px' } },
@@ -492,7 +495,10 @@ def get_uid_str(uid):
492
495
}
493
496
494
497
const root = createRoot(view.el);
495
- root.render(e(VitessceWidget, { model: view.model }));
498
+ // Marimo puts AnyWidgets in a Shadow Root, so we need to tell Emotion to
499
+ // insert styles within the Shadow DOM.
500
+ const styleContainer = view.el.getRootNode();
501
+ root.render(e(VitessceWidget, { model: view.model, styleContainer }));
496
502
497
503
return () => {
498
504
// Re-enable scrolling.
@@ -603,10 +609,11 @@ class VitessceWidget(anywidget.AnyWidget):
603
609
page_mode = Bool (False ).tag (sync = True )
604
610
page_esm = Unicode ('' ).tag (sync = True )
605
611
invoke_timeout = Int (300000 ).tag (sync = True )
612
+ invoke_batched = Bool (True ).tag (sync = True )
606
613
607
614
store_urls = List (trait = Unicode ('' ), default_value = []).tag (sync = True )
608
615
609
- def __init__ (self , config , height = 600 , theme = 'auto' , uid = None , port = None , proxy = False , js_package_version = '3.5.12' , 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 ):
616
+ def __init__ (self , config , height = 600 , theme = 'auto' , uid = None , port = None , proxy = False , js_package_version = '3.5.12' , 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 ):
610
617
"""
611
618
Construct a new Vitessce widget.
612
619
@@ -623,6 +630,7 @@ def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=
623
630
:param bool remount_on_uid_change: Passed to the remountOnUidChange prop of the <Vitessce/> React component. By default, True.
624
631
:param bool prefer_local: Should local data be preferred (only applies to `*_artifact` data objects)? By default, True.
625
632
:param int invoke_timeout: The timeout in milliseconds for invoking Python functions from JavaScript. By default, 300000.
633
+ :param bool invoke_batched: Should invocations (Zarr gets) be submitted in batch, or individually? By default, True.
626
634
:param bool page_mode: Whether to render the <Vitessce/> component in grid-mode or page-mode. By default, False.
627
635
:param str page_esm: The ES module string for the page component creation function. Optional.
628
636
@@ -658,7 +666,7 @@ def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=
658
666
js_package_version = js_package_version , js_dev_mode = js_dev_mode , custom_js_url = custom_js_url ,
659
667
plugin_esm = plugin_esm , remount_on_uid_change = remount_on_uid_change ,
660
668
page_mode = page_mode , page_esm = ('' if page_esm is None else page_esm ),
661
- invoke_timeout = invoke_timeout ,
669
+ invoke_timeout = invoke_timeout , invoke_batched = invoke_batched ,
662
670
uid = uid_str , store_urls = list (self ._stores .keys ())
663
671
)
664
672
@@ -763,6 +771,7 @@ def ipython_display(config, height=600, theme='auto', base_url=None, host_name=N
763
771
"page_esm" : ('' if page_esm is None else page_esm ),
764
772
"remount_on_uid_change" : remount_on_uid_change ,
765
773
"invoke_timeout" : 30000 ,
774
+ "invoke_batched" : False ,
766
775
"proxy" : proxy ,
767
776
"has_host_name" : host_name is not None ,
768
777
"height" : height ,
0 commit comments