Is there a way to clear the cell output during runtime in an Jupyter notebook executed in VS Code using the new Python extension (which supports running Jupyter notebooks in VS Code)?
Ususally I use IPython.display.clear_output() to acomplish that when executing Jupyter notebooks in a web browser, for instance to get a progress bar for long data imports, something along those lines. VS Code for some reason seems to ignore this, which results in a VERY long cell output potentially crashing the kernel during runtime.
Edit (a small example):
from IPython.display import display, Markdown, HTML, clear_output
from time import sleep
def progress(cur, tot):
clear_output(True)
display(
HTML(
'''
<div style="float:left; margin-right:5px;">
<div style="font-weight:bold;">Dataset:</div>
</div>
<div style="float:left; margin-right:5px; text-align:left;">
<div>{:d} / {:d}</div>
</div>
'''.format(cur, tot)
),
HTML('<progress value=\"{:d}\" max=\"{:d}\" style=\"width:100%; height:1.5em;\"></progress>'.format(cur, tot))
)
for i in range(10):
progress(i, 10)
sleep(0.2)
clear_output()
display(Markdown('Done!'))