-
Notifications
You must be signed in to change notification settings - Fork 84
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
FEAT: Jupyter-cache integration #55
FEAT: Jupyter-cache integration #55
Conversation
Note that all tracebacks (and eventually failed notebooks) are stored in the cache, see: https://github.com/ExecutableBookProject/jupyter-cache#staging-notebooks-for-execution |
Great, thanks. So, I should recover the cache information using the pk of the notebook. I will test this out tomorrow morning. |
Yes, note that it is stored on the staged record, not a cache record, because obviously since the notebook failed, it is not cached and there is no cache record created |
I mentioned this in an issue before (can't remember which one!), but I feel that this should be handled around step (3) of the build process below (by adding an event callback), whereby you stage all notebooks, then call execute. Then, in the parse step (7), you will just attempt to retrieve a cached notebook or, on
|
FYI, before this is merged, make sure to add some tests, using the notebooks in https://github.com/ExecutableBookProject/MyST-NB/tree/master/tests/notebooks (for an example of a full sphinx integration test, see https://github.com/ExecutableBookProject/MyST-Parser/blob/master/tests/test_sphinx/test_sphinx_builds.py) |
Nice! Thanks for this nice start! a few quick thoughts from me:
Another thing to remember - users of Jupyter Book should need to know nothing about MyST-NB, we could also make some of these improvements (e.g. clearing cache and parallel execution) in the |
I made a PR to your branch @AakashGfude - I had started some work on this earlier, and that PR is to help give an idea where I was going, and give you some code to work with if it's helpful 👍 |
I assumed the user will have no knowledge about the internals of caching and DB being used. And imagined that the command to clear cache would be done in the background, when something like
This is a nice idea. We will need to decide which layers should have what functionalities. I am not entirely clear about the functionalities
Like you said above, users of Jupyter Book need not know about MyST-NB and internals. So we should avoid situations in which they might have to use the internal complicated tools? |
I had also imagined in the same lines. @choldgraf what are your thoughts on this? |
yeah that sounds reasonable to me - it'll be hard to tell without a prototype to play around with though, I'm happy to try something out when it's ready |
updating cacheing code
…T-NB into jupyter-cahe-integration
@choldgraf @chrisjsewell have reorganized the code in the last few commits as a test, according to the discussion with @chrisjsewell above regarding parallel execution, where the notebooks are executed and cached during the Feel free to scrap this idea, or embrace it. |
Also @choldgraf , I got this attribute error for genutils after merging with master. Did the merge tamper anything? PS:- I will remove this comment later to prevent cluttering. |
Sorry @AakashGfude with 688e421 you'll need to refactor again 😬 |
…T-NB into jupyter-cahe-integration
Looking better! The cache worked for me this time 🎉 A few quick thoughts:
What other kind of functionality should I try to do to break it? :-) |
Re: the last point, it wasn't an error, just a warning, so there was no trace back. Sphinx will throw a warning if the value of a config key is of a different type from the default value |
This is weird, I am not able to reproduce and not able to see in the code where the error is. Maybe will need your help in that, can you grep that variable and see if its set to a string somewhere in your system? Also, about this point
It won't handle the case where users don't want to execute at all. We can have three values for this variable. The third one being "off" ? I am not good in naming things |
Yeah - "off" seems fine if we don't want the sphinx warning about types...otherwise |
@choldgraf Have done the necessary changes, and |
Agree re: the jupinx loading bars, I think that style would be best! A few more thoughts:
|
So, in this case,
Yes, at present it was just doing a substring check of
I saw some logs about execution from nbclient as well. But, I just realized that it shows the log only for markdown files. And it executes markdown files as well. I will supress that by configuring it. and give logs as mentioned |
@choldgraf have updated the functionalities, feel free to test it and let me know your thoughts |
I just gave it another shot, and it worked really nicely 👍 - I tried all the different config options, and it worked really well, great job! I pushed a small extra bit to the documentation and also cleared out the outputs in our One thing that I foresee potentially confusing people in the future: we should provide some kinds of guidance for how to "clear the cache". E.g., do they delete I think that this one is nearly ready to go - we should treat this functionality as "late-alpha, early beta" for a while, so there's time for users to give the API a shot and provide feedback, squash bugs, etc. But I think it's ready to go from a user functionality and docs standpoint @chrisjsewell what do you think? |
Looks good to me 👍 |
…fude/MyST-NB into jupyter-cahe-integration
What I think we can have is have targeted clean methods like deleting the pages from the cache to trigger a re-build without removing the artifacts is something we need to think about. And also where the functionality should be implemented like for example the above |
fantastic! I'll plan on giving this a merge when I'm back at my computer (prob tomorrow morning) |
You could then bump the version to |
alright let's 🚢 it! |
OK I merged, bumped the version on master (#103) , and also added a release: https://github.com/ExecutableBookProject/MyST-NB/releases/tag/0.5.0a1. I bumped master before making the official release on github, so I triggered a travis re-build because I'm assuming that needs to happen once a release already exists |
Not sure if I understand this, but when you make a release that triggers Travis (or Gihub actions as we may move to soon), so you don't need to manually trigger. But anyway its all sorted 👍 FYI, if ppl didn't know, you now have the pre-release on https://pypi.org/project/myst-nb/#history, whereby this will not be installed doing |
* added functionality of jupyter-cache * writing tests to cover the all/most cases * adding execution and cacheing documentation * moved fixtures to conftest
Simple implementation of integration of
jupyter-cache
inmyst-nb's
parser.Current implementation
jupyter-cache
)Apart from making the present implementation more robust, I feel a few functionalities need to be present in MyST-NB :-
clear_cache
function ofjupyter_cache
. It might be necessary if someone wants to re-execute the notebooks without actually changing the code of any of themjupyter-cache
level won't be enough, and parallel execution cannot be implemented in parser I think, because it will create a new instance of multiprocessing library for each notebook.My suggestion for both of the above functionalities is to implement them in a sphinx builder.
Please provide your suggestions @choldgraf @chrisjsewell @mmcky, I will meanwhile continue the implementation to handle as many cases as possible.