-
Notifications
You must be signed in to change notification settings - Fork 58
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function hooks when executing cells / notebooks? #81
Comments
I think you could do this in papermill by extending https://github.com/nteract/papermill/blob/master/papermill/engines.py#L231-L285 and calling a post-execution hook. Course you'd need to run code in the kernel to support it properly. Maybe a hook that saves the final line of each cell as a scrap on the notebook?
I think we'd want to expose call-backs for cell-complete and other events to the engine in papermill so you can just register an engine that supported it. |
yes! that is the kind of pattern that I had in mind. You think Agreed that the nicer way to handle this for our use-case (since I am still not sure what the "right" UX is here) is to just make it possible to extend the back that papermill uses along w/ access to the kernel |
I think papermill is a more established place for adding execution hooks in managed execution patterns, yeah. Keeping nbclient simple and low level makes it easier to understand and less opinionated about how you execute notebook code. Want me to transfer this issue to papermill to continue the discussion about making it easier to add these particular hook patterns? |
happy to do so, thanks for the explanation |
I'm trying to find a way to achieve scrapbook-like functionality but without asking users to write new code. Instead, I'd like them to be able to tag cells with metadata (either tags like
glue_varname
, or other metadata) and to programatically embed extra outputs in the cell depending on that metadata.I think to do this with
nbclient
, we could allow either a notebook-level or cell-level hook that could be run alongside the call toexecute()
. Basically, a function that runs in the context of the kernel that is run with the notebook. I'd have a preference for the ability to do this in each cell, but notebook-level could work too.It seems like this could potentially be useful for other kinds of usecases too, so I wonder what folks think about supporting something like this. Alternatively, can anybody think of a way to support the usecase I described at the top?
The text was updated successfully, but these errors were encountered: