Using specially jupytext-paired notebook content raises the error
WARNING: Notebook code has no file extension metadata, defaulting to `.txt`
during conversion by sphinx.
Below I first explain what I am up to - which partly works like a charm - and then outline the error upon a modification of the juptext-pairing. Either there happens an error somewhere during nbconvert in myst-nb or I am missing a configuration option, or it's a jupytext issue(?) but I don't see where.
In my sphinx docs folder I have some jupyter notebooks which I pair via
jupytext --set-formats ipynb,.py:percent --sync *.ipynb
The *.ipynb are ignored by git and in my conf.py I set:
exclude_patterns = ["conf.py"]
# ...
nb_custom_formats = {".py": ["jupytext.reads", {"fmt": "py"}]}
and reverted the registration of the .ipynb files via https://gist.github.com/juhuebner/2d032ebe74a3b57876996487a54ef589
If I now run the sphinx-build it works out nice and in the folder jupyter_execute the notebooks metadata have entries like
"metadata": {
"jupytext": {
"encoding": "# -*- coding: utf-8 -*-",
"formats": "ipynb,.nb.py:percent",
"text_representation": {
"extension": ".py",
"format_name": "percent",
"format_version": "1.3",
"jupytext_version": "1.11.2"
}
},
"kernelspec": {
"display_name": "Python 3",
"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.8.8"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
However, now in my git workflow I want to treat the notebook python equivalent specially and use a little change to the suffix .nb before the extension .py according to
https://jupytext.readthedocs.io/en/latest/config.html
jupytext --set-formats ipynb,.nb.py:percent --sync *.ipynb
However, now this error occurs
WARNING: Notebook code has no file extension metadata, defaulting to `.txt`
and the notebook metadata is missing the language data:
"metadata": {
"jupytext": {
"formats": "ipynb,.nb.py:percent"
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
However, the *.nb.py files have some information on the extension
# ---
# jupyter:
# jupytext:
# formats: ipynb,.nb.py:percent
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.11.2
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
Can anyone help me out with this? Possibly related to #81 #325 ?
Environment
- Python Version 3.8.8:
- nbformat 5.0.8
- myst-nb 0.12.0
- Operating System: Windows 10
Using specially jupytext-paired notebook content raises the error
during conversion by sphinx.
Below I first explain what I am up to - which partly works like a charm - and then outline the error upon a modification of the juptext-pairing. Either there happens an error somewhere during
nbconvertinmyst-nbor I am missing a configuration option, or it's a jupytext issue(?) but I don't see where.In my sphinx docs folder I have some jupyter notebooks which I pair via
The
*.ipynbare ignored by git and in myconf.pyI set:and reverted the registration of the
.ipynbfiles via https://gist.github.com/juhuebner/2d032ebe74a3b57876996487a54ef589If I now run the sphinx-build it works out nice and in the folder
jupyter_executethe notebooks metadata have entries likeHowever, now in my git workflow I want to treat the notebook python equivalent specially and use a little change to the suffix
.nbbefore the extension.pyaccording tohttps://jupytext.readthedocs.io/en/latest/config.html
However, now this error occurs
and the notebook metadata is missing the language data:
However, the
*.nb.pyfiles have some information on the extensionCan anyone help me out with this? Possibly related to #81 #325 ?
Environment