[Tune] Fix Jupyter reporter with older IPython (#24695)

Fixes `JupyterNotebookReporter` not working with older IPython versions (eg. 5.5.0, installed on Google Colab).
This commit is contained in:
Antoni Baum 2022-05-12 13:27:35 +02:00 committed by GitHub
parent b0fa9d6766
commit 8af1cc1ba1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -546,12 +546,12 @@ class JupyterNotebookReporter(TuneReporterBase, RemoteReporterMixin):
self.display(progress_str)
def display(self, string: str) -> None:
from IPython.core.display import display, HTML
from IPython.display import display, HTML, clear_output
if not self._display_handle:
self._display_handle = display(
HTML(string), display_id=True, clear=self._overwrite
)
if self._overwrite:
clear_output(wait=True)
self._display_handle = display(HTML(string), display_id=True)
else:
self._display_handle.update(HTML(string))