Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Support notebook target #2410

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ def explore(self):
params = (self._get_eval_json()+"\n", self.data["test_data"], self, )
# Suppress visualization output if 'none' target is set
from ...visualization._plot import _target
from ...visualization._plot import show
if _target == 'none':
return
if _target == 'notebook':
return show()
_thread.start_new_thread(_start_process, params)


Expand Down
7 changes: 4 additions & 3 deletions src/python/turicreate/visualization/_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ def set_target(target='auto'):
otherwise launch a native GUI window.
* 'browser': opens a web browser pointing to http://localhost.
* 'gui': always launch a native GUI window.
* 'notebook': launch in a notebook.
* 'none': prevent all visualizations from being displayed.
"""
global _target
if target not in ['auto', 'browser', 'gui', 'none']:
raise ValueError("Expected target to be one of: 'auto', 'browser', 'gui', 'none'.")
if target not in ['auto', 'browser', 'gui', 'notebook', 'none']:
raise ValueError("Expected target to be one of: 'auto', 'browser', 'gui', 'notebook', 'none'.")
_target = target


Expand Down Expand Up @@ -144,7 +145,7 @@ def show(self):

# If auto target is set, try to show inline in Jupyter Notebook
try:
if _target == 'auto' and \
if (_target == 'auto' or _target == 'notebook') and \
get_ipython().__class__.__name__ == "ZMQInteractiveShell":
self._repr_javascript_()
return
Expand Down