nbdev icon indicating copy to clipboard operation
nbdev copied to clipboard

Consider add option to clean `kernelspec` in notebook meta?

Open kanglcn opened this issue 3 years ago • 2 comments

Hi all,

I am new to nbdev and thanks for creating this amazing tool!

I found the kernelspec in notebook meta data in preserved when running nbdev_clean. Please refer to https://github.com/fastai/nbdev/blob/b2f0810a4edd8ee79180b0a1c6a41e6966226ea4/nbdev/clean.py#L91

However, I found this metadata shouldn't be record by git in my case. For example, here is what I get from git diff xxxx.ipynb:

... some unrelated output...

@@ -79,9 +43,21 @@
  ],
  "metadata": {
   "kernelspec": {
-   "display_name": "Python 3.9.5 ('base')",
+   "display_name": "Python 3 (ipykernel)",
    "language": "python",
    "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.9.13"
   }
  },
  "nbformat": 4,

We should save these metadata, for example, the detailed python version.

Will you consider and option to remove it? Thanks for your help.

kanglcn avatar Dec 03 '22 19:12 kanglcn

Seconded. The current behavior means that on a team project someone running nbdev_clean will end up with modifications to ALL notebooks, for eg:

image

johnowhitaker avatar Mar 06 '23 07:03 johnowhitaker

Seconded. I got these meaningless changes in all my notebooks, depending on running them via Jupyter or via vscode:

## modified /metadata/kernelspec/display_name:
-  Python [conda env:py310] *
+  conda-env-py310-py

but maybe it's okay to keep kernelspec, but only to clean up display_name, as that seems to be the only offender?

michaelaye avatar Mar 30 '23 08:03 michaelaye