Repository navigation
Store displays under the running cell's execution count - #1604
Open
MichengLiang wants to merge 1 commit into
Open
MichengLiang wants to merge 1 commit into
MichengLiang wants to merge 1 commit into
Conversation
run_cell increments execution_count before the cell runs, so while a cell runs (and in its post_execute hooks) the cell's own count is execution_count - 1, as IPython's own DisplayPublisher uses. The ZMQ publisher used execution_count outside post_execute, so with store_display_history=True a display was recorded under the next cell and %notebook exported it there. The unit test mocked execution_count=1 while expecting cell 1, which pinned the wrong count; it now mocks the count during cell 1 (2) and covers the post_execute case. A kernel test checks the stored execution count end to end. Fixes ipython#1602
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1602.
run_cellincrementsexecution_countbefore the cell runs, so while a cell runs (and in itspost_executehooks, which is the case ipython/ipython#14998 handled) the cell's own count isexecution_count - 1. IPython's ownDisplayPublisher.publishusesexecution_count - 1;ZMQDisplayPublisher.publishusedexecution_countoutsidepost_execute, so withstore_display_history=Truea display was recorded under the next cell and%notebookexported it there.ZMQDisplayPublisher.publishstores underexecution_count - 1in both cases.test_display_stored_in_historymockedexecution_count = 1while expecting the display under cell 1, which pinned the wrong count. It now mocks the count as it is while cell 1 runs (2), with and without_in_post_execute.test_display_history_uses_the_cell_execution_countchecks it end to end in a kernel started with--ZMQDisplayPublisher.store_display_history=True; it fails before the change (the cell's entry is empty) and passes after.Found while building a tool around ipykernel subshells; investigated and written with an AI assistant (🤖🤖).