tweag / jupyenv

Declarative and reproducible Jupyter environments - powered by Nix
https://jupyenv.io/
MIT License
671 stars 136 forks source link

[Bug]: Unable to use Bokeh #531

Open munnik opened 12 months ago

munnik commented 12 months ago

Current Behavior

In a notebook I have the following:

from bokeh.io import output_notebook
from bokeh.plotting import figure, show

The output is

---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
Cell In[12], line 1
----> 1 from bokeh.io import output_notebook
      2 from bokeh.plotting import figure, show

File /nix/store/75yf2m01cs8z99pa3hv2y8w17gqjip9s-python3-3.10.9-env/lib/python3.10/site-packages/bokeh/io/__init__.py:24
     17 log = logging.getLogger(__name__)
     19 #-----------------------------------------------------------------------------
     20 # Imports
     21 #-----------------------------------------------------------------------------
     22 
     23 # Bokeh imports
---> 24 from .doc import curdoc
     25 from .export import export_png, export_svg, export_svgs
     26 from .notebook import install_jupyter_hooks, install_notebook_hook, push_notebook

File /nix/store/75yf2m01cs8z99pa3hv2y8w17gqjip9s-python3-3.10.9-env/lib/python3.10/site-packages/bokeh/io/doc.py:30
     28 # Bokeh imports
     29 from ..document import Document
---> 30 from .state import curstate
     32 if TYPE_CHECKING:
     33     from ..document.locking import UnlockedDocumentProxy

File /nix/store/75yf2m01cs8z99pa3hv2y8w17gqjip9s-python3-3.10.9-env/lib/python3.10/site-packages/bokeh/io/state.py:54
     52 from ..core.types import PathLike
     53 from ..document import Document
---> 54 from ..resources import Resources, ResourcesMode
     56 if TYPE_CHECKING:
     57     from ..core.types import ID

File /nix/store/75yf2m01cs8z99pa3hv2y8w17gqjip9s-python3-3.10.9-env/lib/python3.10/site-packages/bokeh/resources.py:751
    745 # -----------------------------------------------------------------------------
    746 # Code
    747 # -----------------------------------------------------------------------------
    749 ResourcesLike: TypeAlias = Union[Resources, ResourcesMode]
--> 751 CDN = Resources(mode="cdn")
    753 INLINE = Resources(mode="inline")
    755 __all__ = (
    756     "CDN",
    757     "INLINE",
   (...)
    763     "verify_sri_hashes",
    764 )

File /nix/store/75yf2m01cs8z99pa3hv2y8w17gqjip9s-python3-3.10.9-env/lib/python3.10/site-packages/bokeh/resources.py:323, in BaseResources.__init__(***failed resolving arguments***)
    320 self.messages = []
    322 if self.mode == "cdn":
--> 323     cdn = self._cdn_urls()
    324     self.messages.extend(cdn.messages)
    325 elif self.mode == "server":

File /nix/store/75yf2m01cs8z99pa3hv2y8w17gqjip9s-python3-3.10.9-env/lib/python3.10/site-packages/bokeh/resources.py:384, in BaseResources._cdn_urls(self)
    383 def _cdn_urls(self) -> Urls:
--> 384     return _get_cdn_urls(self.version, self.minified)

File /nix/store/75yf2m01cs8z99pa3hv2y8w17gqjip9s-python3-3.10.9-env/lib/python3.10/site-packages/bokeh/resources.py:710, in _get_cdn_urls(version, minified)
    708 if is_full_release(version): # TODO: TypeGuard?
    709     assert version is not None
--> 710     sri_hashes = get_sri_hashes_for_version(version)
    711     result.hashes = lambda components, kind: {
    712         mk_url(component, kind): sri_hashes[mk_filename(component, kind)] for component in components
    713     }
    715 return result

File /nix/store/75yf2m01cs8z99pa3hv2y8w17gqjip9s-python3-3.10.9-env/lib/python3.10/site-packages/bokeh/resources.py:179, in get_sri_hashes_for_version(version)
    138 """ Report SRI script hashes for a specific version of BokehJS.
    139 
    140 Bokeh provides `Subresource Integrity`_ hashes for all JavaScript files that
   (...)
    176 
    177 """
    178 hashes = get_all_sri_hashes()
--> 179 return hashes[version]

KeyError: '0.0.0'

Expected Behavior

No output/error

Steps To Reproduce

Contents of the kernels.nix file:

{pkgs, ...}: {
  kernel.python.sumo = {
    enable = true;
    extraPackages = ps: [
      ps.psycopg2
      ps.configparser
      ps.scikit-learn
      ps.pandas
      ps.bokeh
      ps.jsonschema
    ];
  };
}

[@bokeh/jupyter_bokeh](https://github.com/bokeh/jupyter_bokeh) is listed as installed in the Extension Manager

OS

- system: `"x86_64-linux"`
 - host os: `Linux 6.1.64, NixOS, 23.11 (Tapir), 23.11.20231202.933d7dc`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - channels(munnik): `"home-manager-23.05.tar.gz, nixos-23.05, nixpkgs"`
 - channels(root): `""`
 - nixpkgs: `/home/munnik/.nix-defexpr/channels/nixpkgs`

Version

Dunno

Additional Context

No response

Relevant log output

No response

munnik commented 11 months ago

Running export BOKEH_CDN_VERSION=3.0.3 && nix run resolves the issue.