marimo
marimo copied to clipboard
Automatically import marimo as mo on markdown fail?
Describe the bug
Environment
{
"marimo": "0.4.0",
"OS": "Windows",
"OS Version": "10",
"Processor": "Intel64 Family 6 Model 106 Stepping 6, GenuineIntel",
"Python Version": "3.10.9",
"Binaries": {
"Browser": "111.0.5563.147",
"Node": "--"
},
"Requirements": {
"click": "8.1.7",
"importlib-resources": "missing",
"jedi": "0.19.1",
"markdown": "3.5.1",
"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.7.1",
"black": "23.12.0"
}
}
Code to reproduce
No response
You'll need to import marimo as mo first. Markdown is written with Python in marimo (mo.md).
Ah, excellent! From an engineering perspective, it makes a lot of sense to have all cells be Python.
- I expected that when I activated "view as markdown", the cell would just need markdown in it, and not depend on other Python state. Might just be habit from Jupyter.
- To make this more user-friendly, we could:
- Print a more user-friendly error (i.e. you still need to import mo), or
- Automatically import marimo as mo when running as an mo
(Feel free to close if you think no more work is needed here 👍 )
Ah, excellent! From an engineering perspective, it makes a lot of sense to have all cells be Python.
I expected that when I activated "view as markdown", the cell would just need markdown in it, and not depend on other Python state. Might just be habit from Jupyter.
To make this more user-friendly, we could:
- Print a more user-friendly error (i.e. you still need to import mo), or
- Automatically import marimo as mo when running as an mo
I suppose one thing we could do is automatically add a cell that imports marimo as mo, if marimo hasn't already been imported.
Should this functionality be extended to import any module on NameError?
Maybe. I think any auto-importing may be too magical though; even auto-importing marimo.
Most IDEs have an auto-import feature (mine auto-imports on save), I don't think it is too magical, especially for mo which is quite common
Most IDEs have an auto-import feature (mine auto-imports on save), I don't think it is too magical, especially for
mowhich is quite common
Okay yea mine does too, good point. Where would the import go, new cell at the bottom of the file?
Bottom of the file and new cell would be my opinion. I thought trying to merge with existing imports, but could cause noisy/unwanted re-renders.
Implemented in #1404.