marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
5.39k stars 158 forks source link

keras.utils.plot_model returns Expected string data #1710

Closed essicolo closed 4 days ago

essicolo commented 4 days ago

Describe the bug

I expected that function plot_model plots a keras graph. However, the cell returns

Something went wrong Expected string data If this is an issue with marimo, please report it on GitHub.

Environment

{ "marimo": "0.6.25", "OS": "Windows", "OS Version": "10", "Processor": "Intel64 Family 6 Model 186 Stepping 2, GenuineIntel", "Python Version": "3.12.3", "Binaries": { "Browser": "--", "Node": "v16.19.1" }, "Requirements": { "click": "8.1.7", "importlib-resources": "missing", "jedi": "0.18.1", "markdown": "3.6", "pymdown-extensions": "10.8.1", "pygments": "2.15.1", "tomlkit": "0.12.5", "uvicorn": "0.30.1", "starlette": "0.37.2", "websockets": "12.0", "typing-extensions": "4.11.0", "black": "24.4.2" } }

Code to reproduce

import marimo as mo
import os
import keras
graphviz_bin = r"C:\Program Files\Graphviz\bin"
os.environ["PATH"] += os.pathsep + graphviz_bin

model = keras.models.Sequential()
model.add(keras.layers.Input(shape=(1,)))
model.add(keras.layers.Dense(2, activation='relu'))
model.add(keras.layers.Dense(1, activation='sigmoid'))
keras.utils.plot_model(model)
mscolnick commented 4 days ago

For whatever reason, the plot_model returns null html (probably because it writes to a file on disk). I am not handling this in this PR https://github.com/marimo-team/marimo/pull/1712.

The output will still be null/empty, but there will not be an error.

akshayka commented 4 days ago

@essicolo just cut version 0.6.26, which contains a fix. Should be on PyPI momentarily.