rubin-dp0 / Support

Submit Github Issues related to DP0
MIT License
1 stars 3 forks source link

File Load Error for 01_Intro_to_DP0_Notebooks.ipynb #9

Closed MelissaGraham closed 3 years ago

MelissaGraham commented 3 years ago

Describe the bug In my /home/melissagraham/notebooks/tutorial-notebooks directory, when I try to open the first tutorial notebook (by double-clicking in the left-hand file directory menu), I get this error:

File Load Error for 01_Intro_to_DP0_Notebooks.ipynb
Unreadable Notebook: /home/melissagraham/notebooks/tutorial-notebooks/01_Intro_to_DP0_Notebooks.ipynb NotJSONError('Notebook does not appear to be JSON: \'{\\n "cells": [\\n {\\n "cell_type": "m...')

But other notebooks in that directory open fine. I first noticed this yesterday, but it persists today.

To Reproduce Log in to the RSP, launch a Notebook server (medium), use the left-hand menu to navigate to my /notebooks/tutorial-notebooks/ directory, and double-click on 01_Intro_to_DP0_Notebooks.ipynb.

Expected behavior Expected the notebook to open like the other notebooks open. I have a separate directory where I create/edit these tutorials, and the first notebook opens fine there (from main and prod branches).

Desktop (please complete the following information): Mac OS X, Chrome

MelissaGraham commented 3 years ago

Check the status of the notebook that is not loading. Open a terminal and navigate to notebooks/tutorial-notebooks, and do git status. In red, if it says both modified: 01_Intro_to_DP0_Notebooks.ipynb, the following describes why. These instructions will work for any of the notebooks in notebooks/tutorial-notebooks. These instructions will NOT work for notebooks in any other directory.

What is happening? Changes have been made to this file (executing the notebook counts as making changes, and note that Jupyter auto-saves changes on a ~2 minute cadence), but Rubin staff have also updated it (e.g., bug fixes). Since the file has been twice modified, git has gone ahead and annotated file with all the conflicting lines between the two versions. This essentially ruins a ipynb file's functionality (but it is a very useful built-in git feature for, e.g., ascii and code files). Do a git diff 01_Intro_to_DP0_Notebooks.ipynb and all the differences will be listed.

Recommended Solution

  1. Use the terminal to restore the version in which you made changes: git restore --staged 01_Intro_to_DP0_Notebooks.ipynb. This takes it out of 'staged' status and will avoid future errors.
  2. At this point, if you want to keep your changes, copy the file to a new name in your home directory: cp 01_Intro_to_DP0_Notebooks.ipynb ../../01_mine.ipynb.
  3. Restore the version updated by Rubin staff: git restore 01_Intro_to_DP0_Notebooks.ipynb. Now your notebooks/tutorial-notebooks directory only contains the most up-to-date versions of the tutorial notebooks, with none of your changes.

Alternative Solution If the notebooks in notebooks/tutorial-notebooks are still not loading, it is safe to delete the entire directory, log out, and log back in. You will then have a full and fresh notebooks/tutorial-notebooks directory.

  1. Use the terminal to navigate to notebooks, then do: rm -rf tutorial/notebooks.
  2. File --> Close and Shutdown Terminal
  3. File --> Save all, Exit, and Log Out
  4. Log back in to the Notebook Aspect and start a new server.
  5. See that your notebooks/tutorial-notebooks is fully restored.