kynan / nbstripout

strip output from Jupyter and IPython notebooks
Other
1.19k stars 95 forks source link

Failed to Dockerize #107

Closed rolandrajko closed 4 years ago

rolandrajko commented 4 years ago

Hi,

I tried to Dockerize the nbstripout, but when I call git diff, I get the following error:

'./nbstripout.cmd -t': ./nbstripout.cmd -t: No such file or directory
fatal: unable to read files to diff

I guess it's because of a stdin kind issue, but I can't figure it out. Any idea? Below the relevant files I used.

Dockerfile:

FROM python:alpine
RUN apk add --no-cache git \
    && pip install --upgrade nbstripout
WORKDIR /workspace
ENTRYPOINT [ "nbstripout" ]
CMD [ "--help" ]

nbstripout.cmd:

@powershell "docker run --rm -v ${pwd}:/workspace -i rolandrajko/nbstripout %*"

.git/config:

[filter "nbstripout"]
    clean = './nbstripout.cmd'
    smudge = cat
    required = true
[diff "ipynb"]
    textconv = './nbstripout.cmd -t'

.gitattributes

*.ipynb filter=nbstripout
*.ipynb diff=ipynb
kynan commented 4 years ago

./nbstripout.cmd -t is interpreted as a filename because you put it in ''. You need to change your .git config to this:

[filter "nbstripout"]
    clean = ./nbstripout.cmd
    smudge = cat
    required = true
[diff "ipynb"]
    textconv = ./nbstripout.cmd -t
rolandrajko commented 4 years ago

In that case I get the following error message:

λ git diff
'.' is not recognized as an internal or external command,
operable program or batch file.
error: external filter './nbstripout.cmd' failed 1
error: external filter './nbstripout.cmd' failed
fatal: classification.ipynb: clean filter 'nbstripout' failed
kynan commented 4 years ago

I don't have experience with Windows so I can only guess what's happening. Have you tried using the full path to nbstripout.cmd instead of ./? Have you tried " instead of ' ?

rolandrajko commented 4 years ago

I remember I tried them both, but now the snippet below seems good. Thanks.

[filter "nbstripout"]
    clean = nbstripout.cmd
    smudge = cat
    required = true
[diff "ipynb"]
    textconv = nbstripout.cmd -t
kynan commented 4 years ago

Glad to hear. Can we close this?

rolandrajko commented 4 years ago

I guess.