Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

static files are not recognized when template is set in NB metadata #1464

Open
dfguerrerom opened this issue Apr 22, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@dfguerrerom
Copy link

Description

To set a custom voila template, there are two options:

  • use the voila_configuration args:
    voila --template=my-template
  • set the name of the template in the notebook metadata:
    {
        "voila" : {
            "template" : "my_template"
        }
    }

However, I have found that when I set the template in the notebook metadata, the template_dirs variable doesn't take these changes into account, instead, it uses the voila_configuration args, which causes the start method diverges because it ends up using two different paths.

see (

def setup_template_dirs(self):
)

Apparently, this bug mainly affects the static_paths, causing 404 errors in templates that uses them. I suspect it might also cause other, less noticible issues.

Reproduce

  1. create a simple notebook and set any other default template, for example: classic.
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "voila": {
    "template": "classic"
   }, 
  "language_info": {
   "name": "python",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
  1. launch voila voila --debug test.ipynb
  2. check the logs and notice:

First log shows "using lab template)
image

Second log, (which is created by nbconvert and reads the notebook):

image

Expected behavior

The template should work when it is set in the notebook metadata.

Solution

If there's no time to address this error, I could open a PR but I would need some guidance, I think we could read the notebook in the setup_template_dirs (as a json file) and use the template name?

@dfguerrerom dfguerrerom added the bug Something isn't working label Apr 22, 2024
@dfguerrerom dfguerrerom changed the title template static files are not recognized when template is set in NB metadata Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant