Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you hide code cell outputs in Google Colab?

Is there a way to hide a single code cell's output in Google Colab?

No one needs to see the sea of pip logs when we install things:

enter image description here

If you look at the screenshot you'll see I tried to apply one of the solutions from this similar Stack Overflow question: https://stackoverflow.com/a/48084050/1762493

I tried applying TagRemovePreprocessor.remove_single_output_tags as a #comment, a @@Magic, and a !command but those don't work with this line.

I checked Colab's "Welcome" and "Resource" notebooks but didn't notice anything there for deeper notebook settings: https://colab.research.google.com/notebooks/welcome.ipynb

Is this even possible?

like image 648
Mikeumus Avatar asked Oct 18 '19 19:10

Mikeumus


People also ask

How do I view full output on Google Colab?

I just realized that you can go to the bottom left corner of the screen and click the button (if you hover over you see that it says "command palette"), then search "fullscreen" you find the button that says view output "fullscreen".


2 Answers

In this case you can just use

!pip install -q gwpy

In general, you can start the cell with %%capture

%%capture
# the rest of your code
like image 76
korakot Avatar answered Sep 25 '22 13:09

korakot


I found this answer and applied it successfully: https://serverfault.com/a/41968/328943

Simply adding &> /dev/null to the tail of any command will silence its output outside of any errors that may arise.

Like so:

!pip install gwpy &> /dev/null

like image 33
Mikeumus Avatar answered Sep 26 '22 13:09

Mikeumus