Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.8k
Notebook execution history#15062
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Notebook execution history#15062
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Thanks for making a pull request to jupyterlab! |
krassowski left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I left some early comments on API and naming. Since this is a new feature we will need tests and a mention in user documentation.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
andrewfulton9 commentedSep 4, 2023
Thanks for the review@krassowski! I'll work on addressing all these comments and update ASAP |
b2e5ace to23f8cbfCompareandrewfulton9 commentedSep 18, 2023
@krassowski, I've added a test for this. Let me know if you think it's sufficient, or I should add something. Do you have a recommendation for where to add a mention of this feature for the user documentation? I was thinking docs/source/user/notebook.rst or docs/source/user/documents_kernels.rst. I'm also seeing that a lot of actions have youtube videos along with the description. Is there any documentation on how to add a video or is that something that has to be done by someone with rights to the Jupyter youtube channel? |
krassowski commentedSep 18, 2023
If I remember correctly we wanted to move away from YouTube videos for user-facing documentation (#8776 and#6823) and are not adding new ones. Either notebook or kernels section of user guide sounds good to me; a single paragraph would do fine, but if you think a video is useful, it would ideally be generated using playwright. This is however a bit difficult because there is no API to start/stop recording at specific time in the test case. |
67bb213 tof3ee2e7Comparekrassowski commentedSep 20, 2023
Kicking CI after bot update. |
Uh oh!
There was an error while loading.Please reload this page.
packages/notebook/src/history.ts Outdated
| args:{notebook:StaticNotebook;cell:Cell} | ||
| ):Promise<void>{ | ||
| constcell=args['cell']; | ||
| awaitthis._retrieveHistory(cell).catch(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is still fetching 500 entries of history on each cell execution. I just tried this locally and for my current history it is extra 180kB on the websocket wire for each cell; execute a notebook with 100 cells and you got 18MB noise on websocket. This is compared to execution and reply messages being barely 300-600 bytes.
I would suggest we only fetch history once when it is first requested by the user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I have it fetching history on each reset so that newly run cells are included in the history without manually appending them. Also, fetching it each time allows a user to access the history from different kernels as well, though they would have to scroll through the history of the current kernel first. What if I implemented something where it only requested a few at a time, requesting more as the user scrolls farther back through the history.
I'm also now wondering if accessing different kernel histories could be considered a security risk with multiple users on jupyter_server? Would users be able to access the kernel history for other users as it is now?
krassowskiSep 22, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It is fine to fetch say 10-20 items at a time and then maybe more if there is no overlap with what was fetched before. All I am arguing is that it should never happen on cell execution, but only when user does invokenotebook:access-previous-history-entry/notebook:access-next-history-entry. We could use cell execution as a heuristic for how many items to fetch; in pseudo-code:
class{onCellExecuted(){this._minToFetch+=1;}previousEntry(){this._ensureHistorySynced();this._setPrevious()}private_ensureHistorySynced(){lethistoryReconcliliated=false;letinitialToFetch=this._minToFetch+5;lethistoryChunk=this._fetch(initialToFetch);consthistoryChunks=[];while(!historyReconcliliated&&historyChunk.length>0){if(historyChunkoverlapsthis._historyCache){historyChunks.push(historyChunk[overlapStart:]);historyReconcliliated=true;}else{// this assumes no execution in the meantimehistoryChunks.push(historyChunk);historyChunk=this._fetch(10);}}this._historyCache.push(...reversed(historyChunks));this._minToFetch=0;}private_minToFetch=0;}
Though this will be tricky to get right. Do we really want to have history from concurrently executing kernels though?
Maybe usingsession,start andstop arguments of,history_request could help? In particular if we restrict ourselves to singlesession, the problem of cross-session history leakage would be eliminated (but then the history would be more limited).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Yeah I was on the fence on whether or not to include multiple kernel histories or just the history of the notebook kernel, I ultimately decided to include them all since that's how the console history works. I did mostly implement the single notebook kernel history though, and that's actually why cell history is collected on execution. I couldn't figure out another way to get the kernel id number without collecting from the first history item immediately after a cell in the notebook was run, though if we go that way it should probably only call history after the first execution. So it seems to me the options are:
- include whole history, and only collect on access commands or
- include only history from current kernel, getting kernel number from first execution of the session
and then with either of those options it can either:
a) grab history in intervals or
b) grab n number (what we currently have)
What are your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I would ask users who requested this feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@rsaim, do you have an opinion on this?
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
Galata snapshots updated. |
Uh oh!
There was an error while loading.Please reload this page.
galata/test/documentation/general.test.ts-snapshots/jupyterlab-documentation-linux.pngShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
krassowski left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This is almost there, just minor changes, mostly updating documentation strings + one issue with translation and narrowing the public API.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
Co-authored-by: Michał Krassowski <5832902+krassowski@users.noreply.github.com>
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
krassowski left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thank you@andrewfulton9!
References
#9646
follows up on@echarles workhere
Code changes
User-facing changes
This PR gives the user the ability to use Alt + up or down arrows to iterate through the kernel history.
kernel_execution_history.mp4
Backwards-incompatible changes
None that I am aware