jupyterhub / nbgitpuller

Jupyter server extension to sync a git repository one-way to a local path
https://nbgitpuller.readthedocs.io
BSD 3-Clause "New" or "Revised" License
205 stars 84 forks source link

Modifications to notebook are remembered even when notebook is deleted #279

Open phys119 opened 1 year ago

phys119 commented 1 year ago

I'm distributing template notebooks to students with nbgitpuller. Some of my students have managed to delete instruction cells from the template. I've told them to delete the notebook and click the link again, as that should download a fresh copy of the notebook, but it turns out that the deletion has been committed locally in the student's account, and is merged when the new copy is downloaded, so they don't get the deleted cells back!

This behaviour seems to be in contradiction to the documentation on automatic merge which suggests that if the notebook is deleted they should get a pristine template when they click the link again.

I'm using a jupyter hub operated by my University (at open.jupyter.ubc.ca).

pip freeze: aiodns==3.0.0 aiohttp==3.8.1 aiosignal==1.2.0 alembic @ file:///home/conda/feedstock_root/build_artifacts/alembic_1657813896088/work altair @ file:///home/conda/feedstock_root/build_artifacts/altair_1640799865332/work analytics-python==1.4.0 ansi2html @ file:///home/conda/feedstock_root/build_artifacts/ansi2html_1657236128758/work anyio @ file:///home/conda/feedstock_root/build_artifacts/anyio_1652463865103/work/dist argon2-cffi @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi_1640817743617/work argon2-cffi-bindings @ file:///home/conda/feedstock_root/build_artifacts/argon2-cffi-bindings_1649500328244/work astroid @ file:///home/conda/feedstock_root/build_artifacts/astroid_1655142257854/work asttokens @ file:///home/conda/feedstock_root/build_artifacts/asttokens_1618968359944/work async-generator==1.10 async-timeout==4.0.2 attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1640799537051/work autopep8 @ file:///home/conda/feedstock_root/build_artifacts/autopep8_1619771482781/work Babel @ file:///home/conda/feedstock_root/build_artifacts/babel_1655419414885/work backcall @ file:///home/conda/feedstock_root/build_artifacts/backcall_1592338393461/work backoff==1.10.0 backports.functools-lru-cache @ file:///home/conda/feedstock_root/build_artifacts/backports.functools_lru_cache_1618230623929/work beautifulsoup4 @ file:///home/conda/feedstock_root/build_artifacts/beautifulsoup4_1649463573192/work black==22.6.0 bleach @ file:///home/conda/feedstock_root/build_artifacts/bleach_1656355450470/work blinker==1.4 bokeh @ file:///home/conda/feedstock_root/build_artifacts/bokeh_1652969564789/work Bottleneck @ file:///home/conda/feedstock_root/build_artifacts/bottleneck_1656803756069/work Brotli @ file:///home/conda/feedstock_root/build_artifacts/brotli-split_1648883617327/work brotlipy @ file:///home/conda/feedstock_root/build_artifacts/brotlipy_1648854167867/work cached-property @ file:///home/conda/feedstock_root/build_artifacts/cached_property_1615209429212/work ccxt==1.91.20 certifi==2022.6.15 certipy==0.1.3 cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1656782834004/work chardet==5.0.0 charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1655906222726/work click @ file:///home/conda/feedstock_root/build_artifacts/click_1651215151197/work cloudpickle @ file:///home/conda/feedstock_root/build_artifacts/cloudpickle_1653061851209/work colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1655412516417/work conda==4.13.0 conda-package-handling @ file:///home/conda/feedstock_root/build_artifacts/conda-package-handling_1649385045972/work cryptography @ file:///home/conda/feedstock_root/build_artifacts/cryptography_1657173997940/work cycler @ file:///home/conda/feedstock_root/build_artifacts/cycler_1635519461629/work Cython @ file:///home/conda/feedstock_root/build_artifacts/cython_1652809237949/work cytoolz @ file:///home/conda/feedstock_root/build_artifacts/cytoolz_1657553432917/work dash @ file:///home/conda/feedstock_root/build_artifacts/dash_1657882603280/work dask @ file:///home/conda/feedstock_root/build_artifacts/dask-core_1657315353846/work debugpy @ file:///home/conda/feedstock_root/build_artifacts/debugpy_1649586344343/work decorator @ file:///home/conda/feedstock_root/build_artifacts/decorator_1641555617451/work defusedxml @ file:///home/conda/feedstock_root/build_artifacts/defusedxml_1615232257335/work dill @ file:///home/conda/feedstock_root/build_artifacts/dill_1653058582944/work distributed @ file:///home/conda/feedstock_root/build_artifacts/distributed_1657319800717/work entrypoints @ file:///home/conda/feedstock_root/build_artifacts/entrypoints_1643888246732/work et-xmlfile==1.1.0 executing @ file:///home/conda/feedstock_root/build_artifacts/executing_1646044401614/work fastjsonschema @ file:///home/conda/feedstock_root/build_artifacts/python-fastjsonschema_1658064924516/work/dist flake8 @ file:///home/conda/feedstock_root/build_artifacts/flake8_1620668104928/work Flask @ file:///home/conda/feedstock_root/build_artifacts/flask_1657844361786/work Flask-Compress @ file:///home/conda/feedstock_root/build_artifacts/flask-compress_1651163502372/work flit_core @ file:///home/conda/feedstock_root/build_artifacts/flit-core_1645629044586/work/source/flit_core fonttools @ file:///home/conda/feedstock_root/build_artifacts/fonttools_1657249373943/work frozenlist==1.3.0 fsspec @ file:///home/conda/feedstock_root/build_artifacts/fsspec_1653010523205/work gitdb==4.0.9 GitPython==3.1.27 gmpy2 @ file:///home/conda/feedstock_root/build_artifacts/gmpy2_1641732907644/work greenlet @ file:///home/conda/feedstock_root/build_artifacts/greenlet_1648882383677/work h5py @ file:///home/conda/feedstock_root/build_artifacts/h5py_1656336064499/work HeapDict==1.0.1 idna @ file:///home/conda/feedstock_root/build_artifacts/idna_1642433548627/work imagecodecs @ file:///home/conda/feedstock_root/build_artifacts/imagecodecs_1655137597069/work imageio @ file:///home/conda/feedstock_root/build_artifacts/imageio_1654071881944/work importlib-metadata @ file:///home/conda/feedstock_root/build_artifacts/importlib-metadata_1653252803161/work importlib-resources @ file:///home/conda/feedstock_root/build_artifacts/importlib_resources_1655356668708/work ipykernel @ file:///home/conda/feedstock_root/build_artifacts/ipykernel_1657295047882/work ipympl @ file:///home/conda/feedstock_root/build_artifacts/ipympl_1650889123350/work ipysheet==0.5.0 ipython @ file:///home/conda/feedstock_root/build_artifacts/ipython_1653754916420/work ipython-genutils==0.2.0 ipython-sql @ file:///home/conda/feedstock_root/build_artifacts/ipython-sql_1636816912182/work ipywidgets @ file:///home/conda/feedstock_root/build_artifacts/ipywidgets_1655973868664/work isort @ file:///home/conda/feedstock_root/build_artifacts/isort_1636447814597/work itsdangerous @ file:///home/conda/feedstock_root/build_artifacts/itsdangerous_1648147185463/work jedi @ file:///home/conda/feedstock_root/build_artifacts/jedi_1649067100958/work Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1654302431367/work joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1633637554808/work json5 @ file:///home/conda/feedstock_root/build_artifacts/json5_1600692310011/work jsonschema @ file:///home/conda/feedstock_root/build_artifacts/jsonschema-meta_1657629641118/work jupyter-archive==3.3.1 jupyter-bokeh @ file:///home/conda/feedstock_root/build_artifacts/jupyter_bokeh_1638244308716/work jupyter-client @ file:///home/conda/feedstock_root/build_artifacts/jupyter_client_1654730843242/work jupyter-core @ file:///home/conda/feedstock_root/build_artifacts/jupyter_core_1652365243968/work jupyter-dash @ file:///home/conda/feedstock_root/build_artifacts/jupyter-dash_1648919001274/work jupyter-lsp @ file:///home/conda/feedstock_root/build_artifacts/jupyter-lsp-meta_1639326415622/work/jupyter-lsp jupyter-resource-usage==0.6.1 jupyter-server @ file:///home/conda/feedstock_root/build_artifacts/jupyter_server_1657107521771/work jupyter-server-mathjax==0.2.6 jupyter-telemetry @ file:///home/conda/feedstock_root/build_artifacts/jupyter_telemetry_1605173804246/work jupyterhub @ file:///home/conda/feedstock_root/build_artifacts/jupyterhub-feedstock_1654538669080/work jupyterlab @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_1654621376725/work jupyterlab-code-formatter==1.5.1 jupyterlab-drawio @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab-drawio_1620212636855/work jupyterlab-git==0.37.1 jupyterlab-github==3.0.1 jupyterlab-latex==3.1.0 jupyterlab-lsp @ file:///home/conda/feedstock_root/build_artifacts/jupyter-lsp-meta_1647904782549/work/jupyterlab-lsp jupyterlab-pygments @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_pygments_1649936611996/work jupyterlab-server @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_server_1657063151834/work jupyterlab-spellchecker @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab-spellchecker_1633697061174/work jupyterlab-system-monitor==0.8.0 jupyterlab-templates==0.3.1 jupyterlab-topbar==0.6.1 jupyterlab-widgets==1.0.2 jupytext==1.14.0 kiwisolver @ file:///home/conda/feedstock_root/build_artifacts/kiwisolver_1657953096987/work lazy-object-proxy @ file:///home/conda/feedstock_root/build_artifacts/lazy-object-proxy_1649033164427/work lckr-jupyterlab-variableinspector==3.0.9 libmambapy @ file:///home/conda/feedstock_root/build_artifacts/mamba-split_1654091934149/work/libmambapy llvmlite==0.38.1 locket @ file:///home/conda/feedstock_root/build_artifacts/locket_1650660393415/work lz4 @ file:///home/conda/feedstock_root/build_artifacts/lz4_1652795530538/work Mako @ file:///home/conda/feedstock_root/build_artifacts/mako_1656619049246/work mamba @ file:///home/conda/feedstock_root/build_artifacts/mamba-split_1654091934149/work/mamba markdown-it-py==2.1.0 MarkupSafe @ file:///home/conda/feedstock_root/build_artifacts/markupsafe_1648737547956/work matplotlib @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-suite_1651609453931/work matplotlib-inline @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-inline_1631080358261/work mccabe==0.6.1 mdit-py-plugins==0.3.0 mdurl==0.1.1 mistune @ file:///home/conda/feedstock_root/build_artifacts/mistune_1635844663025/work mitosheet3==0.3.223 monotonic==1.6 mpmath @ file:///home/conda/feedstock_root/build_artifacts/mpmath_1612895720168/work msgpack @ file:///home/conda/feedstock_root/build_artifacts/msgpack-python_1654260638735/work multidict==6.0.2 munkres==1.1.4 mypy-extensions==0.4.3 nbclassic @ file:///home/conda/feedstock_root/build_artifacts/nbclassic_1657631862903/work nbclient @ file:///home/conda/feedstock_root/build_artifacts/nbclient_1656688109017/work nbconvert @ file:///home/conda/feedstock_root/build_artifacts/nbconvert-meta_1649676641343/work nbdime==3.1.1 nbformat @ file:///home/conda/feedstock_root/build_artifacts/nbformat_1651607001005/work nbgitpuller==1.1.0 nest-asyncio @ file:///home/conda/feedstock_root/build_artifacts/nest-asyncio_1648959695634/work networkx @ file:///home/conda/feedstock_root/build_artifacts/networkx_1655215393654/work notebook @ file:///home/conda/feedstock_root/build_artifacts/notebook_1654636967533/work notebook-shim @ file:///home/conda/feedstock_root/build_artifacts/notebook-shim_1646330736330/work numba @ file:///home/conda/feedstock_root/build_artifacts/numba_1655473324812/work numexpr @ file:///home/conda/feedstock_root/build_artifacts/numexpr_1658076419034/work numpy @ file:///home/conda/feedstock_root/build_artifacts/numpy_1653325310407/work oauthlib @ file:///home/conda/feedstock_root/build_artifacts/oauthlib_1643507977997/work openpyxl==3.0.10 packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1637239678211/work pamela==1.0.0 pandas==1.4.3 pandas-ta==0.3.14b0 pandocfilters @ file:///home/conda/feedstock_root/build_artifacts/pandocfilters_1631603243851/work parso @ file:///home/conda/feedstock_root/build_artifacts/parso_1638334955874/work partd @ file:///home/conda/feedstock_root/build_artifacts/partd_1617910651905/work pathspec==0.9.0 patsy @ file:///home/conda/feedstock_root/build_artifacts/patsy_1632667180946/work pexpect @ file:///home/conda/feedstock_root/build_artifacts/pexpect_1602535608087/work pickleshare @ file:///home/conda/feedstock_root/build_artifacts/pickleshare_1602536217715/work Pillow @ file:///home/conda/feedstock_root/build_artifacts/pillow_1657007160045/work platformdirs @ file:///home/conda/feedstock_root/build_artifacts/platformdirs_1657729053205/work plotly @ file:///home/conda/feedstock_root/build_artifacts/plotly_1656046979833/work pluggy @ file:///home/conda/feedstock_root/build_artifacts/pluggy_1648772594861/work prettytable @ file:///home/conda/feedstock_root/build_artifacts/prettytable_1651787307815/work prometheus-client @ file:///home/conda/feedstock_root/build_artifacts/prometheus_client_1649447152425/work prompt-toolkit @ file:///home/conda/feedstock_root/build_artifacts/prompt-toolkit_1656332401605/work protobuf==3.20.1 psutil @ file:///home/conda/feedstock_root/build_artifacts/psutil_1653089181607/work ptyprocess @ file:///home/conda/feedstock_root/build_artifacts/ptyprocess_1609419310487/work/dist/ptyprocess-0.7.0-py2.py3-none-any.whl pure-eval @ file:///home/conda/feedstock_root/build_artifacts/pure_eval_1642875951954/work pycares==4.2.1 pycodestyle @ file:///home/conda/feedstock_root/build_artifacts/pycodestyle_1615833610040/work pycosat @ file:///home/conda/feedstock_root/build_artifacts/pycosat_1649384799612/work pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1636257122734/work pycurl==7.45.1 pydocstyle @ file:///home/conda/feedstock_root/build_artifacts/pydocstyle_1621377123289/work pyflakes @ file:///home/conda/feedstock_root/build_artifacts/pyflakes_1616623675904/work Pygments @ file:///home/conda/feedstock_root/build_artifacts/pygments_1650904496387/work PyJWT @ file:///home/conda/feedstock_root/build_artifacts/pyjwt_1652398519695/work pylint @ file:///home/conda/feedstock_root/build_artifacts/pylint_1658157521144/work pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1643496850550/work pyparsing @ file:///home/conda/feedstock_root/build_artifacts/pyparsing_1652235407899/work pyrsistent @ file:///home/conda/feedstock_root/build_artifacts/pyrsistent_1649013351988/work PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1648857264958/work python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1626286286081/work python-json-logger @ file:///home/conda/feedstock_root/build_artifacts/python-json-logger_1602545356084/work python-lsp-jsonrpc @ file:///home/conda/feedstock_root/build_artifacts/python-lsp-jsonrpc_1618530352985/work python-lsp-server @ file:///home/conda/feedstock_root/build_artifacts/python-lsp-server_1628113199343/work pytoolconfig @ file:///home/conda/feedstock_root/build_artifacts/pytoolconfig_1656898078212/work pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1647961439546/work pytz-deprecation-shim @ file:///home/conda/feedstock_root/build_artifacts/pytz-deprecation-shim_1656249448407/work PyWavelets @ file:///home/conda/feedstock_root/build_artifacts/pywavelets_1649616405488/work PyYAML @ file:///home/conda/feedstock_root/build_artifacts/pyyaml_1648757090803/work pyzmq @ file:///home/conda/feedstock_root/build_artifacts/pyzmq_1656183556820/work requests @ file:///home/conda/feedstock_root/build_artifacts/requests_1656534056640/work retrying==1.3.3 rope @ file:///home/conda/feedstock_root/build_artifacts/rope_1656025934395/work rpy2 @ file:///home/conda/feedstock_root/build_artifacts/rpy2_1649599347730/work ruamel-yaml-conda @ file:///home/conda/feedstock_root/build_artifacts/ruamel_yaml_1653464396679/work ruamel.yaml @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml_1649033201098/work ruamel.yaml.clib @ file:///home/conda/feedstock_root/build_artifacts/ruamel.yaml.clib_1649013063403/work scikit-image @ file:///home/conda/feedstock_root/build_artifacts/scikit-image_1655254001151/work scikit-learn @ file:///home/conda/feedstock_root/build_artifacts/scikit-learn_1652976692230/work scipy @ file:///home/conda/feedstock_root/build_artifacts/scipy_1653073872310/work seaborn @ file:///home/conda/feedstock_root/build_artifacts/seaborn-split_1629095986539/work Send2Trash @ file:///home/conda/feedstock_root/build_artifacts/send2trash_1628511208346/work simplegeneric==0.8.1 six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work smmap==5.0.0 sniffio @ file:///home/conda/feedstock_root/build_artifacts/sniffio_1648819179288/work snowballstemmer @ file:///home/conda/feedstock_root/build_artifacts/snowballstemmer_1637143057757/work sortedcontainers @ file:///home/conda/feedstock_root/build_artifacts/sortedcontainers_1621217038088/work soupsieve @ file:///home/conda/feedstock_root/build_artifacts/soupsieve_1638550740809/work SQLAlchemy @ file:///home/conda/feedstock_root/build_artifacts/sqlalchemy_1656115934245/work sqlparse @ file:///home/conda/feedstock_root/build_artifacts/sqlparse_1631317292236/work stack-data @ file:///home/conda/feedstock_root/build_artifacts/stack_data_1655315839047/work statsmodels @ file:///home/conda/feedstock_root/build_artifacts/statsmodels_1654787107327/work sympy @ file:///home/conda/feedstock_root/build_artifacts/sympy_1647802543069/work tables @ file:///home/conda/feedstock_root/build_artifacts/pytables_1643135944604/work tblib @ file:///home/conda/feedstock_root/build_artifacts/tblib_1616261298899/work tenacity @ file:///home/conda/feedstock_root/build_artifacts/tenacity_1626090218611/work terminado @ file:///home/conda/feedstock_root/build_artifacts/terminado_1652790610172/work threadpoolctl @ file:///home/conda/feedstock_root/build_artifacts/threadpoolctl_1643647933166/work tifffile @ file:///home/conda/feedstock_root/build_artifacts/tifffile_1651666912743/work tinycss2 @ file:///home/conda/feedstock_root/build_artifacts/tinycss2_1637612658783/work toml @ file:///home/conda/feedstock_root/build_artifacts/toml_1604308577558/work tomli @ file:///home/conda/feedstock_root/build_artifacts/tomli_1644342247877/work tomlkit @ file:///home/conda/feedstock_root/build_artifacts/tomlkit_1657178191936/work toolz @ file:///home/conda/feedstock_root/build_artifacts/toolz_1657485559105/work tornado @ file:///home/conda/feedstock_root/build_artifacts/tornado_1648827254365/work tqdm @ file:///home/conda/feedstock_root/build_artifacts/tqdm_1649051611147/work traitlets @ file:///home/conda/feedstock_root/build_artifacts/traitlets_1655411388954/work typing_extensions @ file:///home/conda/feedstock_root/build_artifacts/typing_extensions_1656706066251/work tzdata @ file:///home/conda/feedstock_root/build_artifacts/python-tzdata_1647621564023/work tzlocal @ file:///home/conda/feedstock_root/build_artifacts/tzlocal_1656259936310/work ujson @ file:///home/conda/feedstock_root/build_artifacts/ujson_1653057323486/work unicodedata2 @ file:///home/conda/feedstock_root/build_artifacts/unicodedata2_1649111910890/work urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1657224465922/work wcwidth @ file:///home/conda/feedstock_root/build_artifacts/wcwidth_1600965781394/work webencodings==0.5.1 websocket-client @ file:///home/conda/feedstock_root/build_artifacts/websocket-client_1655796432389/work Werkzeug @ file:///home/conda/feedstock_root/build_artifacts/werkzeug_1651670883478/work widgetsnbextension @ file:///home/conda/feedstock_root/build_artifacts/widgetsnbextension_1655939017940/work wrapt @ file:///home/conda/feedstock_root/build_artifacts/wrapt_1651495243689/work xlrd @ file:///home/conda/feedstock_root/build_artifacts/xlrd_1610224409810/work XlsxWriter==3.0.2 yapf @ file:///home/conda/feedstock_root/build_artifacts/yapf_1641487982943/work yarl==1.7.2 zict @ file:///home/conda/feedstock_root/build_artifacts/zict_1651156074437/work zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1649012893348/work

welcome[bot] commented 1 year ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

farcila commented 1 year ago

We are experiencing the same Issue @phys119, did you find a workaround?

phys119 commented 1 year ago

Nothing very pretty. I made a copy of the template and pushed that to the repository as well. Then gave those students a link to the copy. Very ugly. Thinking about it again, you could probably have the student open a terminal, cd into the local repository and git checkout template.ipynb to restore the pristine template. I hesitate to do that for my current class - git is out of scope...

farcila commented 1 year ago

hm, ours is an introductory course so I think we can also rule out students running git commands. The odder part is that this behavior persists even after deleting the ipynb_checkpoints folder

phys119 commented 1 year ago

It looks to me that when you click on an nbgitpuller link, changes are committed to the local repository first, before updates are pulled - so the student's deletions are stored in the repository as a commit which gets merged into the pulled file.

Another poor and somewhat dangerous idea for a workaround is to create a notebook that does the cd and git checkout commands as shell commands - so the student wouldn't have to open a terminal, they'd just have to execute a cell in a notebook. This is probably a terrible idea though, since it seems like a great pathway for people to lose work inadvertently. I suppose your cell could back up the notebook before it wipes it out, or even check that the template is smaller than its supposed to be, or something...