Jupyter switched to token authentication by default, enabled nbdime integration in git diff
parent
93623e8cc2
commit
7093626bc2
|
@ -15,9 +15,9 @@ RUN conda install -y -c conda-forge \
|
|||
ARG username
|
||||
ARG userid
|
||||
|
||||
RUN adduser ${username} --uid ${userid} --gecos '' --disabled-password && \
|
||||
echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} && \
|
||||
chmod 0440 /etc/sudoers.d/${username}
|
||||
RUN adduser ${username} --uid ${userid} --gecos '' --disabled-password \
|
||||
&& echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} \
|
||||
&& chmod 0440 /etc/sudoers.d/${username}
|
||||
|
||||
ENV HOME /home/${username}
|
||||
|
||||
|
@ -30,29 +30,41 @@ RUN jupyter contrib nbextension install --user
|
|||
RUN jupyter nbextension enable toc2/main
|
||||
|
||||
|
||||
# INFO: Have RUN command below uncommented to for easy and constant URL (just localhost:8888)
|
||||
# (by setting empty password instead of using a token)
|
||||
# To avoid making a security hole the best would be to regenerate a hash for
|
||||
# your own non-empty password and to replace the hash below.
|
||||
# You can compute a password hash in the notebook, just run the code:
|
||||
# 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.
|
||||
# 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.
|
||||
# You can compute a password hash in any notebook, just run the code:
|
||||
# from notebook.auth import passwd
|
||||
# passwd()
|
||||
RUN mkdir -p ${HOME}/.jupyter && \
|
||||
echo 'c.NotebookApp.password = u"sha1:c6bbcba2d04b:f969e403db876dcfbe26f47affe41909bd53392e"' \
|
||||
>> ${HOME}/.jupyter/jupyter_notebook_config.py
|
||||
# and take the hash from the output
|
||||
#RUN mkdir -p ${HOME}/.jupyter && \
|
||||
# echo 'c.NotebookApp.password = u"sha1:c6bbcba2d04b:f969e403db876dcfbe26f47affe41909bd53392e"' \
|
||||
# >> ${HOME}/.jupyter/jupyter_notebook_config.py
|
||||
|
||||
# INFO: Uncomment the RUN command below to disable git diff paging
|
||||
#RUN git config --global core.pager ''
|
||||
|
||||
|
||||
# INFO: Below - work in progress, nbdime not totally integrated, still it enables diffing
|
||||
# notebooks via nbdiff after connecting to container by "make exec" (docker exec)
|
||||
# Use:
|
||||
# notebooks with nbdiff (and nbdiff support in git diff command) after connecting to
|
||||
# the container by "make exec" (docker exec)
|
||||
# Try:
|
||||
# nbd NOTEBOOK_NAME.ipynb
|
||||
# to get nbdiff between checkpointed version and current version of the given notebook
|
||||
USER root
|
||||
WORKDIR /
|
||||
|
||||
RUN conda install -y -c conda-forge nbdime
|
||||
|
||||
USER ${username}
|
||||
WORKDIR ${HOME}/handson-ml
|
||||
|
||||
RUN git-nbdiffdriver config --enable --global
|
||||
|
||||
# INFO: Uncomment the RUN command below to ignore metadata in nbdiff within git diff
|
||||
#RUN git config --global diff.jupyternotebook.command 'git-nbdiffdriver diff --ignore-metadata'
|
||||
|
||||
|
||||
COPY docker/bashrc /tmp/bashrc
|
||||
RUN cat /tmp/bashrc >> ${HOME}/.bashrc
|
||||
|
|
|
@ -22,7 +22,7 @@ After the process is finished you have a `handson-ml` image, that will be the ba
|
|||
|
||||
### Run the notebooks
|
||||
|
||||
Run `make run` (or just `docker-compose up`) to start the jupyter server inside the container (also named `handson-ml`, same as image). Just point your browser to <http://localhost:8888> (empty password) or the URL printed on the screen and you're ready to play with the book's code!
|
||||
Run `make run` (or just `docker-compose up`) to start the jupyter server inside the container (also named `handson-ml`, same as image). Just point your browser to the URL printed on the screen (or just <http://localhost:8888> if you enabled password authentication) and you're ready to play with the book's code!
|
||||
|
||||
The server runs in the directory containing the notebooks, and the changes you make from the browser will be persisted there.
|
||||
|
||||
|
@ -34,5 +34,7 @@ Run `make exec` (or `docker-compose exec handson-ml bash`) while the server is r
|
|||
|
||||
One of the usefull things that can be done there may be comparing versions of the notebooks using the `nbdiff` command if you haven't got `nbdime` installed locally (it is **way** better than plain `diff` for notebooks). See [Tools for diffing and merging of Jupyter notebooks](https://github.com/jupyter/nbdime) for more details.
|
||||
|
||||
You can see changes you made relative to the version in git using `git diff` which is integrated with `nbdiff`.
|
||||
|
||||
You may also try `nbd NOTEBOOK_NAME.ipynb` command (custom, see bashrc file) to compare one of your notebooks with its `checkpointed` version.<br/>
|
||||
To be precise, the output will tell you *what modifications should be re-played on the **manually saved** version of the notebook (located in `.ipynb_checkpoints` subdirectory) to update it to the **current** i.e. **auto-saved** version (given as command's argument - located in working directory)*.
|
||||
|
|
Loading…
Reference in New Issue