executablebooks / MyST-NB

Parse and execute ipynb files in Sphinx
https://myst-nb.readthedocs.io
BSD 3-Clause "New" or "Revised" License
205 stars 84 forks source link

nb_execution_mode=auto should take into account cells with no expected output #416

Open bsipocz opened 2 years ago

bsipocz commented 2 years ago

Describe the bug

context and expectation When I use nb_execution_mode=auto I would expect that execution is skipped when all the code cells are run.

bug But instead the execution is always run.

problem This is because some of the cells

I think none of these cases should trigger the execution.

I'm happy to propose a fix in a PR

Reproduce the bug

Run all the cells in the notebook referenced above, save it. Then run sphinx-build -b html -D nb_execution_mode=auto . _build/html on it

List your environment

No response

welcome[bot] commented 2 years ago

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

chrisjsewell commented 2 years ago

Heya, yeh happy to see proposals/suggestions thanks 👍

I'd note an alternative solution though, now we have file-level configuration: https://myst-nb.readthedocs.io/en/latest/configuration.html#file-level-configuration

if you want certain notebooks executed and others not, you could set globally nb_execution_mode="force", then set per-notebook:

{
  "metadata": {
    "mystnb": {
      "execution_mode": "off"
    }
  }
}

or visa-versa

bsipocz commented 2 years ago

Yes, I think that will be a good solution for some of the projects I maintain (e.g. where I definitely want to keep the outputs as they are, e.g. when they are a product of cells with a long run time), but the auto option promises such a nice, low maintenance middle-ground.