MyST-NB icon indicating copy to clipboard operation
MyST-NB copied to clipboard

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

Open bsipocz opened this issue 3 years ago • 4 comments

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

  • produces no output, even though they are run. E.g. see the first code cell here, which contains imports: https://github.com/NASA-NAVO/navo-workshop/blob/main/CS_Catalog_Queries.ipynb
  • accidentally remained empty cells
  • or maybe cells with commented out code only (especially in the case of tutorial exercise notebooks)

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

bsipocz avatar May 05 '22 22:05 bsipocz

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:

welcome[bot] avatar May 05 '22 22:05 welcome[bot]

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

chrisjsewell avatar May 05 '22 23:05 chrisjsewell

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.

bsipocz avatar May 05 '22 23:05 bsipocz