-
Notifications
You must be signed in to change notification settings - Fork 650
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
ENH: Modify execute option for jb page command. #594
Conversation
Modifies the meaning of the --execute flag for the jb page command. Using the click.options `--opt/--no-opt` pattern for boolean flags, modify the behavior of jb page so that notebook targets are executed by default, and can be toggled off by passing in the --no-execute flag.
jupyter_book/yaml.py
Outdated
@@ -90,6 +90,8 @@ def yaml_to_sphinx(yaml, config): | |||
sphinx_config["jupyter_execute_notebooks"] = execute.get("execute_notebooks") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a note that this is here well, it's checking for the execute config from this page, so check which one to use (again, apologies for the slightly confusing config setup)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the additional info - I need to spend a bit more time mapping out the different objects/containers that hold configuration information in the different layers (jb, myst-nb, etc.) and how they map to each other.
* Remove negation from conditional for readability.
Adds two tests: 1. Execution of notebook source with jb page (default) 2. Notebook source not execute when --no-execute flag used.
Okay, I've added tests and a blurb to the documentation to update the feature. Note that there are now three tests for |
@rossbar go for it! improving the test infra would be great |
Encapsulate page execution flag tests into a single test class. Eliminates some code repition for test setup and allows for simple parametrization of page --execution flag tests.
Okay, I gave it a shot - I'm not sure it would be considered an improvement :). The changes eliminate a bit of code associated with setting up each individual |
Sounds good! I see some of the tests are failing, is that expected on your end? I am +1 on the change if we get the tests working |
Good point - they were failing for me on master, but it looks like a simple requirements issue - will fix now! |
* Include pyppeteer in test_reqs in setup.py as it is a requirement for test_pdf.py * Fix package name typo in error message.
Hmm - so one of the failing tests is from I'm not exactly sure what is happening there - seems related to the caching somehow? I'm not too familiar with that component. |
|
I'm still having trouble chasing down the execution order of the configuration steps. Based on the comment above jupyter-book/jupyter_book/__init__.py Lines 23 to 35 in d76cdba
it seems like it might be possible that some of the default configuration parameters are overriding config values passed into Does this seem like a reasonable hypothesis? Note also that for a single build, "auto", "force" and "cache" should all induce same behavior when it comes to executing notebooks, and their doesn't seem to be a test for building with "off", so the above might be slipping through the current test suite. |
An example implementation to resolve the scenario where a config option is changed from the command line, so that the CLI option takes precedence over any corresponding value in the _config.yml
I think I've figured out the root cause of the problems here. Essentially, it boils down to the fact that a config parameter ( In d895c1b I've illustrated a way to get around this issue, though in general I'm not very happy with it because I think it makes the configuration machinery even more complicated. I mostly added it in an attempt to better illustrate what I think the problem is. As an aside - I wasn't familiar with the development pattern for sphinx extensions before trying to track down what was happening here. If it wasn't for your comment in the code I linked above, I would've floundered for even longer. |
Hmmmm - I see...so I think there's a root problem here that you've identified, which is that CLI arguments will be over-ridden by the If so, I feel like we should try to nail that bug down and come up with a more natural way for configuring to happen. Do you agree? Then it could be much more straightforward to configure etc. |
Yes, this is correct.
I agree completely - as I mentioned, I only listed the "solution" in d895c1b to help illustrate the point. I do not think it's a good idea to add another What would make sense to me is closing this PR and linking the discussion in a corresponding issue that is more accurately titled to capture the larger issue about the execution-order of the configuration steps. |
OK cool, lemme think about this a little bit and I'll try and whip up a PR that will improve the configuration stuff :-) |
Closing for now, will revisit after potential changes to the configuration process. Thanks for taking the time to follow up on the meandering discussion here! |
Sounds good - I'm going to try to get to it this week :-) this was a really helpful challenge to highlight, thanks for doing so! |
Modifies the meaning of the --execute flag for the jb page command.
Using the click.options
--opt/--no-opt
pattern for boolean flags,modify the behavior of jb page so that notebook targets are executed
by default, and can be toggled off by passing in the --no-execute
flag.
Marking as draft until added tests + update corresponding docs