-
Notifications
You must be signed in to change notification settings - Fork 166
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
Convert to Jupyter notebook or Python script #717
Comments
Hey, thanks for the suggestion. Conversion from a marimo notebook to a Jupyter notebook may not work well -- Jupyter doesn't support any of the marimo UI elements or library functions, and it also doesn't support out of order execution. Conversion to a pure Python script is something we could conceivably do in the future. |
Even if we could lose some features it will be "fair" that Marimo try to do it's best to convert into Jupyter notebook. round-trip conversion between Jupyter notebook and Marimo notebook wil lead to some features loss... that's life! You said that Jupyter doesn't support out of order execution We can consider that the export should consider one cell (maybe first, maybe latest a "input" for data flow). Moreover there is not only on kernel for Jupyter. Most people use ipykernel (see https://docs.jupyter.org/en/latest/projects/kernels.html ) but there is also ipyflow https://github.com/ipyflow/ipyflow which is a reactive kernel for Jupyter. |
hey @King-of-Infinite-Space - we haven't added "export to Jupyter", but we do have "export to a flat Python script" # prints to stdout
marimo export script notebook.py > notebook.script.py
# writes to the outfile
marimo export script notebook.py --output notebook.script.py
# writes to the outfile and watch notebook.py for changes
marimo export script notebook.py --watch --output notebook.script.py |
I want to add that with export to markdown you can also do # prints to stdout
marimo export md notebook.py > notebook.qmd
# writes to jupyter notebook, maybe with a bit of post processing (replace .python.marimo with just python)
quarto convert notebook.qmd |
Thanks for following up. I noticed that the generated python script uses # %%
import numpy as np
# %%
print(np.exp(1))
Then I can use |
@King-of-Infinite-Space , I have a PR out implementing your suggestion (thank you!). |
I am going to close this issue given #1350, since you can now export as a Python script that is Jupyter compatible which can be run in vscode (or other jupyter magic-comment supporting IDEs) |
Description
Currently
marimo convert
converts Jupyter notebook to marimo notebook but can't convert it back.Also, although marimo notebooks can be executed as scripts, it is still useful to export it to a python script (rather than having the code wrapped in functions). Jupyter supports exporting as python script through
nbconvert
.These features would make it easier for people to integrate marimo into their existing workflows. Thanks!
Suggested solution
Support
marimo convert your_notebook.py > your_notebook.ipynb
command.Add "Export to Python script" option.
Alternative
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: