Skip to content

Commit 4fecbf4

Browse files
authored
Merge pull request #731 from thewtex/jupyterlite-tracebacks
Jupyterlite tracebacks
2 parents c10a195 + 35a1262 commit 4fecbf4

File tree

6 files changed

+54
-11
lines changed

6 files changed

+54
-11
lines changed

docs/Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ help:
1414

1515
.PHONY: help Makefile
1616

17+
clean:
18+
rm -rf _build
19+
rm -rf jupyterlite/_output
20+
1721
# Catch-all target: route all unknown targets to Sphinx using the new
1822
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1923
%: Makefile

docs/development.md

+37-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Development
22

3-
Note: [Node.js](https://nodejs.org/en/download/) is required for development.
3+
## Package
44

55
Setup your system for development:
66

@@ -14,4 +14,39 @@ pytest --nbmake examples/*.ipynb
1414

1515
If Python code is changed, restart the kernel to see the changes.
1616

17-
**Warning**: This project is under active development. Its API and behavior may change at any time. We mean it.
17+
**Warning**: This project is under active development. Its API and behavior may change at any time. We mean it 🙃.
18+
19+
## Documentation
20+
21+
Setup your system for documentation development on Unix-like systems:
22+
23+
```bash
24+
git clone https://github.com/InsightSoftwareConsortium/itkwidgets.git
25+
cd itkwidgets/docs
26+
pip install -r requirements.txt
27+
```
28+
29+
Build and serve the documentation:
30+
31+
```bash
32+
make html
33+
python -m http.server -d _build/html 8787
34+
```
35+
36+
Then visit *http://localhost:8787/* to see the rendered documentation.
37+
38+
### JupyterLite
39+
40+
The documentation includes an embedded JupyterLite deployment. To update the
41+
JupyterLite deployment, it is recommended to call `make clean` before starting
42+
a new build to avoid build caching issues. Also, serve the rendered
43+
documentation on a different port to avoid browser caching issues.
44+
45+
Notebooks served in the JupyterLite deployment can be found at
46+
*docs/jupyterlite/files*.
47+
48+
Support package wheels, including the `itkwidgets` wheel are referenced in
49+
*docs/jupyter/jupyterlite_config.json*. To update the URLs there, copy the
50+
download link address for a wheel found at https://pypi.org in a package's *Download
51+
files* page. Additional wheel files, if not on PyPI, can be added directly at
52+
*docs/jupyterlite/files/*.

docs/jupyterlite/files/Hello3DWorld.ipynb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"outputs": [],
99
"source": [
1010
"import piplite\n",
11-
"await piplite.install('itkwidgets==1.0a24')"
11+
"await piplite.install('itkwidgets==1.0a46.dev18+g0bcf158.d20240111')"
1212
]
1313
},
1414
{
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"PipliteAddon": {
33
"piplite_urls": [
4-
"https://files.pythonhosted.org/packages/4c/ee/56f970ca26375176d3e4885f58471a12d5a6794bcefe8ad0ccb8d7158ca3/itkwasm-1.0b82-py3-none-any.whl",
5-
"https://files.pythonhosted.org/packages/6c/55/c3fc7e2b9671d15f0c0becdcb9fad6c330172988744ad6eaa17b71bace88/imjoy_rpc-0.5.16-py3-none-any.whl",
4+
"https://files.pythonhosted.org/packages/0e/9b/2987677aa4dfadd8ad2636f2e90c3b1e527cddb8b0789fa6151f47f832fa/itkwasm-1.0b145-py3-none-any.whl",
5+
"https://files.pythonhosted.org/packages/80/48/1232756c08ecdc3305fecfec40ef13ac7ea2dd94a6203806595a696cc110/imjoy_rpc-0.5.46-py3-none-any.whl"
66
"https://files.pythonhosted.org/packages/69/d9/5a6c8af2f4b4f49a809ae316ae4c12937d7dfda4e5b2f9e4167df5f15c0e/imjoy_utils-0.1.2-py3-none-any.whl",
7-
"https://files.pythonhosted.org/packages/c9/dc/3504845528418aff0b71f4b622bb0e8e12adec2d8f2c1ba21d695b9ac6e6/itkwidgets-1.0a24-py3-none-any.whl",
8-
"https://files.pythonhosted.org/packages/d0/8a/458d5f8b90786be8013b5bfe85aa3ff8d49ee41380d0fdeafaa5f20c95fa/ngff_zarr-0.2.0-py3-none-any.whl"
7+
"https://files.pythonhosted.org/packages/ba/9f/ec8509396a847a34dfba58e7cf5e96750242eda8f7f45cdfe5c04013f204/itkwidgets-1.0a46-py3-none-any.whl",
8+
"https://files.pythonhosted.org/packages/b4/ba/2f2cec7283edd5666f9ac912eacc03ab62df3ae3c83b3718db5cd040dd7a/ngff_zarr-0.6.0-py3-none-any.whl"
99
]
1010
}
1111
}

itkwidgets/standalone_server.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@
2828
from ngff_zarr import detect_cli_io_backend, cli_input_to_ngff_image, ConversionBackend
2929
from pathlib import Path
3030
from urllib.parse import parse_qs, urlencode, urlparse
31-
from urllib3 import PoolManager, exceptions
31+
from .integrations.environment import ENVIRONMENT, Env
32+
# not available in pyodide by default
33+
if ENVIRONMENT is not Env.JUPYTERLITE:
34+
from urllib3 import PoolManager, exceptions
3235

3336
logging.getLogger("urllib3").setLevel(logging.ERROR)
3437
logging.getLogger("websocket-client").setLevel(logging.ERROR)

itkwidgets/viewer.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
build_init_data,
2323
defer_for_data_render,
2424
)
25-
from .cell_watcher import CellWatcher
2625
from .imjoy import register_itkwasm_imjoy_codecs
2726
from .integrations import _detect_render_type, _get_viewer_image, _get_viewer_point_set
2827
from .integrations.environment import ENVIRONMENT, Env
@@ -38,7 +37,8 @@
3837
_viewer_count = 1
3938
_codecs_registered = False
4039
_cell_watcher = None
41-
if ENVIRONMENT is not Env.HYPHA:
40+
if not ENVIRONMENT in (Env.HYPHA, Env.JUPYTERLITE):
41+
from .cell_watcher import CellWatcher
4242
_cell_watcher = CellWatcher() # Instantiate the singleton class right away
4343

4444

@@ -319,7 +319,8 @@ def fetch_value(func: Callable) -> Callable:
319319
@functools.wraps(func)
320320
def _fetch_value(self, *args, **kwargs):
321321
result = func(self, *args, **kwargs)
322-
if isawaitable(result):
322+
global _cell_watcher
323+
if isawaitable(result) and _cell_watcher:
323324
future = asyncio.ensure_future(result)
324325
self.call_getter(future)
325326
return future

0 commit comments

Comments
 (0)