tweag / jupyenv

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

Unable to configure jupyterlab_widgets / ipywidgets with jupiterWith #207

Closed dmayle closed 2 years ago

dmayle commented 2 years ago

Describe the bug Following the docs, I've generated a shell.nix and used generate-directory but the widgets won't load

To Reproduce

  1. shell.nix

    let                                                                                                                                                                                                                                                                          
    jupyter = import (builtins.fetchGit {                                                                                                                                                                                                                                      
    url = https://github.com/tweag/jupyterWith;                                                                                                                                                                                                                              
    rev = "45f9a774e981d3a3fb6a1e1269e33b4624f9740e";                                                                                                                                                                                                                        
    }) {};                                                                                                                                                                                                                                                                     
    
    iPython = jupyter.kernels.iPythonWith {                                                                                                                                                                                                                                    
    name = "python";                                                                                                                                                                                                                                                         
    packages = p: with p; [                                                                                                                                                                                                                                                  
      beautifulsoup4                                                                                                                                                                                                                                                         
      ipywidgets                                                                                                                                                                                                                                                             
      matplotlib                                                                                                                                                                                                                                                             
      Keras                                                                                                                                                                                                                                                                  
      pillow                                                                                                                                                                                                                                                                 
      tensorflow                                                                                                                                                                                                                                                             
      tqdm                                                                                                                                                                                                                                                                   
      jupyterlab-widgets                                                                                                                                                                                                                                                     
    ];                                                                                                                                                                                                                                                                       
    };                                                                                                                                                                                                                                                                         
    
    golang = jupyter.kernels.gophernotes {                                                                                                                                                                                                                                     
    name = "Go";                                                                                                                                                                                                                                                             
    };                                                                                                                                                                                                                                                                         
    
    jupyterEnvironment =                                                                                                                                                                                                                                                       
    jupyter.jupyterlabWith {                                                                                                                                                                                                                                                 
      kernels = [ iPython golang ];                                                                                                                                                                                                                                          
      directory = /home/doug/src/ml-playground/jupyterlab;                                                                                                                                                                                                                 
    };                                                                                                                                                                                                                                                                       
    in                                                                                                                                                                                                                                                                           
    jupyterEnvironment.env

    Run generate-directory jupyterlab_widgets Enter this into a jupyterlab cell:

    import jupyterlab_widgets
    from ipywidgets import interact, interactive, fixed, interact_manual
    import ipywidgets as widgets
    def f(x):
    return x
    interact(f, x=10)

Expected behavior The cell output should be an interactive slider

Environment

Additional context

doug@doug-laptop:~/src/ml-playground$ jupyter-labextension list
JupyterLab v3.1.6
Other labextensions (built into JupyterLab)
   app dir: /nix/store/wijndwf354w2i7fx7j30w7pgl3vqh4f0-jupyterlab
        jupyterlab_widgets v0.3.1 enabled OK
garbas commented 2 years ago

In next version we wont support generate-directory command anymore, but we will focus on packaging extensions with Nix.