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

Automatically import marimo as mo on markdown fail? #1164

Open
MartinBernstorff opened this issue Apr 18, 2024 · 9 comments
Open

Automatically import marimo as mo on markdown fail? #1164

MartinBernstorff opened this issue Apr 18, 2024 · 9 comments
Labels
enhancement New feature or request

Comments

@MartinBernstorff
Copy link

MartinBernstorff commented Apr 18, 2024

Describe the bug

image

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

@MartinBernstorff MartinBernstorff added the bug Something isn't working label Apr 18, 2024
@akshayka
Copy link
Contributor

You'll need to import marimo as mo first. Markdown is written with Python in marimo (mo.md).

@MartinBernstorff
Copy link
Author

MartinBernstorff commented Apr 18, 2024

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

@MartinBernstorff
Copy link
Author

(Feel free to close if you think no more work is needed here 👍 )

@akshayka
Copy link
Contributor

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.

@akshayka akshayka added enhancement New feature or request and removed bug Something isn't working labels Apr 18, 2024
@akshayka akshayka changed the title Markdown fails on Windows Automatically import marimo as mo on markdown fail? Apr 18, 2024
@wasimsandhu
Copy link
Contributor

Should this functionality be extended to import any module on NameError?

@akshayka
Copy link
Contributor

Maybe. I think any auto-importing may be too magical though; even auto-importing marimo.

@mscolnick
Copy link
Contributor

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

@akshayka
Copy link
Contributor

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

Okay yea mine does too, good point. Where would the import go, new cell at the bottom of the file?

@mscolnick
Copy link
Contributor

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.

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

No branches or pull requests

4 participants