fix: set file in compilation for app mode linecache and better stack traces#8800
fix: set file in compilation for app mode linecache and better stack traces#8800dmadisetti merged 4 commits intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR improves traceback/stack trace fidelity when running notebooks in app/run mode by ensuring compiled cells are associated with the real notebook filename, allowing tracebacks to reference the source file instead of synthetic __marimo__cell_*.py paths (addressing #8764).
Changes:
- Pass the notebook filename into
compile_cell(...)whenget_mode() == "run"to enable file-based source positions/linecache usage. - Add a run-mode regression test asserting tracebacks reference the real notebook file and not
__marimo__cell_*.py.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
marimo/_runtime/runtime.py |
In run mode, forwards app_metadata.filename into cell compilation to improve traceback file references. |
tests/_runtime/test_trace.py |
Adds a test that verifies run-mode tracebacks include the notebook filename and exclude synthetic cell filenames. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| code: str, filename: str | ||
| ) -> Optional[SourcePosition]: | ||
| @functools.lru_cache(maxsize=1) | ||
| def _build_source_position_map( |
There was a problem hiding this comment.
is there a concern the change over time and this is stale?
There was a problem hiding this comment.
Yep, with run --watch, good catch
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.21.2-dev52 |
📝 Summary
Previously

app/runmode utilized the defaulteditmode style line caches. By passing in the filename during app mode compilation, we ensure the line cache is set for file level tracebacks. Example:Closes #8764