marimo
marimo copied to clipboard
reload app when file updated externally
Description
I have a marimo app running on a computer and I want to be able to replace the underlying app.py notebook and have the existing "marimo run" instance notice the updated file and reload the connected browsers (a single one in my case).
The use case is a computer used as a wall mounted dashboard where I want to update the dashboard ocasionally.
Alternatively I can kill the existing "marimo run" process but then I need to restart the client since there is no refresh on it either (it shows the "blood spots" background of a killed kernel, but does not connect when "marimo app" is run listening on the same port again).
Suggested solution
use inotify (linux specific, can poll or use similar API on other platforms) to check updates to the notebook. On update, rerun the notebook (wholesale, do not attempt to discover the changed cells and only run them - that would be cool but also potentially wrong) and notify all clients to reload as well. This can be behind a flag, i.e.
marimo app --reload-on-update
Alternative
Restarting the "marimo app" process and the corresponding browser tab.
Additional context
No response
This sounds like a useful feature. (I would vote --watch
as the flag)
@alefminus, is it just the the file running that you want reloaded? or would you potentially want to include downstream files (e.g. a csv, log file, etc). Although, you could probably put a reload/refresh on those files within your marimo notebook itself.
In the meantime, curious if this would work on Linux (haven't tested since I'm on a Mac)
while inotifywait -e close_write app.py; marimo run app.py; done
That should work fine. The second part, reloading the client (i.e. client notices websocket died, goes into reconnection loop, then connection works, reinits) is the part I'm less inclined to write :)
On Wed, Jan 17, 2024 at 4:36 PM Myles Scolnick @.***> wrote:
This sounds like a useful feature. (I would vote --watch as the flag)
@alefminus https://github.com/alefminus, is it just the the file running that you want reloaded? or would you potentially want to include downstream files (e.g. a csv, log file, etc). Although, you could probably put a reload/refresh on those files within your marimo notebook itself.
In the meantime, curious if this would work on Linux (haven't tested since I'm on a Mac) while inotifywait -e close_write app.py; marimo run app.py; done
— Reply to this email directly, view it on GitHub https://github.com/marimo-team/marimo/issues/595#issuecomment-1895942740, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYWFZPAW3JD6U2FMGZB76MDYO7OXTAVCNFSM6AAAAABB6LGPF2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOJVHE2DENZUGA . You are receiving this because you were mentioned.Message ID: @.***>
-- Alon Levy Software Developer Greenvibe 054-2395317
cool! thanks a lot, I'll check it soon. With tests and everything too :)
I've opened #773 after testing, otherwise works great, thanks!