How to use nbconvert as git textconv driver to enable effective version control of Jupyter Notebooks

前端 未结 2 1002
挽巷
挽巷 2021-02-14 00:41

What I\'m trying to do and how it differs from similar problems

I would like to version control Jupyter Notebooks using Git. Unfortunately, by default, Git and Jupyter

相关标签:
2条回答
  • 2021-02-14 01:32

    have you tried just straight up committing the notebooks. I saw similar posts to you when looking on version controlling jupyter notebooks, but when i just tried it it seemed to work fine.

    example notebook on github

    https://github.com/loegare/Test-Post-Please-Ignore/blob/master/Untitled%20Folder/Data%20Due%20Dilligence.ipynb

    0 讨论(0)
  • 2021-02-14 01:40

    If you carefully read the documentation of gitattributes (where the textconv config option is described) you will notice that the converter program must send the output to standard output:

    ...

    Performing text diffs of binary files

    Sometimes it is desirable to see the diff of a text-converted version of some binary files. For example, a word processor document can be converted to an ASCII text representation, and the diff of the text shown. Even though this conversion loses some information, the resulting diff is useful for human viewing (but cannot be applied directly).

    The textconv config option is used to define a program for performing such a conversion. The program should take a single argument, the name of a file to convert, and produce the resulting text on stdout.

    ...

    Therefore you must add the --stdout option to your conversion command:

    ipynb2py

    #!/bin/bash
    jupyter nbconvert --to python --stdout "$1"
    
    0 讨论(0)
提交回复
热议问题