-
Notifications
You must be signed in to change notification settings - Fork 19
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
add remove metadata #169
add remove metadata #169
Conversation
8b1e1cf
to
0da1136
Compare
Fails due to pylint: poetry run pylint src
************* Module nb_clean
src\nb_clean\__init__.py:147:0: R0913: Too many arguments (6/5) (too-many-arguments)
-----------------------------------
Your code has been rated at 9.95/10 |
Any update, @srstevenson The fails is not mandatory and can be fixed by making all args as keyword-only-argument |
I've held off from merging this because I'm not yet convinced there's a real user requirement for it. Most of the notebook metadata doesn't change frequently, and so doesn't contribute to the noise in VCS diffs which nb-clean was written to address. |
Different editor such as Google Colab vs VSCode and different Python version across user produce different metadata. That is the use case. Not convinced enough? |
I would like to support the idea of this PR (can't yet assess its quality wrt. nb-clean coding standards). As I mentioned in #157 (comment), the notebook-level metadata actually do make noise in git commits. For example, this metadata gets changed right after opening in VS Code without even running the notebook, and populated with things like conda environment name or some weird hash. For me, the ability to filter out those is entirely in the spirit of nb-clean. ExampleNote: nb-clean was run after each step 1) initial state "metadata": {
"language_info": {
"name": "python"
}, 2) after opening in web browser and saving "metadata": {
"kernelspec": {
"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"
}
}, 3) after opening in VS Code and saving "metadata": {
"kernelspec": {
"display_name": "scratch",
"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"
},
"vscode": {
"interpreter": {
"hash": "8951b5bc4efd704e8ce7b1700f3d36aa2c5348526bfde6695033584eb49dd3bb"
}
}
}, This is on the same machine using the same conda environment (!) Needless to say that if my colleague happens to open the notebook on his computer, edit some stuff, save and do a git commit with the nb-clean hook, the commit will include his edits PLUS several metadata changes. |
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.
Found some typos
Since notebook metadata language_info is indeed needed, current PR remove this metadata. How about add other parameter such as --add-language-metadata NAME, with default name to Python? |
Another approach is to change this PR into But, based on your example, the
After VSCode open:
|
I don't understand @yasirroni, I don't mind having this in the cleaned notebook with hard-wired |
I don't think we need to complicate things right now.
Ah OK, I think you read it wrong; |
Please let GitHub apply suggestions and resolve discussions automatically as described in https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/incorporating-feedback-in-your-pull-request |
Did not know that feature exist. Sorry, Sir. |
Co-authored-by: Vaclav Hapla <[email protected]>
Co-authored-by: Vaclav Hapla <[email protected]>
Yeah, but the structure changes, since
But, I also works in Octave and octave-based notebook did not use that metadata. Here is a new notebook in Octave created using jupyterlab: "metadata": {
"kernelspec": {
"display_name": "Octave",
"language": "octave",
"name": "octave"
}
}, |
I think, two options might be good. Hard clean: like this PR. "metadata": {
"kernelspec": {
"language": "..."
},
"language_info": {
"name": "...",
},
}, |
No. Please, take a good look - "metadata": {
"kernelspec": {
...
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "python",
...
},
...
"name": "python",
...
},
...
},
Once again, I'm fine with keeping just
It's changed based on what interpreter the kernel uses. Keeping just empty |
@haplav oops. i'm sorry. It will be easier than. |
@srstevenson any chance to get this merged? |
This PR was closed due to inactivity. Please reopen if still relevant. |
Any chance this can be re-opened? I'm willing to fix merge conflict. @srstevenson |
#163 is still open with the same branch, so let's use that PR instead. |
Add new argument for clean and filter "-M" or "--remove-notebook-metadata" to "remove notebook metadata.
re-PR from #163