Repository: bokeh/bokeh

Issue:
restore `Chart(server=True)`
server=True mode was commented out at some point on master, it needs to be restored (or replaced with something that makes more sense with the new server, possibly? I haven't investigated the big picture).

See https://github.com/bokeh/bokeh/blob/2a3ad528279e3b329857d712b61fcca536a59cf8/bokeh/charts/chart.py#L123-L128

For how to fix it up: https://github.com/bokeh/bokeh/wiki/Porting-guide:-new-Bokeh-server



Discussion:
I think we should just remove this argument and use standard `bokeh.io` APIs for serving charts. ping @bokeh/core 

@bokeh/core shall I go ahead in this direction and remove `Chart.show`, and all the support for `document`, `notebook` and `server` arguments?


Resolving patch:
diff --git a/bokeh/charts/chart.py b/bokeh/charts/chart.py
--- a/bokeh/charts/chart.py
+++ b/bokeh/charts/chart.py
@@ -20,10 +20,10 @@
 
 from __future__ import absolute_import
 
+import warnings
+from six import iteritems
 from collections import defaultdict
-
 import numpy as np
-from six import iteritems
 
 from ..core.enums import enumeration, LegendLocation
 from ..document import Document
@@ -42,6 +42,7 @@
 from ..util.notebook import publish_display_data
 from ..util.serialization import make_id
 from ..util.future import with_metaclass
+from ..util.deprecate import deprecated
 from ..themes import Theme
 
 #-----------------------------------------------------------------------------
@@ -117,19 +118,6 @@ class Chart(Plot):
     Height of the rendered chart, in pixels.
     """)
 
-    filename = Either(Bool(False), String, help="""
-    A name for the file to save this chart to.
-    """)
-
-    server = Either(Bool(False), String, help="""
-    A name to use to save this chart to on server.
-    """)
-
-    notebook = Either(Bool(False), String, help="""
-    Whether to display the plot inline in an IPython/Jupyter
-    notebook.
-    """)
-
     title_text_font_size = Override(default={ 'value' : '14pt' })
 
     responsive = Bool(False, help="""
@@ -140,6 +128,8 @@ class Chart(Plot):
 
     _defaults = defaults
 
+    __deprecated_attributes__ = ('filename', 'server', 'notebook')
+
     def __init__(self, *args, **kwargs):
         # pop tools as it is also a property that doesn't match the argument
         # supported types
@@ -159,20 +149,6 @@ def __init__(self, *args, **kwargs):
         self._scales = defaultdict(list)
         self._tooltips = []
 
-        # Add to document and session if server output is asked
-        _doc = None
-        if _doc:
-            self._doc = _doc
-        else:
-            self._doc = Document()
-
-        # if self._options.server:
-        #     _session = None
-        #     if _session:
-        #         self._session = _session
-        #     else:
-        #         self._session = Session()
-
         self.create_tools(self._tools)
 
     def add_renderers(self, builder, renderers):
@@ -322,46 +298,53 @@ def make_grid(self, dimension, ticker):
 
         return grid
 
-    def show(self):
-        """Main show function.
-
-        It shows the plot in file, server and notebook outputs.
-        """
-        # Add to document and session
-        if self.server:
-            if self.server is True:
-                self._servername = "untitled_chart"
-            else:
-                self._servername = self.server
-
-            self._session.use_doc(self._servername)
-            self._session.load_document(self._doc)
-
-        if not self._doc._current_plot == self:
-            self._doc._current_plot = self
-            self._doc.add_root(self)
 
-        if self.filename:
-            if self.filename is True:
-                filename = "untitled"
-            else:
-                filename = self.filename
-
-            with open(filename, "w") as f:
-                f.write(file_html(self._doc, INLINE, self.title))
-            print("Wrote %s" % filename)
-            view(filename)
-        elif self.filename is False and \
-                        self.server is False and \
-                        self.notebook is False:
-            print("You must provide a filename (filename='foo.html' or"
-                  " .filename('foo.html')) to save your plot.")
-
-        if self.server:
-            self.session.store_document(self._doc)
-            link = self._session.object_link(self._doc.context)
-            view(link)
-
-        if self.notebook:
-            from bokeh.embed import notebook_div
-            publish_display_data({'text/html': notebook_div(self)})
+    @property
+    def filename(self):
+        warnings.warn("Chart property 'filename' was deprecated in 0.11 \
+            and will be removed in the future.")
+        from bokeh.io import output_file
+        output_file("default.html")
+
+    @filename.setter
+    def filename(self, filename):
+        warnings.warn("Chart property 'filename' was deprecated in 0.11 \
+            and will be removed in the future.")
+        from bokeh.io import output_file
+        output_file(filename)
+
+    @property
+    def server(self):
+        warnings.warn("Chart property 'server' was deprecated in 0.11 \
+            and will be removed in the future.")
+        from bokeh.io import output_server
+        output_server("default")
+
+    @server.setter
+    def server(self, session_id):
+        warnings.warn("Chart property 'server' was deprecated in 0.11 \
+            and will be removed in the future.")
+        from bokeh.io import output_server
+        if session_id:
+            if isinstance(session_id, bool):
+                session_id='default'
+            output_server(session_id)
+
+    @property
+    def notebook(self):
+        warnings.warn("Chart property 'notebook' was deprecated in 0.11 \
+            and will be removed in the future.")
+        from bokeh.io import output_notebook
+        output_notebook()
+
+    @notebook.setter
+    def notebook(self, flag):
+        warnings.warn("Chart property 'notebook' was deprecated in 0.11 \
+            and will be removed in the future.")
+        from bokeh.io import output_notebook
+        output_notebook()
+
+    @deprecated("Bokeh 0.11", "bokeh.io.show")
+    def show(self):
+        import bokeh.io
+        bokeh.io.show(self)
diff --git a/bokeh/charts/utils.py b/bokeh/charts/utils.py
--- a/bokeh/charts/utils.py
+++ b/bokeh/charts/utils.py
@@ -108,97 +108,6 @@ def polar_to_cartesian(r, start_angles, end_angles):
 
     return zip(*points)
 
-
-# ToDo: Reconsider whether to utilize this, vice Chart
-# TODO: Experimental implementation. This should really be a shared
-#       pattern between plotting/charts and other bokeh interfaces.
-#       This will probably be part of the future charts re-design
-#       to make them inherit from plot (or at least be closer to).
-#       In this was both charts and plotting could share figure,
-#       show, save, push methods as well as VBox, etc...
-class Figure(object):
-    def __init__(self, *charts, **kwargs):
-        self.filename = kwargs.pop('filename', None)
-        self.server = kwargs.pop('server', None)
-        self.notebook = kwargs.pop('notebook', None)
-        self.title = kwargs.pop('title', '')
-        self.children = kwargs.pop('children', None)
-        self.charts = charts
-        self.doc = Document()
-        self.doc.hold(True)
-        self._plots = []
-
-        # if self.server:
-        #     self.session = Session()
-        #     self.session.use_doc(self.server)
-        #     self.session.load_document(self.doc)
-
-        if self.children:
-            from bokeh.models import VBox
-            self.doc.add_root(VBox(children=self.children))
-
-        self.plot = None
-        for i, chart in enumerate(self.charts):
-            chart.doc = self.doc
-            if self.server:
-                chart.session = self.session
-
-            # Force the chart to create the underlying plot
-            chart._setup_show()
-            chart._prepare_show()
-            chart._show_teardown()
-
-            if not self.title:
-                self.title = chart.chart.title
-
-            self._plots += chart.chart._plots
-
-        # reset the pot title with the one set for the Figure
-        self.doc._current_plot.title = self.title
-
-    def show(self):
-        """Main show function.
-
-        It shows the Figure in file, server and notebook outputs.
-        """
-        show(self, self.title, self.filename, self.server, self.notebook)
-
-
-def show(obj, title='test', filename=False, server=False, notebook=False, **kws):
-    """ 'shows' a plot object, by auto-raising the window or tab
-    displaying the current plot (for file/server output modes) or displaying
-    it in an output cell (IPython notebook).
-
-    Args:
-        obj (Component object, optional): it accepts a plot object and just shows it.
-
-    """
-    if filename:
-        if filename is True:
-            filename = "untitled"
-        else:
-            filename = filename
-
-        with open(filename, "w") as f:
-            f.write(file_html(obj.doc, INLINE, title))
-        print("Wrote %s" % filename)
-        view(filename)
-
-    elif filename is False and server is False and notebook is False:
-        print("You have to provide a filename (filename='foo.html' or"
-              " .filename('foo.html')) to save your plot.")
-
-    if server:
-        obj.session.store_document(obj.doc)
-        link = obj.session.object_link(obj.doc.context)
-        view(link)
-
-    if notebook:
-        from bokeh.embed import notebook_div
-        for plot in obj._plots:
-            publish_display_data({'text/html': notebook_div(plot)})
-
-
 def ordered_set(iterable):
     """Creates an ordered list from strings, tuples or other hashable items.
 


Test patch:
diff --git a/bokeh/charts/tests/test_chart.py b/bokeh/charts/tests/test_chart.py
--- a/bokeh/charts/tests/test_chart.py
+++ b/bokeh/charts/tests/test_chart.py
@@ -44,8 +44,7 @@ def setUp(self):
             title="title", xlabel="xlabel", ylabel="ylabel",
             legend="top_left", xscale="linear", yscale="linear",
             width=800, height=600, tools=True,
-            filename=False, server=False,
-            notebook=False, responsive=True,
+            responsive=True,
             xgrid=True, ygrid=False
         )
 
@@ -118,7 +117,7 @@ def test_chart_tools_linear(self, mock_warn):
         base_args = dict(
             title="title", xlabel="xlabel", ylabel="ylabel",
             legend="top_left", xscale="linear", yscale="linear", xgrid=True, ygrid=True,
-            width=800, height=600, filename=False, server=False, notebook=False
+            width=800, height=600,
         )
         expected = [
             [PanTool,  WheelZoomTool, BoxZoomTool, PreviewSaveTool, ResizeTool, ResetTool, HelpTool],