Problem
I'm trying to clear all output and almost all metadata from a jupyter notebook. When I run the following command,
jupyter nbconvert --ClearOutputPreprocessor.enabled=True \
--ClearMetadataPreprocessor.enabled=True \
--ClearMetadataPreprocessor.preserve_nb_metadata_mask="{('language_info', 'name'), 'kernelspec'}" \
--to=notebook --log-level=ERROR my_notebook.ipynb
I get the output I want,
"metadata": {
"kernelspec": {
"display_name": "my-kernel",
"language": "python",
"name": "my-kernel"
},
"language_info": {
"name": "python"
}
}
but also get this warning:
/usr/local/miniconda/lib/python3.7/site-packages/traitlets/traitlets.py:2935: FutureWarning: --ClearMetadataPreprocessor.preserve_nb_metadata_mask={('language_info', 'name'), 'kernelspec'} for containers is deprecated in traitlets 5.0. You can pass `--ClearMetadataPreprocessor.preserve_nb_metadata_mask item` ... multiple times to add items to a list.
FutureWarning,
Given the suggestion from the FutureWarning and the docs, I ran
jupyter nbconvert --ClearOutputPreprocessor.enabled=True \
--ClearMetadataPreprocessor.enabled=True \
--ClearMetadataPreprocessor.preserve_nb_metadata_mask="{('language_info', 'name')}" \
--ClearMetadataPreprocessor.preserve_nb_metadata_mask="{'kernelspec'}" \
--to=notebook --log-level=ERROR my_notebook.ipynb
However, instead of getting my expected output, the notebook has no metadata:
"metadata": {}
Question
- What's going on here? Is it a dependency version issue?
- How can I get the metadata mask to work without a FutureWarning?
I think it is simpler than you trying.
I just tried this and I think it does close to what you want and *importantly, no warning. (I see the warning when trying your first block in the environment, and so I expect it would be there.):
I don't think you actually need `"name" there. I think this works, too:
I will admit I'm not seeing how to submit the tuple so you can leave just the
namefield of the 'language_info' section.In reply to the comment about the tuple
Attempts and results:
Do you know the syntax that works for leaving just the
nameentry forlanguage_info?