fix: preserve invalid cells in topological IPYNB export - #10451
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
All contributors have signed the CLA ✍️ ✅ |
Bundle ReportChanges will increase total bundle size by 43.92kB (0.17%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: marimo-esmAssets Changed:
|
There was a problem hiding this comment.
Pull request overview
Fixes a topological IPYNB export edge case where cells present in the live document but missing from the compiled dependency graph (e.g., during transient invalid edits) could be silently dropped. The exporter now only applies topological ordering when the dependency graph and document cover the exact same set of cell IDs; otherwise it preserves document order and exports every cell.
Changes:
- Default to document-order export and only apply topological sorting when the graph’s cell IDs exactly match the document’s cell IDs.
- Add a regression test ensuring an invalid (graph-missing) cell is preserved in topological export mode.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| marimo/_convert/ipynb/from_ir.py | Prevents dropping document cells by gating topological sorting on full graph/document ID coverage. |
| tests/_export/test_export_ipynb.py | Adds a regression test for preserving invalid/missing-from-graph cells during topological export. |
There was a problem hiding this comment.
All reported issues were addressed across 2 files
Architecture diagram
sequenceDiagram
participant User as User/Editor
participant Export as convert_from_ir_to_ipynb()
participant CM as CellManager
participant Graph as Dependency Graph
participant Sorter as dataflow.topological_sort()
Note over User,Sorter: IPYNB Export with Topological Sort
User->>Export: Request export with sort_mode="topological"
Export->>CM: cell_data()
CM-->>Export: List of cell_data (all cells in document order)
Export->>Graph: Access app.graph
Graph-->>Export: Graph object (only compiled cells)
Export->>Export: Build cell_ids set from cell_data_list
Export->>Graph: Get graph.cells keys
alt cell_ids == set(graph.cells) (all cells are compilable)
Export->>Sorter: topological_sort(graph, graph.cells.keys())
Sorter-->>Export: Sorted cell IDs
Export->>CM: cell_data_at(cid) for each sorted ID
CM-->>Export: Sorted cell_data_list
else cell_ids != set(graph.cells) (some cells have invalid code)
Note over Export: Keep original document order
Export->>Export: Use unchanged cell_data_list
end
Export->>Export: Build notebook from cell_data_list
Export-->>User: IPYNB with all cells preserved
Note over Export: Key: Invalid cells (e.g. "x =") are kept<br/>in document order when graph coverage differs
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.17-dev10 |
Summary
Topological IPYNB export could silently drop cells present in the current notebook document but absent from the dependency graph. This occurs during live editing when a cell contains transient invalid code such as
x =.The converter now starts from document order and applies topological sorting only when the graph contains exactly the same cell IDs. When coverage differs, it keeps document order and preserves every cell.