Skip to content

Commit

Permalink
Fix binder example (#363)
Browse files Browse the repository at this point in the history
* Fix binder issue

* bump version
  • Loading branch information
keller-mark authored Sep 11, 2024
1 parent 94501cc commit c48fdd8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
15 changes: 5 additions & 10 deletions docs/notebooks/widget_pbmc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@
"source": [
"## 4. Create a Vitessce view config\n",
"\n",
"Define the data and views you would like to include in the widget."
"Define the data and views you would like to include in the widget.\n",
"\n",
"For more details about how to configure data depending on where the files are located relative to the notebook execution, see https://python-docs.vitessce.io/data_options.html."
]
},
{
Expand All @@ -129,7 +131,7 @@
"source": [
"vc = VitessceConfig(schema_version=\"1.0.15\", name='PBMC Reference')\n",
"dataset = vc.add_dataset(name='PBMC 3k').add_object(AnnDataWrapper(\n",
" adata_path=zarr_filepath,\n",
" adata_store=zarr_filepath,\n",
" obs_set_paths=[\"obs/leiden\"],\n",
" obs_set_names=[\"Leiden\"],\n",
" obs_embedding_paths=[\"obsm/X_umap\", \"obsm/X_pca\"],\n",
Expand All @@ -153,13 +155,6 @@
"## 5. Create the Vitessce widget"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"A widget can be created with the `.widget()` method on the config instance. Here, the `proxy=True` parameter allows this widget to be used in a cloud notebook environment, such as Binder."
]
},
{
"cell_type": "code",
"execution_count": null,
Expand Down Expand Up @@ -201,7 +196,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.0"
"version": "3.9.0"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "vitessce"
version = "3.3.2"
version = "3.3.3"
authors = [
{ name="Mark Keller", email="mark_keller@hms.harvard.edu" },
]
Expand Down
16 changes: 12 additions & 4 deletions vitessce/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ def get_uid_str(uid):
const pluginEsmArr = view.model.get('plugin_esm');
const remountOnUidChange = view.model.get('remount_on_uid_change');
const storeUrls = view.model.get('store_urls');
const invokeTimeout = view.model.get('invoke_timeout');
const pkgName = (jsDevMode ? "@vitessce/dev" : "vitessce");
Expand Down Expand Up @@ -230,7 +231,9 @@ def get_uid_str(uid):
storeUrl,
{
async get(key) {
const [data, buffers] = await view.experimental.invoke("_zarr_get", [storeUrl, key]);
const [data, buffers] = await view.experimental.invoke("_zarr_get", [storeUrl, key], {
signal: AbortSignal.timeout(invokeTimeout),
});
if (!data.success) return undefined;
return buffers[0].buffer;
},
Expand All @@ -239,7 +242,9 @@ def get_uid_str(uid):
);
function invokePluginCommand(commandName, commandParams, commandBuffers) {
return view.experimental.invoke("_plugin_command", [commandName, commandParams], commandBuffers);
return view.experimental.invoke("_plugin_command", [commandName, commandParams], commandBuffers, {
signal: AbortSignal.timeout(invokeTimeout),
});
}
for (const pluginEsm of pluginEsmArr) {
Expand Down Expand Up @@ -437,10 +442,11 @@ class VitessceWidget(anywidget.AnyWidget):
custom_js_url = Unicode('').tag(sync=True)
plugin_esm = List(trait=Unicode(''), default_value=[]).tag(sync=True)
remount_on_uid_change = Bool(True).tag(sync=True)
invoke_timeout = Int(30000).tag(sync=True)

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.10', js_dev_mode=False, custom_js_url='', plugins=None, remount_on_uid_change=True):
def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=False, js_package_version='3.4.10', js_dev_mode=False, custom_js_url='', plugins=None, remount_on_uid_change=True, invoke_timeout=30000):
"""
Construct a new Vitessce widget.
Expand All @@ -455,6 +461,7 @@ def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=
:param str custom_js_url: A URL to a JavaScript file to use (instead of 'vitessce' or '@vitessce/dev' NPM package).
:param list[WidgetPlugin] plugins: A list of subclasses of VitesscePlugin. Optional.
:param bool remount_on_uid_change: Passed to the remountOnUidChange prop of the <Vitessce/> React component. By default, True.
:param int invoke_timeout: The timeout in milliseconds for invoking Python functions from JavaScript. By default, 30000.
.. code-block:: python
:emphasize-lines: 4
Expand Down Expand Up @@ -486,7 +493,7 @@ def __init__(self, config, height=600, theme='auto', uid=None, port=None, proxy=
super(VitessceWidget, self).__init__(
config=config_dict, height=height, theme=theme, proxy=proxy,
js_package_version=js_package_version, js_dev_mode=js_dev_mode, custom_js_url=custom_js_url,
plugin_esm=plugin_esm, remount_on_uid_change=remount_on_uid_change,
plugin_esm=plugin_esm, remount_on_uid_change=remount_on_uid_change, invoke_timeout=invoke_timeout,
uid=uid_str, store_urls=list(self._stores.keys())
)

Expand Down Expand Up @@ -569,6 +576,7 @@ def ipython_display(config, height=600, theme='auto', base_url=None, host_name=N
"custom_js_url": custom_js_url,
"plugin_esm": plugin_esm,
"remount_on_uid_change": remount_on_uid_change,
"invoke_timeout": 30000,
"proxy": proxy,
"has_host_name": host_name is not None,
"height": height,
Expand Down

0 comments on commit c48fdd8

Please sign in to comment.