Get help from the marimo community

Updated 2 weeks ago

Basic Interactivity in Static HTML

I am trying to make it so I can export a report I built in Marimo to static HTML so that the report is pre-computed and can be displayed on a separate Marimo application. Part of this report goes into a deep dive analysis of specific variables. Currently the report runs on the app so its easy enough to use the dropdown to choose which variable to dive into.

The report however, is very compute intensive, and it would be nice to run the report beforehand and just show the HTML from it in the app. However, in static HTML, the dropdown doesn't work due to it requiring some python code to run. I am trying to find an adequate workaround for this. I attempted to use tabs, which actually worked magnificently, except for I have too many tabs to fit on the screen. The carousel also almost works, however it is not user friendly to have to scroll down in the carousel to see the full deep dive.

I havent messed too much with WASM stuff. Not sure if you can run the WASM html inside another Marimo app? My hope is that the main Marimo app just shows a list of reports that have been generated and can load the selected HTML report. So I am not sure if that is possible with the WASM export. Something that looks like the dropdown but acts like the tabs would be ideal at this point. I know I could generate a large accordion if needed as well, I just don't love the way it looks as much as something like the tabs. But thought I would check and see if there was a more elegant solution to this?

Thanks!
M
n
8 comments
We don't really have much to support this. We have though about using persistant_cache plus wasm to make pre-computed applications.

basically for things that don't work in wasm (because of package limitations, certain network requests, size limits) you could pre-compute all variartions of how the use the app and then when users do interact in wasm, we would get all cache hits. and avoid re-running cells that may not work.

this approach could be really fragile and complex, so unsure if we will support it.

You could get pretty close to it yourself though if you'd like with wasm:

Plain Text
if is_wasm():
   df = pl.read_csv("s3://my_cache//..)
else:
   df = make_expensive_computation()


not sure if its only dataframes, but that could get you pretty far.

Plain Text
def is_wasm():
  return 'pyodide' in sys.modules
@Myles Scolnick is it possible to display a marimo notebook html in another marimo notebook? I am trying to do something like this:
Plain Text
from pathlib import Path
import marimo as mo

mo.Html(Path("path/to/file.html").read_text())


But it is showing a blank output. The file was another marimo notebook I downloaded as HTML.
For reference.
Attachment
Screenshot_2024-12-23_at_11.33.39_AM.png
Not sure if it’s possible, I haven’t tried. Maybe “mo.iframe” would be better
Thanks I’ll see if IFrames work. If they don’t, would this be something I could open a feature request for? Or is it not something that interesting for you to support?
So IFrames worked kinda. But it defaults to the code view. Is there a way to default to the run view?
Scratch that. I just downloaded it the wrong way.
IFrames indeed work thank you!
Add a reply
Sign up and join the conversation on Discord