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

Converting a Jupyter notebook with external (local) images to Marimo notebook leads to broken image link #2950

Closed
s-celles opened this issue Nov 24, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@s-celles
Copy link
Contributor

Describe the bug

Hello,

I'm trying to use Marimo with these examples (Jupyter notebooks from Pandapower)
https://github.com/e2nIEE/pandapower/tree/develop/tutorials

git clone https://github.com/e2nIEE/pandapower/
cd tutorials
marimo convert .\minimal_example.ipynb -o .\minimal_example.py
marimo edit minimal_example.py

Image

As you can see <img src="pics/3bus-system.png" width="50%"> is not rendered.

Any idea?

Environment

> marimo env
{
  "marimo": "0.9.23",
  "OS": "Windows",
  "OS Version": "11",
  "Processor": "Intel64 Family 6 Model 142 Stepping 12, GenuineIntel",
  "Python Version": "3.11.5",
  "Binaries": {
    "Browser": "131.0.6778.86",
    "Node": "v23.2.0"
  },
  "Dependencies": {
    "click": "8.1.7",
    "docutils": "0.18.1",
    "itsdangerous": "2.0.1",
    "jedi": "0.18.1",
    "markdown": "3.6",
    "narwhals": "1.13.1",
    "packaging": "23.1",
    "psutil": "5.9.0",
    "pygments": "2.15.1",
    "pymdown-extensions": "10.8",
    "pyyaml": "6.0.1",
    "ruff": "0.7.2",
    "starlette": "0.37.2",
    "tomlkit": "0.12.4",
    "typing-extensions": "4.12.2",
    "uvicorn": "0.29.0",
    "websockets": "10.4"
  },
  "Optional Dependencies": {
    "altair": "5.4.1",
    "pandas": "2.2.2",
    "pyarrow": "17.0.0"
  }
}

Code to reproduce

No response

@s-celles s-celles added the bug Something isn't working label Nov 24, 2024
@mscolnick
Copy link
Contributor

mscolnick commented Nov 24, 2024

We don't support images this way. This is because <img src="pics/3bus-system.png" will make a network request http://localhost:2718/pics/3bus-system.png, which we do not expose as a way to read your files from your filesystem, as that could allow an attacker for example to read your .env file.

Instead we recommend you do mo.image() to read the file which converts it to a data-uri

@mscolnick
Copy link
Contributor

mscolnick commented Nov 24, 2024

We could add public folder to automatically serve assets from that folder. This is what most modern frontend frameworks will do.
This is similar to streamlit's static folder

@s-celles
Copy link
Contributor Author

s-celles commented Nov 25, 2024

What is quite surprising is that Markdown syntax

![img](pics/3bus-system.png)

is also unsupported.

@s-celles
Copy link
Contributor Author

My opinion is that you should reduce any friction that trouble Jupyter notebook conversion to Marimo notebook while considering potential security breach.
I perfectly understand that listing .env content can be problematic. Maybe a rule "reject all content" except some (.png, .jpeg, .jpg ...) should be considered in this case.

@mscolnick
Copy link
Contributor

mscolnick commented Nov 25, 2024

Yea, since our markdown is dynamic mo.md(f"Your name is {input.value}") and often can include "end-user generated content", we need to be more careful with fetching assets from it. We could include a "public-assets" field, that you can configure to be "*.png", but I think a better/clearer/safer option would be a public folder. So, while marimo convert today would require you to copy pics to the public folder, it is possible that we can do this on your behalf as part of the marimo convert CLI`.

@s-celles
Copy link
Contributor Author

In such a case, export could provide 2 options.Embed resources as base64 or store as external file in this directory

@mscolnick
Copy link
Contributor

Sounds good - @s-celles, would you like to open up a new issue for this feature-request, or update this issue with the request (and I can close this one)?

@s-celles
Copy link
Contributor Author

I'm off until tomorrow. Sorry

@mscolnick
Copy link
Contributor

No worries, I will close this issue. Whenever you'd like, we can open a new issue about public/ assets (unrelated to marimo convert)

@mscolnick mscolnick closed this as not planned Won't fix, can't repro, duplicate, stale Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants