![]() ![]() ![]() Somehow your entire home directory was deleted. Um, actually you didn’t delete the notebook. Run a query similar to the following to see which sessions you last ran: select ssion, sessions.start, sessions.end, history.source from sessions join history using (session) where start > '2019–02–27' and start myoutput.py jupytext - to ipynb myoutput.py If the sqlite3 command line is not install you can get it from your system package manager or by simply running something like # using conda conda install sqlite3 # using apt sudo apt-get update & sudo apt-get install sqlite3 # using yum sudo yum install sqlite3 # using brew brew install sqlite3 Start a sqlite session by doing the following in a bash shell. To find the right session we can generally run some queries like this to narrow on on the particular session we want. The remark field looks like it shows promise, but it is empty, nothing to see there. The ` end` timestamp might be set, but it is best to not rely on it. This corresponds to the time where you restarted the kernel for a notebook. Using the sessions ` start` timestamp we can filter the list of sessions to ones related to when we started our session. TABLE history (session integer, line integer, source text, source_raw text, PRIMARY KEY (session, line)) TABLE sessions ( session integer primary key autoincrement, start timestamp, end timestamp, num_cmds integer, remark text) There may be others, but they are likely empty, and uninteresting. There are two tables of interest here ` session` and ` history`. You can generally do this just by copying the file somewhere else. Now is a very good time to make a backup of the ` history.sqlite` database. You’re just going to have to redo that sadly. ![]() No non-code cells All of your beautifully written markdown prose is gone.But if you can recover the code, you should be able to rerun your notebook and get output. No cell output Since this is a listing of history of command sent to the kernel, you do not have results of a command.There is a session_id though which will have to suffice. No file names Since this is the history of the kernel session there is no way to associate a particular piece of code with a file as there is no mentions of filenames in this history table.Odds are you’ve never removed anything from then history so your code could well be in there. This contains every command you’ve ever sent to the IPython kernel and not actively removed from history. Inside this directory is a sqlite database: These can be found in: ~/.ipython/profile_default This is used to drive things like CTRL-R searches in the terminal but can also be used to recover code that has been executed IPython by default stores all the commands you’ve issued to it in a sqlite database. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |