Widgets not displaying

I am trying to run the notebook “InSAR Time Series Analysis using MintPy and HyP3 products” using OpenScienceLab Server. I am not able to interact with the widgets. the codes I am tring to run are below:

import url_widget as url_w
notebookUrl = url_w.URLWidget()
display(notebookUrl)

from IPython.display import Markdown
from IPython.display import display

notebookUrl = notebookUrl.value
user = !echo $JUPYTERHUB_USER
env = !echo $CONDA_PREFIX
if env[0] == ‘’:
** env[0] = ‘Python 3 (base)’**
if env[0] != ‘/home/jovyan/.local/envs/osl_mintpy’:
** display(Markdown(f’WARNING:‘))**
** display(Markdown(f’This notebook should be run using the “osl_mintpy” conda environment.‘))**
** display(Markdown(f’It is currently using the “{env[0].split(”/“)[-1]}” environment.‘))**
** display(Markdown(f’Select “osl_mintpy” from the “Change Kernel” submenu of the “Kernel” menu.‘))**
** display(Markdown(f’If the “osl_mintpy” environment is not present, use <a href=“{notebookUrl.split(”/user")[0]}/user/{user[0]}/notebooks/conda_environments/Create_OSL_Conda_Environments.ipynb"> Create_OSL_Conda_Environments.ipynb to create it.‘))**
** display(Markdown(f’Note that you must restart your server after creating a new environment before it is usable by notebooks.'))**

import base64
import contextlib
import csv
from datetime import datetime, timedelta
from getpass import getpass
import os
from pathlib import Path
import re
import shutil
from typing import Union
import zipfile
import h5py
from ipyfilechooser import FileChooser
import numpy as np
from osgeo import gdal, osr
gdal.UseExceptions()
from pandas.core.frame import DataFrame
import rasterio
from rasterio.transform import from_origin
from rasterio.warp import transform_bounds, transform
import rioxarray as rxr
from tqdm.notebook import tqdm
import urllib
import xarray as xr
from bokeh.plotting import figure, show, output_file, ColumnDataSource, output_notebook
from bokeh.models import LabelSet, Div
import bokeh.layouts
import ipywidgets as widgets
from ipywidgets import Layout
from mintpy.cli import view, tsview, plot_network, plot_transection, plot_coherence_matrix
import mintpy.plot_coherence_matrix
import mintpy.objects.insar_vs_gps
import mintpy.utils
import opensarlab_lib as asfn

path = Path.cwd()
fc = FileChooser(path)
display(fc)

I am getting the error when I try to run the file chooser codes:
[Open Browser Console for more detailed log - Double click to close this message]
Failed to load model class ‘VBoxModel’ from module ‘@jupyter-widgets/controls’
Error: Module @jupyter-widgets/controls, version ^1.5.0 is not registered, however, 2.0.0 is
** at f.loadClass (https://opensciencelab.asf.alaska.edu/lab/smce-prod-opensarlab/user/2022806416/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/134.fe2572ece3b7955c89bb.js?v=fe2572ece3b7955c89bb:1:75054)**
** at f.loadModelClass (https://opensciencelab.asf.alaska.edu/lab/smce-prod-opensarlab/user/2022806416/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/336.0a90bd910629a565bb7e.js?v=0a90bd910629a565bb7e:1:10728)**

Please read and revise your post based on Getting good answers to your questions. Pay particular attention to the the information about making a minimal reproducible example (MRE) and provide one. Specifically, if your issue is with ipyfilechooser then make a new notebook and run only enough code to get the issue you are facing. (I suspect it will be only a few lines; however, you have way too much stuff here making it nowhere near an MRE.) Then supply that code block here formatted to be readable with syntax highlighting and useable. To help with that, see about ‘block code formatting’ and ’ Automatic code styling’ here.

Update:
I think the minimal MRE you may be looking for is below in this demo of using ipyfilechooser where it works with ipywidgets properly installed:

  1. Click ‘launch binder’ here to start a session (or just click here to launch a Jupyter session directly), then when the notebook interface opens, click the Jupyter logo in the upper left, and then change the end of the URL from /tree to /lab. That will change the interface to the JupyterLab interface in this session.

  2. Open a new notebook.

  3. Run in a cell the following:

    %pip install ipyfilechooser
    
  4. Then restart the kernel and refresh the browser page.

  5. Then in a new cell run the following code pared down to the pertinent code from your posted code:

    from ipyfilechooser import FileChooser
    from pathlib import Path
    path = Path.cwd()
    fc = FileChooser(path)
    display(fc)
    
  6. Use the widget to select a file.

  7. Finally, to demonstrate a selection has been made, in the next cell run the following:

    # Then from Usage at https://github.com/crahan/ipyfilechooser#usage
    # Print the selected path, filename, or both
    print(fc.selected_path)
    print(fc.selected_filename)
    print(fc.selected)
    

That should give you a place to see how it works and compare the behavior with your system.

On your system, I suspect after opening Jupyter, you just need to do steps #5 & #6 in a new notebook and I suspect you’ll get the error you reported. Unless restarting things fixed it in the meantime.

1 Like