Get help from the marimo community

Updated last month

My mo.stop is disappearing in SQL cells

At a glance

The community member is using mo.stop in a SQL cell, but when they restart the notebook, the mo.stop disappears and they are back to a SQL cell without the stop. The community members discuss that mo.stop() is not supported in SQL cells, but if custom code is added, it should be left as is and not reverted back to SQL. They provide examples of code that may be causing the issue, such as using mo.sql() with a print statement, which gets lost when transforming in and out of the cell. Another community member suggests using mo.stop in a separate cell if the SQL query depends on a UI element, or creating a NOOP query in the SQL statement as a potential workaround.

Heya, as it sounds, I’m using mo.stop in a SQL cell (after turning the SQL cell into a python one) and when I restart a notebook the mo.stop disappear and I’m back with a SQL cell but with no stop
1
M
S
l
6 comments
we don't support mo.stop() in sql cells. however, if you add custom code, we should be leaving it as is and not revert back to sql. can you share the snippet?
I think there's something not working
Plain Text
print("hiii")

_df = mo.sql(
    "SELECT 1, 2"
)

this is treated as a valid sql cell, and transforming in and out will lose the print statement
have a fix for this, but if your code doesn't look like the above then it may be a different issue
it looks like the above yes! @Shahmir
it looks like:

Plain Text
mo.stop(some_ui.value is None, "Please interact with UI element")

df = mo.sql("select from my table", engine = pg_engine)
Oh interesting. I've seen someone else do this, so I see the use case for sure.
@lucharo if your sql query depends on the ui element, mo.stop in another cell should work. you can likely also create a NOOP query in the sql statement, but that may look gross
Add a reply
Sign up and join the conversation on Discord