GCBallesteros / jupytext.nvim

Jupyter notebooks on neovim powered by Jupytext
66 stars 14 forks source link

fix: correctly infer output extension for jupytext command #20

Open hamzashezad opened 3 months ago

hamzashezad commented 3 months ago

fixes a bug where extracted metadata information is not used when constructing the jupytext command to convert python. NOTE: this and #19 are both required to fix issues when opening a Google Colab exported notebook.

Context I get the following metadata from a notebook exported directly from Google Colab. jupytext doesn't have enough information to use auto:hydrogen when converting:

  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
GCBallesteros commented 3 months ago

Can you explain what information is jupytext missing above in order to make use of the auto mode?

hamzashezad commented 3 months ago

jupytext uses the kernelspec.language_info.file_extension (or kernelspec.language, or jupytext.main_language as fallbacks) to determine the output format: https://github.com/mwouts/jupytext/blob/main/src/jupytext/formats.py#L811 -> https://github.com/mwouts/jupytext/blob/main/src/jupytext/formats.py#L782