Skip to content

exec: add --output flag to write executed notebook to file#11

Merged
anish749 merged 3 commits into
mainfrom
add-output-notebook-flag
Mar 30, 2026
Merged

exec: add --output flag to write executed notebook to file#11
anish749 merged 3 commits into
mainfrom
add-output-notebook-flag

Conversation

@anish749

Copy link
Copy Markdown
Owner

Problem

When executing a complete notebook via --file, there's no way to get the executed notebook with outputs as a file. The agent only sees streamed text output but can't point users to a rendered notebook.

Solution

Add --output option to nbexec exec for .ipynb files:

Scenario Behavior
Full run + --output Write executed notebook to specified path
Full run, no --output Auto-generate <input>_out.ipynb, report path on stderr
Partial run + --output Update only executed cells in output file (preserves prior partial run outputs)
Partial run, no --output No output file (unchanged behavior)
  • Output notebook preserves all cells (markdown, etc.) from the input
  • Output is written even on cell failure so partial results are not lost
  • --output is rejected for non-notebook files

Testing

8 new tests in TestOutputNotebook covering all scenarios above, including incremental partial runs and error handling. All 16 tests pass.

Full notebook runs auto-generate <input>_out.ipynb when --output is
not specified. Partial runs with --output update only the executed
cells, preserving outputs from prior runs. Output is written even
on cell failure so partial results are not lost.
@anish749 anish749 merged commit 8f7922f into main Mar 30, 2026
1 check passed
@anish749 anish749 deleted the add-output-notebook-flag branch March 30, 2026 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant