feat(cli): stream block outputs in real-time during deepnote run#304
feat(cli): stream block outputs in real-time during deepnote run#304jamesbhobbs wants to merge 3 commits intomainfrom
deepnote run#304Conversation
…ution CLI --input values were being ignored because input blocks unconditionally assigned from their saved metadata during execution, overwriting the CLI-provided values. This patches the in-memory DeepnoteFile to inject CLI input values into input block metadata before execution begins. Also adds a test documenting that empty projects return exit code 0. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Previously, `deepnote run` waited until each block finished executing before rendering all outputs at once. For long-running blocks (e.g., training loops with print() updates), users saw nothing until completion. Wire the existing `onOutput` callback from the execution engine to render outputs immediately as they arrive from the Jupyter kernel. Machine output modes (-o json, -o toon) are unchanged. Co-Authored-By: Claude Opus 4.6 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #304 +/- ##
==========================================
+ Coverage 82.45% 82.48% +0.02%
==========================================
Files 112 112
Lines 6807 6816 +9
Branches 1821 1823 +2
==========================================
+ Hits 5613 5622 +9
Misses 1194 1194 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
No actionable comments were generated in the recent review. 🎉 📝 WalkthroughWalkthroughThe changes add streaming output coordination to the CLI run command. When blocks execute, the command now tracks which blocks need a newline before their first streamed output and which blocks produced streamed output. It inserts a newline before the first output from each block and a blank line after blocks with streamed output. Tests verify this behavior across different output modes and validate that the Sequence DiagramsequenceDiagram
participant Engine as engine.runProject
participant BlockEvent as Block Events
participant Handler as Handler (run.ts)
participant Console as Console Output
Engine->>BlockEvent: emit block_start
BlockEvent->>Handler: onBlockStart(blockId)
Handler->>Handler: mark blockId in needsNewlineBeforeOutput
Engine->>BlockEvent: emit onOutput(content)
BlockEvent->>Handler: onOutput(blockId, content)
alt Has pending newline
Handler->>Console: render newline
end
Handler->>Console: render output content
Handler->>Handler: mark blockId in blocksWithStreamedOutput
Handler->>Handler: remove from needsNewlineBeforeOutput
Engine->>BlockEvent: emit block_done
BlockEvent->>Handler: onBlockComplete(blockId)
Handler->>Handler: check hadStreamedOutput
alt Had streamed output
Handler->>Console: render blank line
end
Handler->>Handler: clear tracking for blockId
🚥 Pre-merge checks | ✅ 2 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
Summary
onOutputcallback from the execution engine to render block outputs immediately as they arrive from the Jupyter kernel, instead of batching them after block completionprint()updates), users now see output in real-time instead of waiting until the block finishes-o json,-o toon) are unchanged — they still collect outputs viaresult.outputsinonBlockDoneTest plan
-o jsonoutput includes outputs in blocks array (tested:does not render output via onOutput in machine output mode)[1/3] label ✓ (50ms)on one line (tested:keeps status on same line as label for blocks with no output)🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests