-
Notifications
You must be signed in to change notification settings - Fork 316
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
Recommendations for including data in WASM notebook #3194
Comments
+1 Persistent cache loading over network would be the ideal way to do this. What's your current WASM export workflow? Are you using wasm export, islands, or mkdocs? |
I was just trying to use direct command line wasm export. Have in the past used static html exports as a way to share notebook outputs/results with non-technical users as a report, without them having to install anything. Github's direct display of notebook outputs is one advantage of ipynb format (maybe the only one?) that is still keeping some team members from marimo (other than just the usual inertia), because there's no workflow at all needed. But allowing those non-technical users to easily have interactive content via wasm export would be amazing and worth some amount of workflow change My ideal would probably be having some way to package everything into a single file (embedding everything as base64 strings, i guess?). That seems likely to be infeasible, though, so an output dir that can be zipped and shared or otherwise easily deployed somewhere would be alright too. Generally I'm doing dev on a local laptop, so wouldn't want to serve |
@dmadisetti Can you share a bit more about what you have in mind regarding manually loading a file over the network? What's the best way to detect whether we're running in WASM if I want to load data differently depending on environment (or skip some WASM -incompatible steps entirely) ? The overarching need behind this issue is something I've found is a very common pattern: i do some complex/heavy analysis in a notebook and then also have code to visualize or interact with the results. The latter portion i want to share, but want it running off a snapshot of the earlier analysis results Currently my options seem to be:
Not sure this is the place to discuss it, but would be great to have more explicit support (or documentation, if there's already a path I'm not using?) for this workflow |
So here are the options as I see them with cache:
Outside of cache, wasm could leverage the virtual filesystem
As is, I don't think this is a documentation issue so much as a missing feature |
Seems there are kinda two parts to this:
Re: 2. -- you'd mentioned further up in the thread that "manually loading a file over the network is the current best option" - that sounded to me like you had a specific (albeit more manual) workaround in mind that would work today? |
@dmadisetti I do think overall you're right that it sounds like this is certainly at least as much a feature request as a docs issue (probably more so). Unfortunately I don't seem to be able to change the tags (i think the issue template auto-adds them when creating)? |
I have some thoughts, but not fully fleshed out on which approach is the best, nor which we want to recommend at the moment.
|
Ah, didn't register that i could drop That's awesome as a workaround! Assuming that if I'm using cookie-based or HTTP basic auth for the notebook, then imagine putting the data behind the same auth scheme should work, right? Haven't actually tested this yet, but can't see why not (famous last words...) One remaining question is: what's the best way to detect whether we're running in WASM if I want to load data differently depending on environment (or skip some WASM-incompatible steps entirely) ? I guess just try loading the local file, catch the This is def workable as a step in the right direction. But still not ideal that the whole computation needs to be redone -- for heavy computations that could take quite a while in WASM. If I also deploy/serve the |
You can create a util int your notebooks: def is_wasm() -> bool:
return "pyodide" in sys.modules I don't expect |
Documentation is
Explain in Detail
The most common pattern of my notebooks is to read a file (CSV or JSON) into a pandas DF and then do some manipulations. When exporting WASM this fails with FileNotFound errors
Not so surprising that marimo has no concept of what external files I'm depending on. Is there a recommended path for how to include data along with the notebook when publishing? This seems like a pretty common need, but not seeing any mention of this in the export docs https://docs.marimo.io/guides/exporting.html#export-to-wasm-powered-html
Your Suggestion for Changes
It would be amazing if this just worked out of the box (by watching for open files and auto-including them as deps, i guess?), but just having some recommended way to do this (even with extra work) would be nice. Maybe there's something I should be doing with Marimo's built-in caching, for instance?
Did try just wrapping with a simple persistent cache:
But seems that the cache doesn't get included in the WASM export assets, so it still fails trying to open the file (same error as with no cache):
The text was updated successfully, but these errors were encountered: