Repository: bokeh/bokeh

Issue:
investigate removing autoadd, autosave, autopush
I think these options are either unused, or should just always behave as their current defaults (so can be removed)


Discussion:
I personally never used either of those.

Resolving patch:
diff --git a/bokeh/core/state.py b/bokeh/core/state.py
--- a/bokeh/core/state.py
+++ b/bokeh/core/state.py
@@ -76,17 +76,9 @@ class State(object):
 
         session_id (str) : a default session ID for Bokeh server output
 
-        autoadd (bool) : whether certain functions automatically add roots to the document
-
-        autosave (bool) : whether certain functions automatically save the file
-
-        autopush (bool): whether certain functions automatically push to the server
-
     """
 
     def __init__(self):
-        # TODO (havocp) right now there's no way to turn off autoadd
-        self._autoadd = True
         self.last_comms_handle = None
         self.reset()
 
@@ -132,29 +124,11 @@ def server_url(self):
     def app_path(self):
         return self._session_coords.app_path
 
-    @property
-    def autoadd(self):
-        return self._autoadd
-
-    @autoadd.setter
-    def autoadd(self, val):
-        self._autoadd = val
-
-    @property
-    def autosave(self):
-        return self._autosave
-
-    @property
-    def autopush(self):
-        return self._autopush
-
     def _reset_keeping_doc(self):
         self._file = None
         self._notebook = False
         self._session_coords = _SessionCoordinates(dict())
         self._server_enabled = False
-        self._autosave = False
-        self._autopush = False
 
     def _reset_with_doc(self, doc):
         self._document = doc
@@ -172,7 +146,7 @@ def reset(self):
         '''
         self._reset_with_doc(Document())
 
-    def output_file(self, filename, title="Bokeh Plot", autosave=False, mode="cdn", root_dir=None):
+    def output_file(self, filename, title="Bokeh Plot", mode="cdn", root_dir=None):
         """Output to a standalone HTML file.
 
         Does not change the current Document from curdoc(). File,
@@ -185,12 +159,6 @@ def output_file(self, filename, title="Bokeh Plot", autosave=False, mode="cdn",
 
             title (str, optional) : a title for the HTML document
 
-            autosave (bool, optional) : whether to automatically save (default: False)
-                If True, then Bokeh plotting APIs may opt to automatically
-                save the file more frequently (e.g., after any plotting
-                command). If False, then the file is only saved upon calling
-                :func:`show` or :func:`save`.
-
             mode (str, optional) : how to include BokehJS (default: ``'cdn'``)
                 One of: ``'inline'``, ``'cdn'``, ``'relative(-dev)'`` or
                 ``'absolute(-dev)'``. See :class:`bokeh.resources.Resources` for more details.
@@ -201,8 +169,7 @@ def output_file(self, filename, title="Bokeh Plot", autosave=False, mode="cdn",
 
         .. warning::
             This output file will be overwritten on every save, e.g., each time
-            show() or save() is invoked, or any time a Bokeh plotting API
-            causes a save, if ``autosave`` is True.
+            show() or save() is invoked.
 
         """
         self._file = {
@@ -210,7 +177,6 @@ def output_file(self, filename, title="Bokeh Plot", autosave=False, mode="cdn",
             'resources' : Resources(mode=mode, root_dir=root_dir),
             'title'     : title
         }
-        self._autosave = autosave
 
         if os.path.isfile(filename):
             logger.info("Session output file '%s' already exists, will be overwritten." % filename)
@@ -231,8 +197,7 @@ def output_notebook(self):
         """
         self._notebook = True
 
-    def output_server(self, session_id=DEFAULT_SESSION_ID, url="default",
-                      app_path='/', autopush=False):
+    def output_server(self, session_id=DEFAULT_SESSION_ID, url="default", app_path='/'):
         """Store Bokeh plots and objects on a Bokeh server.
 
         File, server, and notebook output may be active at the
@@ -251,12 +216,6 @@ def output_server(self, session_id=DEFAULT_SESSION_ID, url="default",
 
             app_path (str, optional) : relative path of the app on the Bokeh server (default: "/")
 
-            autopush (bool, optional) : whether to automatically push (default: False)
-                If True, then Bokeh plotting APIs may opt to automatically
-                push the document more frequently (e.g., after any plotting
-                command). If False, then the document is only pushed upon calling
-                :func:`show` or :func:`push`.
-
         Returns:
             None
 
@@ -268,5 +227,4 @@ def output_server(self, session_id=DEFAULT_SESSION_ID, url="default",
                                                         url=url,
                                                         app_path=app_path))
 
-        self._autopush = autopush
         self._server_enabled = True
diff --git a/bokeh/io.py b/bokeh/io.py
--- a/bokeh/io.py
+++ b/bokeh/io.py
@@ -97,7 +97,7 @@ def update(self, doc, json):
         self._json[doc] = json
 
 
-def output_file(filename, title="Bokeh Plot", autosave=False, mode="cdn", root_dir=None):
+def output_file(filename, title="Bokeh Plot", mode="cdn", root_dir=None):
     '''Configure the default output state to generate output saved
     to a file when :func:`show` is called.
 
@@ -111,12 +111,6 @@ def output_file(filename, title="Bokeh Plot", autosave=False, mode="cdn", root_d
 
         title (str, optional) : a title for the HTML document (default: "Bokeh Plot")
 
-        autosave (bool, optional) : whether to automatically save (default: False)
-            If True, then Bokeh plotting APIs may opt to automatically
-            save the file more frequently (e.g., after any plotting
-            command). If False, then the file is only saved upon calling
-            :func:`show` or :func:`save`.
-
         mode (str, optional) : how to include BokehJS (default: ``'cdn'``)
             One of: ``'inline'``, ``'cdn'``, ``'relative(-dev)'`` or
             ``'absolute(-dev)'``. See :class:`bokeh.resources.Resources` for more details.
@@ -134,14 +128,12 @@ def output_file(filename, title="Bokeh Plot", autosave=False, mode="cdn", root_d
 
     .. warning::
         This output file will be overwritten on every save, e.g., each time
-        show() or save() is invoked, or any time a Bokeh plotting API
-        causes a save, if ``autosave`` is True.
+        show() or save() is invoked.
 
     '''
     _state.output_file(
         filename,
         title=title,
-        autosave=autosave,
         mode=mode,
         root_dir=root_dir
     )
@@ -181,7 +173,7 @@ def output_notebook(resources=None, verbose=False, hide_banner=False, load_timeo
 # usually we default session_id to "generate a random one" but
 # here we default to a hardcoded one. This is to support local
 # usage e.g. with a notebook.
-def output_server(session_id=DEFAULT_SESSION_ID, url="default", app_path="/", autopush=False):
+def output_server(session_id=DEFAULT_SESSION_ID, url="default", app_path="/"):
     """ Configure the default output state to push its document to a
     session on a Bokeh server.
 
@@ -212,12 +204,6 @@ def output_server(session_id=DEFAULT_SESSION_ID, url="default", app_path="/", au
 
         app_path (str, optional) : relative path of the app on the Bokeh server (default: "/")
 
-        autopush (bool, optional) : whether to automatically push (default: False)
-            If True, then Bokeh plotting APIs may opt to automatically
-            push the document more frequently (e.g., after any plotting
-            command). If False, then the document is only pushed upon calling
-            :func:`show` or :func:`push`.
-
     Returns:
         None
 
@@ -229,7 +215,7 @@ def output_server(session_id=DEFAULT_SESSION_ID, url="default", app_path="/", au
     bokeh.client sessions as described at http://bokeh.pydata.org/en/latest/docs/user_guide/server.html#connecting-with-bokeh-client"
     """)
 
-    _state.output_server(session_id=session_id, url=url, app_path=app_path, autopush=autopush)
+    _state.output_server(session_id=session_id, url=url, app_path=app_path)
 
 def set_curdoc(doc):
     '''Configure the current document (returned by curdoc()).
@@ -616,12 +602,6 @@ def _remove_roots(subplots):
         if sub in doc.roots:
             doc.remove_root(sub)
 
-def _push_or_save(obj):
-    if _state.server_enabled and _state.autopush:
-        push()
-    if _state.file and _state.autosave:
-        save(obj)
-
 def hplot(*children, **kwargs):
     deprecated((0, 12, 0), 'bokeh.io.hplot()', 'bokeh.models.layouts.Row')
     layout = Row(children=list(children), **kwargs)


Test patch:
diff --git a/bokeh/core/tests/test_state.py b/bokeh/core/tests/test_state.py
--- a/bokeh/core/tests/test_state.py
+++ b/bokeh/core/tests/test_state.py
@@ -35,7 +35,6 @@ def test_output_file(self):
         s = state.State()
         s.output_file("foo.html")
         self.assertEqual(s.file['filename'], "foo.html")
-        self.assertEqual(s.autosave, False)
         self.assertEqual(s.file['title'], "Bokeh Plot")
         self.assertEqual(s.file['resources'].log_level, 'info')
         self.assertEqual(s.file['resources'].minified, True)
@@ -47,7 +46,6 @@ def test_output_file_file_exists(self, mock_isfile, mock_logger):
         s = state.State()
         s.output_file("foo.html")
         self.assertEqual(s.file['filename'], "foo.html")
-        self.assertEqual(s.autosave, False)
         self.assertEqual(s.file['title'], "Bokeh Plot")
         self.assertEqual(s.file['resources'].log_level, 'info')
         self.assertEqual(s.file['resources'].minified, True)
diff --git a/bokeh/tests/test_io.py b/bokeh/tests/test_io.py
--- a/bokeh/tests/test_io.py
+++ b/bokeh/tests/test_io.py
@@ -53,12 +53,12 @@ def tearDown(self):
 class testOutputFile(DefaultStateTester):
 
     def test_noarg(self):
-        default_kwargs = dict(title="Bokeh Plot", autosave=False, mode="cdn", root_dir=None)
+        default_kwargs = dict(title="Bokeh Plot", mode="cdn", root_dir=None)
         io.output_file("foo.html")
         self._check_func_called(io._state.output_file, ("foo.html",), default_kwargs)
 
     def test_args(self):
-        kwargs = dict(title="title", autosave=True, mode="cdn", root_dir="foo")
+        kwargs = dict(title="title", mode="cdn", root_dir="foo")
         io.output_file("foo.html", **kwargs)
         self._check_func_called(io._state.output_file, ("foo.html",), kwargs)
 
@@ -81,12 +81,12 @@ def test_args(self, mock_load_notebook):
 class TestOutputServer(DefaultStateTester):
 
     def test_noarg(self):
-        default_kwargs = dict(session_id="default", url="default", app_path='/', autopush=False)
+        default_kwargs = dict(session_id="default", url="default", app_path='/')
         io.output_server()
         self._check_func_called(io._state.output_server, (), default_kwargs)
 
     def test_args(self):
-        kwargs = dict(session_id="foo", url="http://example.com", app_path='/foo', autopush=True)
+        kwargs = dict(session_id="foo", url="http://example.com", app_path='/foo')
         io.output_server(**kwargs)
         self._check_func_called(io._state.output_server, (), kwargs)