-
Notifications
You must be signed in to change notification settings - Fork 809
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
[large notebooks] Collapsible headings do not show up anymore #822
Comments
Well, it sounds like the extension's attempting, but failing, to load. Could you post any output from the As to what's causing it, what changes have you recently made to your notebook environment? Any new nbextensions/server extensions? Updated versions? Custom js? Finally, does this apply equally to existing and new notebooks? I would guess yes, but worth a check... |
|
I have widgetsnbextension and ipywidgets (5.1.5). It works no problem with small notebooks, is very consistent. For large notebooks I get "script is too slow" warning, which I accept to keep going, and almost always I get no collapsible headings. |
Ok, how large is 'large'? The number of cells/headings is potentially relevant in addition to actual file size, I expect. When you say "almost always I get no collapsible headings.", do you mean that for the same notebook, sometimes you do get them, and sometimes you don't? I suspect, then, that this issue is something to do with the browser/javascript engine/notebook deciding to kill a collapsible headings callback which has taken too long, and as a result the nbextension doesn't get correctly loaded. Indeed, I suspect that it'll be a huge number of calls to update_collapsed_headings, so I should probably put a rate-limiter on that, setting a timeout or something... |
large is maybe 60 to 100 headings of different levels. Coming from Mathematica I am used to fraction a lot the content, duplicate section to keep track of variants of the calculations, etc ... Sometimes indeed the headings are collapsible, but I cannot say what is the deciding factor. Being fast to reply to the many "script is too slow" warnings seems to help, but I am not sure is a true effect because on Chrome I do not get any of these warning for "script is too slow" and still sometimes loads correctly. Let me know if I can help in any way with tests or else. |
Right, so I suspect that it may just be the many almost-simultaneous calls to
So to clarify, and just check that I've got the story correct in my head, a few questions/requests for confirmation:
I'll try to knock together some rate-limiting now, and we can see if it helps |
At present I do not have the mathematica-style brackets, but I might have activated that option before. Each section might have 4 to 20 cells, some are initialization cells and might take seconds to evaluate each, some are a lot faster. I alternate Chrome and Firefox. |
ah, ok. I've had a stab at throttling the update calls in #823 if you fancy trying it out? |
I can try it, sure. But how do I do that? |
ah, apologies. So, it depends slightly on your python environment, but essentially, to get a copy of the repo incorporating the pr #823, you can use:
Alternatively, in one line you can update yoru existing collapsible_headings install javascript to include the PR changes using
and adding whichever of the Does that make sense? |
I used the first way to install this. I suppose it went through as no error has been thrown. On the small notebook it still loads fine, but does not work yet on the big one. Here is the JS console of the one that does not work. These two seems to be the most relevant log lines, the full log is below them.
Full log from Chrome:
|
ok, so from the line
it's at least clear that we're looking at a load timeout which is the problem. Having experimented a little myself using a dummy notebook (see this gist), I find that the notebook takes a very long time to load - something like 20 seconds or so. The collapsible_headings execution itself is of order 10ms, which isn't long enough to cause the timeout, so I think the best option may be to delay binding of heading updates until the notebook is definitely loaded. I'll push another attempt... |
I use |
Ok, on further investigation, this isn't actually an issue specific to collapsible_headings. Essentially it's a limitation of the way notebook loading happens. In essence, if your notebook is big enough, then the require calls to load the nbextensions may happen while the notebook is loading, and then all the processing time is hogged by the notebook load, and as a result any and all nbextensions will fail to load. You could increasing the available timeout by adding something like window.requirejs.config({
waitseconds: 60, // default is 30s
}); to your |
is this as simple as JS trying to be asynchronous that unfolds in a clumsy way? in my JS when it comes to load large database files (JSON or XML) it turned out that I could force to load that file in a synchronous way and that solved the issue. is there any such option here?? i will try to put a bigger timeout (if I manage to edit the correct file). Anyhow if these notebooks cannot be too big to load extensions is a big trouble and should be solved to compare to Mathematica and alike thanks for investigating this!! |
As far as I can tell, yes, that's what's happening. I'm not sure whether it's the data transfer that's the bottleneck, or the processing required to add the cells (my guess is the latter), but something in the notebook load is causing problems for the asynchronous load of the nbextensions. I'm not sure there's a useful way to perform a synchronous load (see this SO question), and in any case, this would require a PR to notebook.
The
Yes, absolutely, I agree. Not really sure how to fix it, but definitely needs addressing. This may be a limitation of the browser though, since js is single-threaded, I believe. Anyway... |
It might be worth you opening an issue at jupyter/notebook for this, since it seems to be a problem with how the notebook loads nbextensions, rather than with the nbextensions themselves... |
Following http://stackoverflow.com/a/39921293/2842999 I did find my
custom.js (and even realized I did use it at some point for some custom
keyboard shortcuts).
Added the
window.requirejs.config({
waitseconds: 60, // default is 30s
});
and does not change the timeout error. Now trying with 6000 but does not
work either ...
…On 5 January 2017 at 18:06, Josh Barnes ***@***.***> wrote:
It might be worth you opening an issue at jupyter/notebook for this, since
it seems to be a problem with how the notebook loads nbextensions, rather
than with the nbextensions themselves...
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#822 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AI8aNQyASDMffSV1YycgvCee3pCPCMexks5rPSMogaJpZM4LUMNU>
.
|
Hmm, ok, something clearly going on that I don't understand. Perhaps there are timeouts enforced by the browser independent of requirejs? Seems a little unlikely though, so maybe something else going on... |
What is the approximate load time of your notebook without nbextensions? In the region of a minute? |
Yes, something around one or two minutes. |
yeah, I've looked at it again, and come to the same conclusion, that it's a problem with notebook itself. However, it has also occurred to me that you could get around this temporarily by getting the nbextension to load later, after notebook is loaded |
You could do this with something along the lines of require(['base/js/namespace', 'base/js/utils', 'base/js/events'], function (Jupyter, utils, events) {
function load_ch () { utils.load_extension('collapsible_headings/main'); }
if (Jupyter.notebook._fully_loaded) load_ch();
else events.one('notebook_loaded.Notebook', load_ch);
}); placed either in your |
using
after the notebook has started, seems to properly fold the sections I had last left folded. i will test how this interacts with the loading of other extensions and report. |
I get similar issues with a large notebook, except the problem is that a lot of extensions just time out. I tried the I can get all the extensions to load if i close and halt and open the notebook 2-3 times. Js Console Error:
I have a separate error where ipywidgets cant be found and is using 21ms of the load time... opened another issue on that though #1702. Edit: LOL i've had a similar problem before, now only if I can remember how i fixed it... |
I guess JS is not made for large notebooks, period. I went back doing thing in Wolfram ... :( |
@foice I wish I knew enough about how it could be optimized. Perhaps implementing the bottlenecks in a compiled language would be of interest. |
Using
as magic cell solved it for 'collapsible_headings/main', but didn't work with 'toc2/main' which is the one I was looking to reactivate. Also tried
on custom.js, with no success. Extensions stopped loading when notebook reached around 250 cells (half are code cells, other half are markup cells used for headings). No issues on smaller notebooks. |
Update: Solved it by switching from Safari to Google Chrome. I'd been using Safari all along (on a MacBook Pro). Using Google Chrome the notebook loads much faster (it takes maybe just 1/3 of the time to load) and loads all my extensions, including toc2. |
Hello, I have used collapsible headings for sometime now, but as of today they not show up any more in my notebooks. I have tried several times to switch off and back on this extension with the http://localhost:8888/nbextensions page, but it does not seem to help. I have also tried on Chrome and Firefox and in both cases the handles to close the heading for the section do not show up.
Any idea what else I could try to get the collapsible headings back?
The text was updated successfully, but these errors were encountered: