tethysplatform / tethys

The Tethys Platform main Django website project repository.
http://tethysplatform.org/
BSD 2-Clause "Simplified" License
92 stars 49 forks source link

[BUG] Error in Gizmo showcase with Bokeh 3 #980

Closed swainn closed 9 months ago

swainn commented 1 year ago

Describe the bug I get ValueError when visiting the Bokeh page of the Gizmo showcase app when Bokeh 3.x is installed.

To Reproduce Steps to reproduce the behavior:

  1. Install Gizmo Showcase
  2. conda install bokeh=3
  3. Start Tethys
  4. Navigate to the Bokeh View under Plot Views in the Gizmo Showcase app.

Expected behavior It should render the page without error showing bokeh plots.

Errors/Traceback

```python Environment: Request Method: GET Request URL: http://127.0.0.1:8000/apps/gizmo-showcase/bokeh/bokeh-view/ Django Version: 3.2.19 Python Version: 3.11.4 Installed Applications: ('channels', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_bootstrap5', 'tethys_apps', 'tethys_compute', 'tethys_config', 'tethys_gizmos', 'tethys_layouts', 'tethys_sdk', 'tethys_services', 'tethys_quotas', 'guardian', 'rest_framework', 'rest_framework.authtoken') Installed Middleware: ('django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'tethys_portal.middleware.TethysMfaRequiredMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'tethys_portal.middleware.TethysAppAccessMiddleware') Traceback (most recent call last): File "/home/aquadev/miniconda3/envs/microtethys/lib/python3.11/site-packages/django/core/handlers/exception.py", line 38, in inner response = await get_response(request) File "/home/aquadev/miniconda3/envs/microtethys/lib/python3.11/site-packages/django/core/handlers/base.py", line 233, in _get_response_async response = await wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/aquadev/tethys/tethys_apps/decorators.py", line 39, in wrapper return controller(request, *args, **kwargs) File "/home/aquadev/miniconda3/envs/microtethys/lib/python3.11/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view return view_func(request, *args, **kwargs) File "/home/aquadev/tethysapp-gizmo_showcase/tethysapp/gizmo_showcase/controllers/bokeh.py", line 141, in bokeh_view select.toolbar.active_multi = range_tool File "/home/aquadev/miniconda3/envs/microtethys/lib/python3.11/site-packages/bokeh/core/has_props.py", line 327, in __setattr__ return super().__setattr__(name, value) File "/home/aquadev/miniconda3/envs/microtethys/lib/python3.11/site-packages/bokeh/core/property/descriptors.py", line 332, in __set__ value = self.property.prepare_value(obj, self.name, value) File "/home/aquadev/miniconda3/envs/microtethys/lib/python3.11/site-packages/bokeh/core/property/bases.py", line 364, in prepare_value raise ValueError(f"failed to validate {obj_repr}.{name}: {error}") Exception Type: ValueError at /apps/gizmo-showcase/bokeh/bokeh-view/ Exception Value: failed to validate Toolbar(id='p1280', ...).active_multi: expected an element of either Null, Auto or Instance(GestureTool), got RangeTool(id='p1300', ...) ```

Screenshots N/A

Tethys Environment Information Include output from these commands:

