Patches to nbdiff for skipping noisy metadata, some local config
Nbdiff --ignore-details skils autoscroll, collapsed, deletable, editable, toc (pull request on the way). Enabling empty pass, no git pager, ignoring gitdiff nbdiff details.main
parent
4453715759
commit
8d16b3061d
|
@ -21,8 +21,10 @@ RUN adduser ${username} --uid ${userid} --gecos '' --disabled-password \
|
||||||
|
|
||||||
ENV HOME /home/${username}
|
ENV HOME /home/${username}
|
||||||
|
|
||||||
WORKDIR ${HOME}/handson-ml
|
ARG workdir=${HOME}/handson-ml
|
||||||
RUN chown ${username}:${username} ${HOME}/handson-ml
|
|
||||||
|
WORKDIR ${workdir}
|
||||||
|
RUN chown ${username}:${username} ${workdir}
|
||||||
|
|
||||||
USER ${username}
|
USER ${username}
|
||||||
|
|
||||||
|
@ -30,7 +32,7 @@ RUN jupyter contrib nbextension install --user
|
||||||
RUN jupyter nbextension enable toc2/main
|
RUN jupyter nbextension enable toc2/main
|
||||||
|
|
||||||
|
|
||||||
# INFO: Uncomment the RUN command below for easy and constant notebook URL (just localhost:8888)
|
## INFO: Uncomment the RUN command below for easy and constant notebook URL (just localhost:8888)
|
||||||
# That will switch jupyter to using empty password instead of a token.
|
# That will switch jupyter to using empty password instead of a token.
|
||||||
# To avoid making a security hole you SHOULD in fact not only uncomment but
|
# To avoid making a security hole you SHOULD in fact not only uncomment but
|
||||||
# regenerate the hash for your own non-empty password and replace the hash below.
|
# regenerate the hash for your own non-empty password and replace the hash below.
|
||||||
|
@ -38,12 +40,12 @@ RUN jupyter nbextension enable toc2/main
|
||||||
# from notebook.auth import passwd
|
# from notebook.auth import passwd
|
||||||
# passwd()
|
# passwd()
|
||||||
# and take the hash from the output
|
# and take the hash from the output
|
||||||
#RUN mkdir -p ${HOME}/.jupyter && \
|
RUN mkdir -p ${HOME}/.jupyter && \
|
||||||
# echo 'c.NotebookApp.password = u"sha1:c6bbcba2d04b:f969e403db876dcfbe26f47affe41909bd53392e"' \
|
echo 'c.NotebookApp.password = u"sha1:c6bbcba2d04b:f969e403db876dcfbe26f47affe41909bd53392e"' \
|
||||||
# >> ${HOME}/.jupyter/jupyter_notebook_config.py
|
>> ${HOME}/.jupyter/jupyter_notebook_config.py
|
||||||
|
|
||||||
# INFO: Uncomment the RUN command below to disable git diff paging
|
## INFO: Uncomment the RUN command below to disable git diff paging
|
||||||
#RUN git config --global core.pager ''
|
RUN git config --global core.pager ''
|
||||||
|
|
||||||
|
|
||||||
# INFO: Below - work in progress, nbdime not totally integrated, still it enables diffing
|
# INFO: Below - work in progress, nbdime not totally integrated, still it enables diffing
|
||||||
|
@ -54,18 +56,33 @@ RUN jupyter nbextension enable toc2/main
|
||||||
# to get nbdiff between checkpointed version and current version of the given notebook
|
# to get nbdiff between checkpointed version and current version of the given notebook
|
||||||
USER root
|
USER root
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
|
|
||||||
RUN conda install -y -c conda-forge nbdime
|
RUN conda install -y -c conda-forge nbdime
|
||||||
|
|
||||||
USER ${username}
|
USER ${username}
|
||||||
WORKDIR ${HOME}/handson-ml
|
WORKDIR ${workdir}
|
||||||
|
|
||||||
RUN git-nbdiffdriver config --enable --global
|
RUN git-nbdiffdriver config --enable --global
|
||||||
|
|
||||||
# INFO: Uncomment the RUN command below to ignore metadata in nbdiff within git diff
|
## INFO: Optionally uncomment any (one) of the following RUN commands below to ignore either
|
||||||
|
# metadata or details in nbdiff within git diff
|
||||||
#RUN git config --global diff.jupyternotebook.command 'git-nbdiffdriver diff --ignore-metadata'
|
#RUN git config --global diff.jupyternotebook.command 'git-nbdiffdriver diff --ignore-metadata'
|
||||||
|
RUN git config --global diff.jupyternotebook.command 'git-nbdiffdriver diff --ignore-details'
|
||||||
|
|
||||||
|
|
||||||
|
##
|
||||||
|
RUN ls -l /tmp/
|
||||||
|
COPY docker/nbdime-*.patch /tmp/
|
||||||
|
RUN ls -l /tmp/
|
||||||
|
USER root
|
||||||
|
WORKDIR /
|
||||||
|
RUN patch -d /opt/conda/lib/python3.6/site-packages -p1 --forward --reject-file=- < \
|
||||||
|
/tmp/nbdime-1-details.patch \
|
||||||
|
&& patch -d /opt/conda/lib/python3.6/site-packages -p1 --forward --reject-file=- < \
|
||||||
|
/tmp/nbdime-2-toc.patch
|
||||||
|
RUN rm /tmp/nbdime-*.patch
|
||||||
|
USER ${username}
|
||||||
|
WORKDIR ${workdir}
|
||||||
|
|
||||||
|
|
||||||
COPY docker/bashrc /tmp/bashrc
|
COPY docker/bashrc /tmp/bashrc
|
||||||
RUN cat /tmp/bashrc >> ${HOME}/.bashrc
|
RUN cat /tmp/bashrc >> ${HOME}/.bashrc
|
||||||
RUN sudo rm -rf /tmp/bashrc
|
RUN sudo rm /tmp/bashrc
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
alias ll="ls -l"
|
alias ll="ls -alF"
|
||||||
|
|
||||||
nbd() {
|
nbd() {
|
||||||
DIRNAME=$(dirname "$1")
|
DIRNAME=$(dirname "$1")
|
||||||
|
@ -8,5 +8,5 @@ nbd() {
|
||||||
CHECKPOINT_COPY=$DIRNAME/.ipynb_checkpoints/$BASENAME-checkpoint.ipynb
|
CHECKPOINT_COPY=$DIRNAME/.ipynb_checkpoints/$BASENAME-checkpoint.ipynb
|
||||||
|
|
||||||
# echo "How change $CHECKPOINT_COPY into $WORKING_COPY"
|
# echo "How change $CHECKPOINT_COPY into $WORKING_COPY"
|
||||||
nbdiff "$CHECKPOINT_COPY" "$WORKING_COPY"
|
nbdiff "$CHECKPOINT_COPY" "$WORKING_COPY" --ignore-details
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
--- a/nbdime/diffing/notebooks.py
|
||||||
|
+++ b/nbdime/diffing/notebooks.py
|
||||||
|
@@ -548,8 +548,12 @@ def set_notebook_diff_targets(sources=True, outputs=True, attachments=True, meta
|
||||||
|
metadata_keys = ("/cells/*/metadata", "/metadata", "/cells/*/outputs/*/metadata")
|
||||||
|
if metadata:
|
||||||
|
for key in metadata_keys:
|
||||||
|
- if key in notebook_differs:
|
||||||
|
- del notebook_differs[key]
|
||||||
|
+ if details:
|
||||||
|
+ if key in notebook_differs:
|
||||||
|
+ del notebook_differs[key]
|
||||||
|
+ else:
|
||||||
|
+ notebook_differs[key] = diff_ignore_keys(
|
||||||
|
+ inner_differ=diff, ignore_keys=['collapsed', 'autoscroll', 'deletable', 'editable'])
|
||||||
|
else:
|
||||||
|
for key in metadata_keys:
|
||||||
|
notebook_differs[key] = diff_ignore
|
|
@ -0,0 +1,11 @@
|
||||||
|
--- a/nbdime/diffing/notebooks.py
|
||||||
|
+++ b/nbdime/diffing/notebooks.py
|
||||||
|
@@ -553,7 +553,7 @@
|
||||||
|
del notebook_differs[key]
|
||||||
|
else:
|
||||||
|
notebook_differs[key] = diff_ignore_keys(
|
||||||
|
- inner_differ=diff, ignore_keys=['collapsed', 'autoscroll', 'deletable', 'editable'])
|
||||||
|
+ inner_differ=diff, ignore_keys=['toc', 'collapsed', 'autoscroll', 'deletable', 'editable'])
|
||||||
|
else:
|
||||||
|
for key in metadata_keys:
|
||||||
|
notebook_differs[key] = diff_ignore
|
Loading…
Reference in New Issue