Holoviews not updating Image on renku environment


I have a project with a datafile containing images which I would like to peek through using holoviews.Image. When I run the script locally I can interactively see different images within the dataset. The updating function is however called only once when I try running it on renku environment within a jupyterlab notebook.
I tried running /opt/conda/bin/jupyter labextension install @pyviz/jupyterlab_pyviz ## allows for holoview animations on jupyter notebook on renku environment as I was trying to resolve on my own, but it didn’t help.

Here is a minimal script to reproduce the issue:

import h5py, os, holoviews as hv, requests, pickle, tarfile

url = 'https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz'
r = requests.get(url, allow_redirects=True)
fname_z = 'tmp.tar.gz'
open(fname_z, 'wb').write(r.content)
tar = tarfile.open(fname_z, "r:gz")

fname = 'cifar-10-batches-py/data_batch_1'
with open(fname, 'rb') as fo:
    d_data = pickle.load(fo, encoding='bytes')
num_images = d_data[b'data'].shape[0]
fs = 500 # frame size
def select_slice(s):
    im = d_data[b'data'][s].reshape((3, 32,32)).transpose((1,2,0))
    return hv.Image(im).options(cmap='gray', frame_width=fs, frame_height=fs)

dmap = hv.DynamicMap(select_slice, kdims=['s']).redim.values(s=range(num_images))


Edit: On my project, I am interested in reading a single image from file interactively at a time (to circumvent loading whole dataset into memory). So reading file within select_slice(s) looks like the following:

with h5py.File(fname, 'r') as fh:
    im = fh['key_for_images'][s,...]
1 Like

@firat it seems that it works when holoviews is installed from the pyviz conda channel. Otherwise by just installing with pip through the requirements.txt file did not work.

If you look at this diff you will see the changes you need to make to make it work. The changes that are relevant are in the environment.yaml file and the Dockerfile.

Also if you want to try the test project I started, it is here

thanks, that seems to have solved it!