Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Merged

Conversation

@andrewfulton9
Copy link
Contributor

References

#9646

follows up on@echarles workhere

Code changes

  • Adds keybindings "Alt ArrowUp" and "Alt ArrowDown" to notebook to iterate through kernel history in an activated cell
  • Adds history code file to notebook for managing the kernel history iteration file
  • Adds code to notebook widget file to add history functionality

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

fcollonval and eliasdabbas reacted with hooray emoji
@jupyterlab-probot
Copy link

Thanks for making a pull request to jupyterlab!
To try out this branch onbinder, follow this link:Binder

Copy link
Member

@krassowskikrassowski left a comment
edited
Loading

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.

@andrewfulton9
Copy link
ContributorAuthor

Thanks for the review@krassowski! I'll work on addressing all these comments and update ASAP

@andrewfulton9
Copy link
ContributorAuthor

@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
Copy link
Member

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.

@krassowski
Copy link
Member

Kicking CI after bot update.

args:{notebook:StaticNotebook;cell:Cell}
):Promise<void>{
constcell=args['cell'];
awaitthis._retrieveHistory(cell).catch();
Copy link
Member

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.

Copy link
ContributorAuthor

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?

Copy link
Member

@krassowskikrassowskiSep 22, 2023
edited
Loading

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).

Copy link
ContributorAuthor

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:

  1. include whole history, and only collect on access commands or
  2. 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?

Copy link
Member

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.

Copy link
ContributorAuthor

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?

@github-actions
Copy link
Contributor

Galata snapshots updated.

Copy link
Member

@krassowskikrassowski left a 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.

andrewfulton9and others added16 commitsOctober 20, 2023 15:58
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>
Copy link
Member

@krassowskikrassowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thank you@andrewfulton9!

@krassowskikrassowski merged commit3bdca21 intojupyterlab:mainOct 25, 2023
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsOct 26, 2024
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@fcollonvalfcollonvalfcollonval left review comments

@krassowskikrassowskikrassowski approved these changes

Assignees

@andrewfulton9andrewfulton9

Projects

None yet

Milestone

4.1.0

Development

Successfully merging this pull request may close these issues.

4 participants

@andrewfulton9@krassowski@fcollonval@echarles

[8]ページ先頭

©2009-2025 Movatter.jp