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

New voila labextension path breaks custom setup #1506

Closed
martinRenou opened this issue Oct 23, 2024 · 10 comments
Closed

New voila labextension path breaks custom setup #1506

martinRenou opened this issue Oct 23, 2024 · 10 comments

Comments

@martinRenou
Copy link
Member

          my `page_config_hook` doesn't work anymore after this PR....

Screenshot from 2024-10-23 10-19-18

my previous logic was only adding the labextensions that were available in the virtual environment that I wanted to use... now I have refactored to also include the voila extensions... however, there's nothing rendered in my voila page.

my federated extensions are:

        "federated_extensions": [
            {
                "name": "jupyterlab-plotly",
                "load": "static/remoteEntry.41e12212782f05d7d17b.js",
                "extension": "./extension",
                "mimeExtension": "./mimeExtension",
                "entrypoints": None,
            },
            {
                "name": "jupyter-vue",
                "load": "static/remoteEntry.f993df579401788f32ef.js",
                "extension": "./extension",
                "entrypoints": None,
            },
            {
                "name": "jupyter-vuetify",
                "load": "static/remoteEntry.cba680c7ed013f0591de.js",
                "extension": "./extension",
                "entrypoints": None,
            },
            {
                "name": "jupyter-leaflet",
                "load": "static/remoteEntry.a83217134ba8dacb85fc.js",
                "extension": "./extension",
                "entrypoints": None,
            },
            {
                "name": "jupyterlab_pygments",
                "load": "static/remoteEntry.5cbb9d2323598fbda535.js",
                "extension": "./extension",
                "style": "./style",
                "entrypoints": None,
            },
            {
                "name": "@jupyter-widgets/jupyterlab-manager",
                "load": "static/remoteEntry.e4ff09401a2f575928c0.js",
                "extension": "./extension",
                "entrypoints": None,
            },
            {
                "name": "@jupyterhub/jupyter-server-proxy",
                "load": "static/remoteEntry.569b1096d01998b85e34.js",
                "extension": "./extension",
                "entrypoints": None,
            },
            {
                "name": "@voila-dashboards/widgets-manager8",
                "load": "static/remoteEntry.958dac8c7410b5fcc9ee.js",
                "extension": "./extension",
                "entrypoints": None,
            },
        ],

Is there anything else I've been missing?

Originally posted by @dfguerrerom in #1501 (comment)

@martinRenou
Copy link
Member Author

Thanks for commenting @dfguerrerom !

Would you be able to show the very beginning of errors in the JavaScript console?

Also can you very the @voila-dashboards/widgets-manager8 extension is properly loaded?

@dfguerrerom
Copy link
Contributor

thanks for answering... I think it cannot activate the widget-manager8:

image

@trungleduc
Copy link
Member

trungleduc commented Oct 23, 2024

could you post a minimal reproduction of your custom hook so we can debug it locally?

@martinRenou
Copy link
Member Author

is /api/apps/labextensions/ a custom endpoint of yours? It seems /api/apps/labextensions/basin-rivers/@voila-dashboards/widgets-manager8/static/*.js is not answering back with the proper thing

@dfguerrerom
Copy link
Contributor

I look for the path of the notebook to get the name of the virtual environment where I need to take the extensions from and (just for testing) I have added the voila labextensions... the returned url is the endpoint where my server serves the files.

def get_app_data(base_url: str, app_name: str) -> Tuple[List[str], str]:
    """Get the module data"""

    # To the logic to get the app data
    jupyter_url = f"/api/apps/labextensions/{app_name}/"
    jupyter_paths = [
        f"/usr/local/share/jupyter/kernels/venv-{app_name}/venv/share/jupyter/labextensions/"
    ] + ["/usr/local/share/jupyter/voila/labextensions"]

    return jupyter_paths, jupyter_url


def get_app_name(notebook_path: str):
    """Extract the app name from the notebook path"""

    return notebook_path.split("apps/")[1].split("/")[0]


def page_config_hook(
    page_config: dict,
    base_url,
    settings,
    log,
    voila_configuration: VoilaConfiguration,
    notebook_path,
):

    app_name = get_app_name(notebook_path)
    app_extensions_paths, app_extensions_url = get_app_data(base_url, app_name)
    page_config["fullLabextensionsUrl"] = app_extensions_url

    recursive_update(
        page_config,
        gpc(app_extensions_paths, logger=log),
    )
    disabled_extensions = [
        "@voila-dashboards/jupyterlab-preview",
        "@jupyter/collaboration-extension",
    ]
    disabled_extensions.extend(page_config.get("disabledExtensions", []))

    required_extensions = []
    federated_extensions = deepcopy(page_config["federated_extensions"])

    filtered_extensions = filter_extension(
        federated_extensions=federated_extensions,
        disabled_extensions=disabled_extensions,
        required_extensions=required_extensions,
        extension_allowlist=voila_configuration.extension_allowlist,
        extension_denylist=voila_configuration.extension_denylist,
    )

    extensions = maybe_inject_widgets_manager_extension(
        filtered_extensions, app_extensions_paths
    )

    page_config["federated_extensions"] = extensions

    return page_config


c.VoilaConfiguration.page_config_hook = page_config_hook

@dfguerrerom
Copy link
Contributor

is /api/apps/labextensions/ a custom endpoint of yours? It seems /api/apps/labextensions/basin-rivers/@voila-dashboards/widgets-manager8/static/*.js is not answering back with the proper thing

True, it doesn't find that file because voila is not installed in my kernel, I was using the system voila paths... but probably, installing voila in my kernel will cause problems if the system version changes...

@dfguerrerom
Copy link
Contributor

I managed to serve the file correctly and it works, can we close it? the issue was on my side

@martinRenou
Copy link
Member Author

Happy you managed to fix it!

the issue was on my side

Do you think we made a mistake making that release a patch release? I'm wondering if we should expect more issues like this one to pop up.

@martinRenou
Copy link
Member Author

Closing as fixed for now

@dfguerrerom
Copy link
Contributor

dfguerrerom commented Oct 23, 2024

Do you think we made a mistake making that release a patch release?

well... that one was my mistake, my PR was on the same release and I was applying the logic of my branch... both were in the same patch.
However, now my case of use will still have to deal with another path to look for...

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

No branches or pull requests

3 participants