-
Notifications
You must be signed in to change notification settings - Fork 807
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
can I avoid initialization cells to be run on notebook load? #812
Comments
currently, this isn't implemented, but it seems like a reasonable use-case for a configurable option. I think it's plausible to want this to be different in different notebooks, so worth storing in notebook metadata as well as in server's nbconfig. |
so, on closer inspection, this seems to stem from the fact that the initialization cells are simply run on the event |
I think it will be difficult to get consistent behavior of executing initialization cells only when a new kernel is started from the notebook frontend itself due to race conditions and the other things you mentioned. You could check however for the kernel ID, which is unique for each restart. So the logic would be only execute the cell if the kernel ID has changed. |
Neat, but we'd have no memory of whether the page has been loaded previously, so I think it'd still look like a 'new' kernel id. Unless we store it in local storage or something, perhaps. But, as you say, I think there are too many edge cases to expect that to work reliably. |
There is no memory in Javascript that persists reloading as far as I understand, so you have to store it in notebook or cell metadata. if '_is_initialized' is not in locals():
_is_initialized = True
# do my intialization |
Well, there's window.localStorage as in select_keymap/main.js#L153, but even that's per-browser, so not really sufficient. I think your kernel-code is probably the neatest reasonably robust solution beyond only manually running them. Anyway, I've thrown together a PR to make the autorunning configurable on the basis that its default behaviour is just the same as what we have now anyway... |
I think init cells are a great thing, however the frontend sometimes needs to be reloaded for stupid reasons, which might have to do with javascript or anything else, but do not require to reload data from disk (for instance).
with the current extension, every time I re-load the page all the initialization cells are reloaded. is there a way to avoid this reload?
The text was updated successfully, but these errors were encountered: