voila-dashboards / voici

Voici turns any Jupyter Notebook into a static web application
https://voici.readthedocs.io/
Other
143 stars 8 forks source link

Demo not working #115

Closed parthi2929 closed 2 months ago

parthi2929 commented 2 months ago

Description

When I try to run voici-demo, creating a new repo as here, it fails for demo.ipynb.

image

Reproduce

  1. Create new repo from voice-demo
  2. Trigger Github actions
  3. Go to your github page of this repo

Expected behavior

The page should be rendered fine.

parthi2929 commented 2 months ago

Also could be helpful, if possible to document what build-environment file is for, while we already have environment file. I tried packages for my notebook in both files, still failed, but once demo is fixed I might have more clues to fix mine here which is unable to read relationships.csv file (so I am also waiting to see if demo reads indicators.csv file fine.

martinRenou commented 2 months ago

if possible to document what build-environment file is for, while we already have environment file. I tried packages for my notebook in both files

The build-environment file is the build environment spec: the environment from which you build the voici dashboard. You usually won't update it much unless you want a specific version of jupyterlite or voici.

The environment one is the one specifying the runtime package for your notebook, this is where you'll put bqplot.

When I run your example, I see different issues than you (bqplot seems properly installed, you are missing more runtime dependencies it seems):

Screenshot from 2024-04-17 09-20-16

I believe you may be hitting cache, a private window may help you.

martinRenou commented 2 months ago

Closing as answered, but feel free to continue the discussion if needed!

parthi2929 commented 2 months ago

@martinRenou I do not know what happened but now demo.ipynb works, but my Sujan 03.ipynb not working, even with pyvis included in environment.yml (this is also reason, I tried adding also in build-environemnt.yml earlier to see if that could help)..

What do you mean by hitting a cache here, as its github actions, nothing in my local machine?

martinRenou commented 2 months ago

What do you mean by hitting a cache here, as its github actions, nothing in my local machine?

Your browser caches data all the time (that way, coming to the same page multiple times will not re-download those data).

The problem with this and jupyterlite/voici is that sometimes the cached data is outdated (your browser cached a kernel with a set of Python packages that is not containing everything you want).

You can either clean the browser cache, or visit the page with a private window (which does not make use of caching).

parthi2929 commented 2 months ago

I am still getting error, but this time, that template.html file not found. Initially of course I thought I am not providing that file, but I did not get this error locally in my system. The respective notebook is here..

If working in my local env Jupyter lab but not in voici, I am not able to debug why..

parthi2929 commented 2 months ago

To add more context, when pyvis installed, the template.html should be found in below relative path in python environment where the pyvis package is installed.. (at least that is how it is in my conda env)

image

I tried the following code, in the beginning of notebook, which prints that template.html does indeed exist for my local system in my conda env..

import importlib.resources as pkg_resources
from pathlib import Path

def find_template_in_package(package, filename="template.html"):
    # Access the package's resources
    package_files = pkg_resources.files(package)
    # Convert to a Path object to use pathlib operations
    directory = Path(package_files)
    # Search recursively for the file
    for path in directory.rglob(filename):
        return path
    return None

# Package from which to find the file
package = __import__('pyvis')

# Search for the 'template.html' file
template_path = find_template_in_package(package)

if template_path:
    print(f"'template.html' found at: {template_path}")
else:
    print("No 'template.html' file found in the pyvis package.")

image

But when we access it online, voici renders that its not found.. image

This indicates, that some how this template.html (and may be some more assets like this?) not becoming available via voici..

Kindly help..

martinRenou commented 2 months ago

Thank you for the detailed issue, this is really useful!

I think empack is filtering out the HTML files from pyvis, https://github.com/emscripten-forge/empack/pull/96 should fix this!