fastai / nbdev

Create delightful software with Jupyter Notebooks
https://nbdev.fast.ai/
Apache License 2.0
4.8k stars 484 forks source link

NBs becoming untrusted in save hook #892

Open jph00 opened 1 year ago

jph00 commented 1 year ago

Currently NBs become untrusted when saving, if using the save hook.

seeM commented 1 year ago

I've been looking into this and there seem to be quite a few issues with Jupyter's trust system with hooks completely disabled. I'm not sure when/why these first appeared. See section below for more.

One idea would be to allow users to opt-in to completely disabling the trust system for notebooks in nbdev repos by configuring a repo-specific setting (e.g. trust_nbs = True). I'm not yet sure if this is possible or if its a good idea, will tinker some more. Another idea would be to deal with the current behaviour until its fixed upstream (or try make a PR). @hamelsmu @jph00 what do you think?

Jupyter trust issues

Creating a cell of any type breaks trust in Notebook

I haven't seen an issue tracking this in the Notebook repo. https://github.com/jupyterlab/jupyterlab/issues/9765 is similar but is in Lab.

Repro:

  1. Open any notebook
  2. Trust it (click the "Untrusted" button on the top-right)
  3. Create a cell of any type - it should remain trusted (should show "Trusted" on the top-right)
  4. Refresh the page - it will now be untrusted

This isn't the case in Lab. For example, creating a code cell with source "1" keeps trust in Lab.

Markdown cells break trust in Lab

This is being tracked in: https://github.com/jupyterlab/jupyterlab/issues/12889. It's a different issue to the previous and only affects Lab.

Repro:

  1. Open any notebook
  2. Trust it (open the command prompt and run "Trust Notebook")
  3. Create a blank code cell or markdown cell - it should now be untrusted (should show a shield with an x in the bottom-right)
  4. Trust it - it should still be untrusted
  5. Refresh the page - it should still be untrusted