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

Sidebar doens't render if cells block on initialization #1386

Open
mrdobalina2k opened this issue May 15, 2024 · 3 comments
Open

Sidebar doens't render if cells block on initialization #1386

mrdobalina2k opened this issue May 15, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@mrdobalina2k
Copy link

mrdobalina2k commented May 15, 2024

Describe the bug

If a/some cell(s) in the marimo app take a long time to initialize (could be some database transfer, file reading etc), then, for whatever reason, the sidebar doesn't show up when running marimo run app.py.

Environment

{
"marimo": "0.5.2",
"OS": "Windows",
"OS Version": "11",
"Processor": "Intel64 Family 6 Model 126 Stepping 5, GenuineIntel",
"Python Version": "3.12.2",
"Binaries": {
"Browser": "123.0.6312.123",
"Node": "v14.16.0"
},
"Requirements": {
"click": "8.1.7",
"importlib-resources": "missing",
"jedi": "0.19.1",
"markdown": "3.6",
"pymdown-extensions": "10.7.1",
"pygments": "2.17.2",
"tomlkit": "0.12.4",
"uvicorn": "0.29.0",
"starlette": "0.37.2",
"websocket": "missing",
"typing-extensions": "4.9.0",
"black": "24.3.0"
}
}

Code to reproduce

here's a minimal repro, where one cell sleeps for 2 seconds to emulate a blocking thread (like an i/o operation)

 
import marimo
 
__generated_with = "0.5.2"
app = marimo.App(layout_file="layouts/sidebar.grid.json")
 
 
@app.cell
def __():
    import marimo as mo
    from time import sleep
    return mo, sleep
 
 
@app.cell
def __(mo):
    mo.sidebar(
        [
            mo.md("World"),
            mo.ui.switch()
 
        ]
    )
    return
 
 
@app.cell
def __(mo, sleep):
    sleep(2) # emulate blocking
    mo.md("Hi")
    return
 
 
if __name__ == "__main__":
    app.run()
@mrdobalina2k mrdobalina2k added the bug Something isn't working label May 15, 2024
@mscolnick
Copy link
Contributor

mscolnick commented May 15, 2024

what happens if you move the sidebar creation to the first cell? it's likely that the blocking cell is run first, since its a tie between the second and third cell, we don't force the sidebar to render before the other.

we do plan on adding parallel execution at some point, but in the mean time, can you force the sidebar to be first by forcing it in the dependency graph.

e.g.

# Cell 2
sidebar = mo.siderbar(...)
sidebar

# Other cells
sidebar
sleep(2)
mo.md("hi")

@mrdobalina2k
Copy link
Author

It may be a bit difficult in practice, since apps may have many cells, and knowing which order they are executed in should be the purpose of marimo, and not the user's to guess. However, I still don't understand why the sidebar doesn't eventually render, even if cell 3 is executed before cell 2.

@mscolnick
Copy link
Contributor

However, I still don't understand why the sidebar doesn't eventually render, even if cell 3 is executed before cell 2.

@mrdobalina2k is this while editing. this is something i don't experience. i see it show after 2 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants