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

Reload the notebook when the file changes on disk #2675

Closed
ibash opened this issue Oct 19, 2024 · 7 comments · Fixed by #3437
Closed

Reload the notebook when the file changes on disk #2675

ibash opened this issue Oct 19, 2024 · 7 comments · Fixed by #3437
Labels
enhancement New feature or request
Milestone

Comments

@ibash
Copy link

ibash commented Oct 19, 2024

Description

Neovim is my editor. When I edit a marimo notebook file and save it in vim, I would like marimo to reload with my changes.

Note that I am not editing external modules, but the marimo notebook directly.

It's not necessary to auto-run cells. I'm happy to run them manually.

Note that I think listening to file changes on disk is better than a direct neovim integration, because listening to file changes would allow integration with other tools.

Related to #998, however only module reloading was implemented.

Suggested solution

Watch file changes to the notebook file on disk. When a change is detected update cells and mark which cells are outdated.

Alternative

No response

Additional context

No response

@ibash ibash added the enhancement New feature or request label Oct 19, 2024
@gabrielgrant
Copy link
Contributor

gabrielgrant commented Nov 15, 2024

yes, big benefit of marimo being just python is that it easily integrates with other tooling and normal code editing environment. In addition to being nice to edit with a normal code editor, this also means that a notebook may sometimes be automatically edited by these other tools (eg when moving or changing a symbol name in an imported file). In these cases it seems especially important to pick up the changes, rather than just silently overwrite (which seems to be the default behavior today?)

@gaardhus
Copy link

gaardhus commented Dec 2, 2024

Related to #1511

@dmadisetti
Copy link
Collaborator

dmadisetti commented Dec 2, 2024

FWIW #1511 is not fully related, that's file changes in general- not the working notebooks


Reloading the notebook when file changes is not a great solution, as edit changes are decoupled from the backend- so there's the potential to have inconsistent state.

The real solution is to build a plugin such that marimo frontend, backend, and editor are in sync. The VsCode Plugin does this already: https://github.com/marimo-team/vscode-marimo

Something that directly follows the VsCode plugin could work.

Related

I wrote this proposal: marimo-team/meps#6
to allow for the marimo server to be the canonical edit source, which would allow for features like live editing with multiple users.
I use neovim too, and my plan was to go from this to an integrated plugin.

I just didn't want to do the work twice (make a vim plugin like the VSCode Plugin, get multiplayer working, and then change the plugin to work with that).

Some progress on the proposal front has been made. The kiosk mode for instance, which would be great for an interim vim plugin.

@mscolnick mscolnick added this to the marimo 1.0.0 milestone Dec 6, 2024
@gabrielgrant
Copy link
Contributor

gabrielgrant commented Dec 16, 2024

@dmadisetti you mention that the VSCode plugin does this. Can you explain a bit more how that works? I'd love to be able to just edit the .py file in VSCode and have a kiosk mode updated with the granular (cell-level) execution, but afaict that doesn't work today? this could be automatically on save, or the same way it works when re-running in the notebook interface where save and run are separate (ie cell outputs can be "dirty")

@dmadisetti
Copy link
Collaborator

@gabrielgrant That should work today?

The VSCode plugin is very similar to the jupyter notebook experience

Mind opening an issue in https://github.com/marimo-team/vscode-marimo/issues if the problem persists?

@gabrielgrant
Copy link
Contributor

gabrielgrant commented Dec 17, 2024

I haven't been able to use the VScode plugin notebook experience (seem to be having the same issue as marimo-team/vscode-marimo#61 ), so what I was talking about was just editing the .py file directly. Are you saying that is expected to stay in sync with what I'm seeing in the browser? It doesn't seem to -- even after refreshing the notebook in the browser, new changes added to the .py file don't seem to appear

@dmadisetti
Copy link
Collaborator

Hmm, it may be that the plugin is currently broken. What is supposed to happen is very similar to the jupyter experience (none of the generated _ functions should be present, just cells).

Just editing a file will not keep it in sync, only through the plugin interface that seems to currently have an issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants