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

Verify that the custom Emscripten FS from JupyterLite can be used #3

Closed
martinRenou opened this issue Feb 20, 2023 · 7 comments · Fixed by #59
Closed

Verify that the custom Emscripten FS from JupyterLite can be used #3

martinRenou opened this issue Feb 20, 2023 · 7 comments · Fixed by #59
Labels
enhancement New feature or request

Comments

@martinRenou
Copy link
Member

Problem

JupyterLite can provide access to local files using a custom Emscripten File System, we should check that Voilite works properly with it

@martinRenou martinRenou added the enhancement New feature or request label Feb 20, 2023
@martinRenou martinRenou transferred this issue from voila-dashboards/voila Feb 21, 2023
@martinRenou martinRenou changed the title Voilite: Verify that the custom Emscripten FS from JupyterLite can be used Verify that the custom Emscripten FS from JupyterLite can be used Feb 21, 2023
@jtpio
Copy link
Member

jtpio commented Mar 13, 2023

Just checked with Voici 0.2.0 via the Voici Demo and it appears the Service Worker can't be found.

This looks like an issue with the base URL:

image

@jtpio
Copy link
Member

jtpio commented Apr 12, 2023

Checking with the demo folder, it appears that the baseUrl in the initial jupyter-config-data is empty:

image

But manually setting "baseUrl": "/" in the generated HTML seems to do the trick:

image

@jtpio
Copy link
Member

jtpio commented Apr 12, 2023

That empty string looks unexpected since there the baseUrl is currently set to / here:

voici/voici/addon.py

Lines 142 to 145 in 8069c95

# TODO Update Voila templates so we don't need this,
# the following monkey patch will not work if lite is served
# in a sub directory
page_config["baseUrl"] = "/"

@jtpio
Copy link
Member

jtpio commented Apr 12, 2023

As a comparison the themesUrl defined here:

page_config[
"themesUrl"
] = f"../../../{'../' * len(relative_path.parts)}build/themes"

Appears to be defined correctly on the page:

image

@martinRenou do you know if the page config baseUrl might be overridden at some other point during the export, maybe in an upstream exporter?

@martinRenou
Copy link
Member Author

@martinRenou do you know if the page config baseUrl might be overridden at some other point during the export, maybe in an upstream exported?

It's not impossible that Voila itself overrides the baseUrl?

@jtpio
Copy link
Member

jtpio commented Apr 12, 2023

Right, I'm not exactly sure how the empty baseUrl is ends up on the page:

image

However, this seems to be triggering the following code path in JupyterLab PageConfig:

https://github.com/jupyterlab/jupyterlab/blob/25658adabce206725cafe42161181ba43ae87bcd/packages/coreutils/src/pageconfig.ts#L37-L39

export function getOption(name: string): string {
    if (configData) {
      return configData[name] || getBodyData(name);
    }

configData[name] would be "", so the || triggers a call to getBodyData. With getBodyData getting the value from the body data attribute:

image

Which voila defines here: https://github.com/voila-dashboards/voila/blob/0f4cc5360ff387eeaf7e647cee712b2ce08d573a/share/jupyter/voila/templates/base/page.html#L23

 <body data-base-url="{{ base_url }}voila/">

Most likely that's why there is a voila/ part in the URL:

image

@jtpio
Copy link
Member

jtpio commented Apr 12, 2023

Digging a bit more, Voila seems to be updating the page config baseUrl with the one from the resources in the template: https://github.com/voila-dashboards/voila/blob/0f4cc5360ff387eeaf7e647cee712b2ce08d573a/share/jupyter/voila/templates/lab/index.html.j2#L81

{# Set a dummy variable - we just want the side effect of the update. #}
{% set _ = page_config_full.update(baseUrl=resources.base_url, kernelId=kernel_id) %}

So if resources.base_url is empty, that could explain why we always get "baseUrl": "".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants