JupyterLab Notebook cells going missing - jupyter-lab

I am using quite large notebooks in JupyterLab to run Python code. They contain many Markdown cells with text and some images. The problem I am having is that when I close the Notebook and reopen, some of these cells have collapsed and can't be expanded (show as a horizontal line). Sometimes I will get a message telling me how many cells are hidden but they can't be expanded. Others seem to have disappeared completely.
Occasionally, I can get some cells to expand if I reload the page. I thought it may have been because I had lots of Markdown header levels and those too far down the hierarchy were collapsing. However, even removing many of the header levels has not solved the problem.
Have others had this issue and has anyone been able to resolve it? Thanks!
Edit: Thank you Vinson. My Jupyter Version is Version 3.1.7, running on Google Chrome (Version 92.0.4515.159 (Official Build) (64-bit)), on Windows machine.

This was fixed in JupyterLab 3.1.10 (this PR) released on 2021-09-01 - the issue should disappear after you upgrade and restart JupyterLab:
# (or conda-forge equivalent if you use conda/mamba)
pip install -U "jupyterlab>=3.1.10"
If however, you are unable to update right now, you can use a workaround of disabling the placeholder rendering, by going to Advanced Settings Editor -> Notebook and in the right pane (User Preferences) paste the following:
{
"renderCellOnIdle": false,
"numberCellsToRenderDirectly": 10000000000000
}
then press save and reload JupyterLab.

I do not know how to fix this with conda. But option 2 is working for me. For those who are not family with the deep tech, you can try these, two extran configure there are shown the line numbers.
{
"markdownCellConfig": {
"lineNumbers": true
},
"codeCellConfig": {
"lineNumbers": true
},
"renderCellOnIdle": false,
"numberCellsToRenderDirectly": 10000000000000
}

Related

VS Code input and variables don't show frequently in Interactive window

I have started using VS Code for work instead of Anaconda and there are some weird observations which I am not able to figure out.
If I try to execute some code in a cell in the interactive window, many-a-times, only output remains available and the input code automatically gets hidden. For eg. I type the following and execute:-
And this is what I see at the window:-
Similarly, there are some variables which I have already defined but they don't show up in the Jupyer:Variables tab. For eg. there is a variable _link_name_to_index which is not visible in the tab as shown below:-
However, when I execute the same in the window, I can see the values of the dictionary as expected:-
Maybe it is just a matter of some settings, but I still couldn't find out which one. Also, I know I have put a lot of images, because it is not a code doubt as such, rather more of a tool doubt. I have taken only one particular example here, but I face this issue often. I am using VS Code version 1.75.0 in Ubuntu 20.04, using Python 3.9.12 in a virtual environment, if it helps.
This is a bug in the latest Version of VSCode (1.75). It is tracked in this issue. For now, the only option seems to be downgrading to v1.74.x

Jupyter Notebook didn't save for over a day. How can I recover lost work?

I've lost a day's work in Jupyter Notebook because it didn't autosave. As I was working, I would click on File > Save and Checkpoint to be safe. I closed the notebook when I finished working and when I tried reopening it, I see that essentially all my work is gone and it says Last Checkpoint: a day ago (autosaved) next to the filename. I now realize that I had been working for a long time on the notebook with an orange box with some kind of error message. I'm sorry that I can't remember the specific message right now, but I think it was something involving POS or POST or POSIT ...?. I saw Trusted next to the error message, so I must've thought things were OK.
I tried opening the filename-checkpoint.ipynb file within the .ipynb_checkpoints folder but it's blank. I looked up a possible solution on Recovering from a Jupyter Disaster, but it requires SQL, which I don't know. Is there any hope for recovering my work? I realize that this is probably a rookie mistake, but I'm pretty new at this.
Thanks
PS: I'm running Python3 on MacOS
Hope you've already found how to recover lost work from Jupyter notebook work. If not, try the following:
Go to Anaconda Navigator (the green circle!)
Launch a Jupyter Lab
In Jupyter Lab, open a Terminal window
Launch iPython in the terminal by typing ipython and hitting enter
Hit Up arrow
All your code are stored in history and each cell compilation that you would've done in the past shows up there.
Copy+Paste it back to a new Jupyter notebook and you are ready to go again!
If you want to copy/paste.
After running terminal and ipython, page_up yo code you want. Click right button on a mouse, then Watch the elements code. Now you can select code, copy and paste it.
If you don't have Anaconda Navigator you can do access the same data the manual way:
open a new ipython terminal
type %history -g -f history.txt
This will output the entire history of edits which are saved in history.sqlite in your IPython profile folder. You can scroll down to the bottom to find your most recent edits.
You can also just explore the history.sqlite directly, which is located in your IPython profile. The profile should be inside .ipython in your user directory (windows and linux).
Thanks to Christian Long's answer on another question for providing this info.

Pen Width font turning to White automatically (Jaspersoft Studio 6.4 Arch Linux Gnome)

Im having some glitching issues while using JasperSoft Studio. (using the latest version from the AUR).Im using GNOME.
Steps to reproduce :
Add Text Field. Select it.
Go to Properties -> Borders -> Click on a border on the square.
The Pen Width (1.0 by default) appears for an instant and then "disappears" (Its still there as I can select it but i think the font color becomes white)
This can be temprorarily resolved by going to preferences and toggling the theme from classic -> GTK or vice versa. The resolution exists only for the current report and does not remain for other opened reports. Really annoying bug.
Ive tried Adwaita and GTK other themes etc...but no use. The bug persists.
I have a version 6.1.1 of Jaspersoft Studio on another machine running the latest UBUNTU GNOME and it works near perfectly.I tried running this version of Jasper on arch using various settings but it stops working as soon as I open a JRXML file. Nothing is clickable and I have to kill the process. I am guessing its a GTK issue.
I dont want to go back to using Ubuntu as I love the Arch experience. Can someone help me to run the AUR version of Arch without this glitch.
And if you think 6.1.1 should run fine on Arch...can someone help me overcome the GTK issue (Ive already tried export SWT_GTK3=0; but it doesnt work)
Thanks.
Try editing the runjss.sh script (probably in /opt/jaspersoftstudio) and add the line
export SWT_GTK3=0
Then try running JSS via that script and see if it helps.
I haven't had the same issue as you but I've been having a lot of Gnome-related problems and I'm using the same combination as your - Arch (Manjaro) and Gnome with JasperSoft Studio 6.4.3. Works perfectly since I added that line.
You can also edit the .desktop file to exec runjss instead of the default exec line.

Highlight to select and Middle-button to paste in jupyter notebook?

In Jupyter Notebook, when I highlight text either from within a cell in the notebook or from outside the notebook, Middle-Button click doesn't paste anything as it is supposed to do in many other applications in linux. Is there any setting that would allow one to be able to paste with a Middle-Button click into an Ipython or Jupyter Notebook?
I'm using the notebook in firefox if that matters.
The fact that you're using Firefox definitely matters. See this issue on CodeMirror (CodeMirror is the text editor that Juypter uses): Issue #931
In that thread, it references this Firefox issue: https://bugzilla.mozilla.org/show_bug.cgi?id=846674
It seems as though the issue has only recently been fixed, so it may take a little bit to trickle into CodeMirror. You may want to comment on the issue in CodeMirror to inform them that the issue has been fixed on FF and it might prompt them to investigate.
However, Jupyter doesn't automatically use the most recent version of CodeMirror so again you may have to wait a while. If this issue is truly critical then I suggest switching to another browser.

Does the IPython Notebook have "initialization cells"?

When I open a saved IPython Notebook, I need to evaluate all the cells with imports, function definitions etc. to continue working on the session. It is convenient to click Cell > Run All to do this. But what If I do not want to re-evaluate all calculations? Do I need to pick the cells to evaluate by hand each time?
For this problem, Mathematica has the concept of "initialization cells". You can mark some cells in the notebook as initialization cell, and then perform "evaluate initialization cells" after opening the notebook.
Does the IPython Notebook have a similar solution?
First, when you open an IPython notebook, this does not mean the state of the kernel is lost,
unless you restarted the server or explicitly stop the kernel.
Otherwise, there are no marked cell, but there is a "run until here" on dev version.
Also if you are using dev version, using Cell Toolbar /metadata and I would say ~30 line of javascript it should be doable.
I suggest you open an enhancement request on main issue tracker. This could typically be made as an extension during a sprint and/or a blog post to explain internal of notebook.
If you're using the latest and greatest of the notebooks (mine is > 4.1), the feature you requested is available through an extension.
The extensions, as well as an interface that can be conveniently used to enable/disable each individual extension, can be installed as follows
$ git clone https://github.com/ipython-contrib/IPython-notebook-extensions.git
$ cd IPython-notebook-extensions
$ ./setup.py
When you have installed the extension, start the notebook server
$ cd ; jupyter-notebook < /dev/null > .jupyter.log 2>&1 &
and go to the extension management page
$ xdg-open http://localhost:8888/nbextensions
In the recently opened browser window, enable the "Initialization cells" extension.
If you open now a notebook of yours, in the toolbar you will see a new icon, similar to a hand-held calculator and in the View/Cell Toolbar a new entry, Initialisation Cell.
Enable this menu entry and click on the cells' toolbar which ones you want to mark as an initialization cell (possibly remove the cells' toolbar) and click on the icon previously described...
When you load a notebook, the initialization cells are automatically run, so that if you want you can place them in a convenient place, say the end of the notebook if you're like me...

Resources