Better tracebacks when running as a script
akshayka opened this issue · comments
The tracebacks when running as a script are inscrutable. This is particularly frustrating when a user runs a script that takes several hours, only to fail with a traceback that cannot be understood.
Ideally, the traceback would point to the exact line in the original script that raised the error.
Instead, tracebacks look like this today:
Script:
import marimo
__generated_with = "0.6.19"
app = marimo.App()
@app.cell
def __(y):
x = 0
y = y/x
return x, y
if __name__ == "__main__":
app.run()
Traceback:
Traceback (most recent call last):
File "/home/akshay/src/marimo-team/marimo/tmp/script.py", line 15, in <module>
app.run()
File "/home/akshay/src/marimo-team/marimo/marimo/_ast/app.py", line 360, in run
return self._run_sync(post_execute_hooks=post_execute_hooks)
File "/home/akshay/src/marimo-team/marimo/marimo/_ast/app.py", line 275, in _run_sync
outputs[cid] = execute_cell(cell._cell, glbls)
File "/home/akshay/src/marimo-team/marimo/marimo/_ast/cell.py", line 459, in execute_cell
exec(cell.body, glbls)
File "/tmp/marimo_467203/__marimo__cell_Hbol_.py", line 2, in <module>
NameError: name 'y' is not defined
Notice how the user has no idea what __celll__Hbol__
is, the line number is relative to the cell and not the whole script (line 2 of what?), and the offending line is not even shown.
cc @delennc