``` tethys version 4.1.1.dev20+ged56463f ``` ``` conda info active environment : microtethys active env location : /home/aquadev/miniconda3/envs/microtethys shell level : 2 user config file : /home/aquadev/.condarc populated config files : /home/aquadev/.condarc conda version : 23.3.1 conda-build version : not installed python version : 3.10.11.final.0 virtual packages : __archspec=1=x86_64 __glibc=2.35=0 __linux=5.15.90.1=0 __unix=0=0 base environment : /home/aquadev/miniconda3 (writable) conda av data dir : /home/aquadev/miniconda3/etc/conda conda av metadata url : None channel URLs : https://repo.anaconda.com/pkgs/main/linux-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/linux-64 https://repo.anaconda.com/pkgs/r/noarch package cache : /home/aquadev/miniconda3/pkgs /home/aquadev/.conda/pkgs envs directories : /home/aquadev/miniconda3/envs /home/aquadev/.conda/envs platform : linux-64 user-agent : conda/23.3.1 requests/2.29.0 CPython/3.10.11 Linux/5.15.90.1-microsoft-standard-WSL2 ubuntu/22.04.2 glibc/2.35 solver/libmamba conda-libmamba-solver/23.3.0 libmambapy/1.4.1 UID:GID : 1000:1000 netrc file : None offline mode : False ``` ``` conda list # packages in environment at /home/aquadev/miniconda3/envs/microtethys: # # Name Version Build Channel _libgcc_mutex 0.1 conda_forge conda-forge _openmp_mutex 4.5 2_gnu conda-forge appdirs 1.4.4 pyh9f0ad1d_0 conda-forge asgiref 3.7.2 pyhd8ed1ab_0 conda-forge attrs 23.1.0 pyh71513ae_1 conda-forge autobahn 23.6.2 pyhd8ed1ab_0 conda-forge automat 22.10.0 pyhd8ed1ab_0 conda-forge bcrypt 3.2.2 py311hd4cff14_1 conda-forge beautifulsoup4 4.12.2 pyha770c72_0 conda-forge bokeh 3.2.1 py311h92b7b1e_0 boltons 23.0.0 pyhd8ed1ab_0 conda-forge brotli-python 1.0.9 py311ha362b79_9 conda-forge bzip2 1.0.8 h7f98852_4 conda-forge c-ares 1.19.1 hd590300_0 conda-forge ca-certificates 2023.7.22 hbcca054_0 conda-forge certifi 2023.7.22 py311h06a4308_0 cffi 1.15.1 py311h409f033_3 conda-forge channels 3.0.5 pyhd8ed1ab_0 conda-forge charset-normalizer 3.2.0 pyhd8ed1ab_0 conda-forge colorama 0.4.6 pyhd8ed1ab_0 conda-forge conda 23.7.2 py311h38be061_0 conda-forge conda-libmamba-solver 23.7.0 pyhd8ed1ab_0 conda-forge conda-package-handling 2.2.0 pyh38be061_0 conda-forge conda-package-streaming 0.9.0 pyhd8ed1ab_0 conda-forge constantly 15.1.0 py_0 conda-forge contourpy 1.1.0 py311h9547e67_0 conda-forge cryptography 41.0.3 py311h63ff55d_0 conda-forge daphne 3.0.2 pyhd8ed1ab_0 conda-forge django 3.2.19 pyhd8ed1ab_0 conda-forge django-bootstrap5 23.3 pyhd8ed1ab_0 conda-forge django-guardian 2.4.0 pyhd8ed1ab_0 conda-forge django-model-utils 4.3.1 pyhd8ed1ab_0 conda-forge djangorestframework 3.14.0 pyhd8ed1ab_0 conda-forge fmt 9.1.0 h924138e_0 conda-forge freetype 2.12.1 hca18f0e_1 conda-forge geojson 3.0.1 pyhd8ed1ab_0 conda-forge hyperlink 21.0.0 pyhd3deb0d_0 conda-forge icu 72.1 hcb278e6_0 conda-forge idna 3.4 pyhd8ed1ab_0 conda-forge incremental 22.10.0 pyhd8ed1ab_0 conda-forge jinja2 3.1.2 pyhd8ed1ab_1 conda-forge jsonpatch 1.32 pyhd8ed1ab_0 conda-forge jsonpointer 2.0 py_0 conda-forge keyutils 1.6.1 h166bdaf_0 conda-forge krb5 1.21.2 h659d440_0 conda-forge lcms2 2.15 haa2dc70_1 conda-forge ld_impl_linux-64 2.40 h41732ed_0 conda-forge lerc 4.0.0 h27087fc_0 conda-forge libarchive 3.6.2 h039dbb9_1 conda-forge libblas 3.9.0 17_linux64_openblas conda-forge libcblas 3.9.0 17_linux64_openblas conda-forge libcurl 8.2.1 hca28451_0 conda-forge libdeflate 1.18 h0b41bf4_0 conda-forge libedit 3.1.20191231 he28a2e2_2 conda-forge libev 4.33 h516909a_1 conda-forge libexpat 2.5.0 hcb278e6_1 conda-forge libffi 3.4.2 h7f98852_5 conda-forge libgcc-ng 13.1.0 he5830b7_0 conda-forge libgfortran-ng 13.1.0 h69a702a_0 conda-forge libgfortran5 13.1.0 h15d22d2_0 conda-forge libgomp 13.1.0 he5830b7_0 conda-forge libiconv 1.17 h166bdaf_0 conda-forge libjpeg-turbo 2.1.5.1 h0b41bf4_0 conda-forge liblapack 3.9.0 17_linux64_openblas conda-forge libmamba 1.4.9 h658169a_0 conda-forge libmambapy 1.4.9 py311h527f279_0 conda-forge libnghttp2 1.52.0 h61bc06f_0 conda-forge libnsl 2.0.0 h7f98852_0 conda-forge libopenblas 0.3.23 pthreads_h80387f5_0 conda-forge libpng 1.6.39 h753d276_0 conda-forge libsolv 0.7.24 hfc55251_1 conda-forge libsqlite 3.42.0 h2797004_0 conda-forge libssh2 1.11.0 h0841786_0 conda-forge libstdcxx-ng 13.1.0 hfd8a6a1_0 conda-forge libtiff 4.5.1 h8b53f26_0 conda-forge libuuid 2.38.1 h0b41bf4_0 conda-forge libwebp-base 1.3.1 hd590300_0 conda-forge libxcb 1.15 h0b41bf4_0 conda-forge libxml2 2.11.5 h0d562d8_0 conda-forge libzlib 1.2.13 hd590300_5 conda-forge lz4-c 1.9.4 hcb278e6_0 conda-forge lzo 2.10 h516909a_1000 conda-forge markupsafe 2.1.3 py311h459d7ec_0 conda-forge ncurses 6.4 hcb278e6_0 conda-forge numpy 1.25.2 py311h64a7726_0 conda-forge openjpeg 2.5.0 hfec8fc6_2 conda-forge openssl 3.1.2 hd590300_0 conda-forge packaging 23.1 pyhd8ed1ab_0 conda-forge pandas 2.0.3 py311h320fe9a_1 conda-forge pillow 10.0.0 py311h0b84326_0 conda-forge pip 23.2.1 pyhd8ed1ab_0 conda-forge plotly 5.16.1 pyhd8ed1ab_0 conda-forge pluggy 1.2.0 pyhd8ed1ab_0 conda-forge pthread-stubs 0.4 h36c2ea0_1001 conda-forge pyasn1 0.4.8 py_0 conda-forge pyasn1-modules 0.2.7 py_0 conda-forge pybind11-abi 4 hd8ed1ab_3 conda-forge pycosat 0.6.4 py311hd4cff14_1 conda-forge pycparser 2.21 pyhd8ed1ab_0 conda-forge pyopenssl 23.2.0 pyhd8ed1ab_1 conda-forge pysocks 1.7.1 pyha2e5f31_6 conda-forge python 3.11.4 hab00c5b_0_cpython conda-forge python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python-tzdata 2023.3 pyhd8ed1ab_0 conda-forge python_abi 3.11 3_cp311 conda-forge pytz 2023.3 pyhd8ed1ab_0 conda-forge pyyaml 6.0 py311hd4cff14_5 conda-forge readline 8.2 h8228510_1 conda-forge reproc 14.2.4 h0b41bf4_0 conda-forge reproc-cpp 14.2.4 hcb278e6_0 conda-forge requests 2.31.0 pyhd8ed1ab_0 conda-forge ruamel.yaml 0.17.32 py311h459d7ec_0 conda-forge ruamel.yaml.clib 0.2.7 py311h2582759_1 conda-forge service_identity 18.1.0 py_0 conda-forge setuptools 68.1.2 pyhd8ed1ab_0 conda-forge setuptools-scm 7.1.0 pyhd8ed1ab_0 conda-forge setuptools_scm 7.1.0 hd8ed1ab_0 conda-forge six 1.16.0 pyh6c4a22f_0 conda-forge soupsieve 2.3.2.post1 pyhd8ed1ab_0 conda-forge sqlparse 0.4.4 pyhd8ed1ab_0 conda-forge tenacity 8.2.3 pyhd8ed1ab_0 conda-forge tethys-platform 4.1.1.dev20+ged56463f pypi_0 pypi tethysapp-gizmo-showcase 0.0.1 dev_0 tethysapp-layout-showcase 0.0.1 dev_0 tk 8.6.12 h27826a3_0 conda-forge tomli 2.0.1 pyhd8ed1ab_0 conda-forge toolz 0.12.0 pyhd8ed1ab_0 conda-forge tornado 6.3.3 py311h459d7ec_0 conda-forge tqdm 4.66.1 pyhd8ed1ab_0 conda-forge twisted 22.10.0 py311hd4cff14_0 conda-forge txaio 23.1.1 pyhd8ed1ab_0 conda-forge typing-extensions 4.7.1 hd8ed1ab_0 conda-forge typing_extensions 4.7.1 pyha770c72_0 conda-forge tzdata 2023c h71feb2d_0 conda-forge urllib3 2.0.4 pyhd8ed1ab_0 conda-forge wheel 0.41.1 pyhd8ed1ab_0 conda-forge xorg-libxau 1.0.11 hd590300_0 conda-forge xorg-libxdmcp 1.1.3 h7f98852_0 conda-forge xyzservices 2023.7.0 pyhd8ed1ab_0 conda-forge xz 5.2.6 h166bdaf_0 conda-forge yaml 0.2.5 h7f98852_2 conda-forge yaml-cpp 0.7.0 h27087fc_2 conda-forge zope.interface 6.0 py311h2582759_0 conda-forge zstandard 0.19.0 py311haa97af0_2 conda-forge zstd 1.5.2 hfc55251_7 conda-forge ```

Additional context I was testing using microtethys.

sdc50 commented 10 months ago

It appears this issue is discussed here: https://github.com/bokeh/bokeh/issues/12971

sdc50 commented 10 months ago

It appears that this line:

select.toolbar.active_multi = range_tool

Is not needed. I've removed this line and tested with Bokeh=2.4 and Bokeh=3.3. It works with both.

However, in Bokeh 3.3 the BOKEH_RESOURCES="inline" is not working. This was the default setting. I've changed it to "server" which works in both versions of Bokeh. The error when using "inline" is a JavaScript error:

Uncaught ReferenceError: Bokeh is not defined
    at HTMLDocument.fn (bokeh-view/:242:5)
fn @ bokeh-view/:242

and I believe is a bug with Bokeh.

sdc50 commented 10 months ago

I created this discourse topic to find out if this change is a bug or an intended change in Bokeh. Until this is fixed in Bokeh I've created some logic to set BOKEH_RESOURCES to server (for the gizmo only) if it is set to inline and Bokeh version is >2.

sdc50 commented 9 months ago

It appears, per the response from discourse topic, that Bokeh components was never intended to support the inline resources option.

sdc50 commented 9 months ago

closed by #967