marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
5.39k stars 158 forks source link

Pre-load assets causing error when trying to deploy to Domino Data Labs #1592

Closed KristofPusztai closed 3 weeks ago

KristofPusztai commented 3 weeks ago

Describe the bug

Trying to deploy web app view of a marimo project to the Domino Data Labs App Infrastructure, however, the dev console shows the following errors occurring upon deployment (I have taken out the enterprise domino-url for security):

       GET https://{domino-url}/assets/noise-60BoTA8O.png 404 (Not Found)
66683ea283c10934c5d5abd7/:9 

       GET https://{domino-url}/assets/gradient-yHQUC_QB.png 404 (Not Found)
66683ea283c10934c5d5abd7/:64 

       GET https://{domino-url}/assets/index-BNR0NT9j.css net::ERR_ABORTED 404 (Not Found)
66683ea283c10934c5d5abd7/:13 

       GET https://{domino-url}/assets/PTSans-Regular-CxL0S8W7.ttf net::ERR_ABORTED 404 (Not Found)
66683ea283c10934c5d5abd7/:12 

       GET https://{domino-url}/assets/Lora-VariableFont_wght-B2ootaw-.ttf net::ERR_ABORTED 404 (Not Found)
66683ea283c10934c5d5abd7/:14 

       GET https://{domino-url}/assets/PTSans-Bold-D9fedIX3.ttf net::ERR_ABORTED 404 (Not Found)
66683ea283c10934c5d5abd7/:15 

       GET https://{domino-url}/assets/FiraMono-Regular-BTCkDNvf.ttf net::ERR_ABORTED 404 (Not Found)
66683ea283c10934c5d5abd7/:17 

       GET https://{domino-url}/assets/FiraMono-Bold-CLVRCuM9.ttf net::ERR_ABORTED 404 (Not Found)
66683ea283c10934c5d5abd7/:63 

       GET https://{domino-url}/assets/index-DdSRT048.js net::ERR_ABORTED 404 (Not Found)
66683ea283c10934c5d5abd7/:16 

       GET https://{domino-url}/assets/FiraMono-Medium-DU3aDxX5.ttf net::ERR_ABORTED 404 (Not Found)

I followed the Domino Data Labs Streamlit Web App Tutorial which should be a similar deployment process compared to Marimo, and deployed the web app to host 0.0.0.0 and port 8888 via the CLI arguments:

marimo run --headless --host "0.0.0.0" --port 8888 app.py

It looks like, when trying to load in the web page through Domino, it is looking for these assets in the wrong location:

    <!-- Preload is necessary because we show these images when we disconnect from the server,
    but at that point we cannot load these images from the server -->
    <link rel="preload" href="./assets/gradient-yHQUC_QB.png" as="image" />
    <link rel="preload" href="./assets/noise-60BoTA8O.png" as="image" />
    <!-- Preload the fonts -->
    <link rel="preload" href="./assets/Lora-VariableFont_wght-B2ootaw-.ttf" as="font" crossorigin="anonymous" />
    <link rel="preload" href="./assets/PTSans-Regular-CxL0S8W7.ttf" as="font" crossorigin="anonymous" />
    <link rel="preload" href="./assets/PTSans-Bold-D9fedIX3.ttf" as="font" crossorigin="anonymous" />
    <link rel="preload" href="./assets/FiraMono-Regular-BTCkDNvf.ttf" as="font" crossorigin="anonymous" />
    <link rel="preload" href="./assets/FiraMono-Medium-DU3aDxX5.ttf" as="font" crossorigin="anonymous" />
    <link rel="preload" href="./assets/FiraMono-Bold-CLVRCuM9.ttf" as="font" crossorigin="anonymous" />

These errors do not happen when running locally, only when trying to deploy through Domino.

Environment

{ "marimo": "0.6.16", "OS": "Linux", "OS Version": "5.14.0-284.34.1.el9_2.x86_64", "Processor": "x86_64", "Python Version": "3.10.14", "Binaries": { "Browser": "--", "Node": "v12.16.3" }, "Requirements": { "click": "8.1.7", "importlib-resources": "missing", "jedi": "0.19.1", "markdown": "3.6", "pymdown-extensions": "10.8.1", "pygments": "2.18.0", "tomlkit": "0.12.5", "uvicorn": "0.30.1", "starlette": "0.37.2", "websockets": "12.0", "typing-extensions": "4.11.0", "black": "24.4.2" } }

Code to reproduce

No response

dmadisetti commented 3 weeks ago

Quick suggestion. Try setting symlinks to be true in

[server]                                                                                                                                                                                                                      
follow_symlink = true

I'm not sure how their servers are set up, but I've had similar issues with other build / deploy tools.

Be sure to undo this option if it doesn't work

KristofPusztai commented 3 weeks ago

What file is that option in? I'm assuming it's the .marimo.toml one?

I've tried placing that in the toml file but does not seem to have an effect, I might not be placing this in the correct spot though, locally I see that the toml file is located in the same directory as the other user-level config's such as .bash_profile etc... so I tried placing in a similar spot in the deployment environment

Update: Looks like a similar issue occurs for Dash 2.x dashboards that is fixed by specifying the pathname prefix so I'm positive it has to do with those asset href paths being relative.

mscolnick commented 3 weeks ago

@KristofPusztai , can you verify <base href="/"> is in the return HTML?

https://{domino-url}/assets/noise-60BoTA8O.png is the correct path. you can also see this running marimo run locally and seeing the paths

KristofPusztai commented 3 weeks ago

Yes, that is in the base HTML! I see that running locally it has the localhost:port/assets/... path which makes sense, but when running on Domino deployment, I don't think https://{domino-url}/assets/... makes sense because the app URL that Domino directs me to when deploying is in the form {domino-url}/modelproducts/app-id so shouldn't the correct path for these assets be {domino-url}/modelproducts/app-id/assets/noise-60BoTA8O.png? Otherwise it wouldn't be throwing these errors and would load properly?

mscolnick commented 3 weeks ago

Oh - that wasn't clear from your first message since you removed the URL. You will need to use --base-url in marimo run to manually set the base url

KristofPusztai commented 3 weeks ago

Ah okay will give that a try, thank you @mscolnick @dmadisetti

Update: After trying to update the --base-url with the proper URL, it is now throwing a different error entirely in that it is unable to find the base HTML page to begin with, I've tried several different base URL's based on the Domino Data Labs App URL documentation but none of them work and all throw the same error of being unable to locate the base HTML resource.

On further inspection, when running without setting the --base-url parameter, I just can't find the assets directory that should be present:

localhost run with asset directory clearly visible:

Screenshot 2024-06-12 at 10 26 06 AM

Deployment directory structure missing assets:

Screenshot 2024-06-12 at 10 29 32 AM

Might have to be something I need to work out with the Domino team and how their deployment process is working under the hood

mscolnick commented 3 weeks ago

Which of these 3 urls are you using? And what are you setting the base-url too (feel free to use their placeholders)

App URLs There are essentially 3 different URLs you can use to access an App:

1) The official app URL:http:///modelproducts/ This URL will not ever change for an app. Going to this URL in a browser gives you your app with a Domino banner at the top.

2) The "static" internal app URL:http:///u///app Like the first URL, this URL will not change if you stop and start the app, but it will change if you rename the project or change ownership, since it has the project owner and project name in the URL.

3) The current session URL:http://///r/notebookSession/ This URL will change every time you start and stop the app.

KristofPusztai commented 3 weeks ago

@mscolnick Worked with one of the members of the Domino team supporting our enterprise instance, turns out issue was on their side, thank you for the help though!