internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: bokeh/bokeh

Issue:
plots don't render in dev docs due to missing resources
The docs incorrectly looking for `/en/0.12.7dev15/static/js/bokeh-gl.min.js` instead of `dev`

ping @bryevdv 


Discussion:
Fairly certain I fixed the `test` deploy case and broke the dev and regular cases here

https://github.com/bokeh/bokeh/pull/6654/commits/f98188289472ef4b013dd82c65ffd55e9c382eb7#diff-fb8614bfb85117b76215c540120c0e03R91

Resolving patch:
diff --git a/bokeh/sphinxext/bokeh_plot.py b/bokeh/sphinxext/bokeh_plot.py
--- a/bokeh/sphinxext/bokeh_plot.py
+++ b/bokeh/sphinxext/bokeh_plot.py
@@ -88,14 +88,25 @@
 from .example_handler import ExampleHandler
 from .templates import PLOT_PAGE
 
-if settings.docs_cdn() is not None:
-    docs_cdn = settings.docs_cdn()
+docs_cdn = settings.docs_cdn()
+
+# if BOKEH_DOCS_CDN is unset just use default CDN resources
+if docs_cdn is None:
+    resources = Resources(mode="cdn")
+
+else:
+    # "BOKEH_DOCS_CDN=local" is used for building and displaying the docs locally
     if docs_cdn == "local":
         resources = Resources(mode="server", root_url="/en/latest/")
+
+    # "BOKEH_DOCS_CDN=test:newthing" is used for building and deploying test docs to
+    # a one-off location "en/newthing" on the docs site
+    elif docs_cdn.startswith("test:"):
+        resources = Resources(mode="server", root_url="/en/%s/" % docs_cdn.split(":")[1])
+
+    # Otherwise assume it is a dev/rc/full release version and use CDN for it
     else:
-        resources = Resources(mode="server", root_url="/en/%s/" % docs_cdn)
-else:
-    resources = Resources(mode="cdn")
+        resources = Resources(mode="cdn", version=docs_cdn)
 
 GOOGLE_API_KEY = getenv('GOOGLE_API_KEY')
 if GOOGLE_API_KEY is None:


Test patch:
Repository: bokeh/bokeh

Issue:
Automatic configuration of Slider.format
Integer sliders should use integer formatting.



Discussion:

Resolving patch:
diff --git a/bokeh/models/widgets/sliders.py b/bokeh/models/widgets/sliders.py
--- a/bokeh/models/widgets/sliders.py
+++ b/bokeh/models/widgets/sliders.py
@@ -74,7 +74,7 @@ class Slider(AbstractSlider):
     The step between consecutive values.
     """)
 
-    format = Override(default="0,0.00")
+    format = Override(default="0[.]00")
 
 class RangeSlider(AbstractSlider):
     """ Range-slider based number range selection widget. """
@@ -95,7 +95,7 @@ class RangeSlider(AbstractSlider):
     The step between consecutive values.
     """)
 
-    format = Override(default="0,0.00")
+    format = Override(default="0[.]00")
 
 class DateSlider(AbstractSlider):
     """ Slider-based date selection widget. """


Test patch:
Repository: bokeh/bokeh

Issue:
Don't fail silently when inline resources aren't available
Currently we get empty `<script>` and `<style>` tags in generated HTML. This should pretty much revert #644.


Discussion:

Resolving patch:
diff --git a/bokeh/resources.py b/bokeh/resources.py
--- a/bokeh/resources.py
+++ b/bokeh/resources.py
@@ -262,11 +262,8 @@ def _resolve(self, kind):
 
     def _inline(self, path):
         begin = "/* BEGIN %s */" % basename(path)
-        try:
-            with open(path, 'rb') as f:
-                middle = f.read().decode("utf-8")
-        except IOError:
-            middle = ""
+        with open(path, 'rb') as f:
+            middle = f.read().decode("utf-8")
         end = "/* END %s */"  % basename(path)
         return "%s\n%s\n%s" % (begin, middle, end)
 


Test patch:
Repository: bokeh/bokeh

Issue:
Bug: bokeh.io.push_notebook is broken
bokeh.io.push_notebook is broken in the 0.12.7 release because the comms_handle isn't returned from bokeh.io._show_with_state.

Example:
jupyter notebook examples/howto/notebook_comms/basic_usage.ipynb

Caused by: https://github.com/bokeh/bokeh/pull/6799/files#diff-ab5e8987987503b1248b3f5c707e056dL318

Bokeh 0.12.7

ping @bryevdv 


Discussion:
Oh I see, @rs2 mentioned this on gitter but I understood to mean the `push_notebook` was not returning which is expected. I also tested the notebooks but not well enough. What is working is the handle for "last shown". For an immediate workaround, the handle could be accessed right after `show` here:

```
state.last_comms_handle 
```

Resolving patch:
diff --git a/bokeh/io.py b/bokeh/io.py
--- a/bokeh/io.py
+++ b/bokeh/io.py
@@ -99,6 +99,12 @@ def install_notebook_hook(notebook_type, load, show_doc, show_app, overwrite=Fal
                     notebook_handle # whether a notebook handle was requested
                 )
 
+            If the notebook platform is capable of supporting in-place updates
+            to plots then this function may return an opaque notebook handle
+            that can  be used for that purpose. The handle will be returned by
+            ``show()``, and can be used by as appropriate to update plots, etc.
+            by additional functions in the library that installed the hooks.
+
         show_app (callable) :
             A function for displaying Bokeh applications in the notebook
             type. This function will be called with the following arguments:
@@ -415,7 +421,7 @@ def _show_with_state(obj, state, browser, new, notebook_handle=False):
     shown = False
 
     if state.notebook:
-        _show_notebook_doc_with_state(obj, state, notebook_handle)
+        comms_handle = _show_notebook_doc_with_state(obj, state, notebook_handle)
         shown = True
 
     if state.file or not shown:
@@ -425,7 +431,7 @@ def _show_with_state(obj, state, browser, new, notebook_handle=False):
 
 # Note: this function mostly exists so it can be mocked in tests
 def _show_notebook_doc_with_state(obj, state, notebook_handle):
-    _run_notebook_hook(state.notebook_type, 'doc', obj, state, notebook_handle)
+    return _run_notebook_hook(state.notebook_type, 'doc', obj, state, notebook_handle)
 
 def _show_file_with_state(obj, state, new, controller):
     filename = save(obj, state=state)


Test patch:
Repository: bokeh/bokeh

Issue:
Add network-related sample data source
In order to assist users experimenting with graph visualizations, we should add a sample data source that lends itself to this sort of visualization.

I'm proposing adding flight route data from: https://openflights.org/data.html


Discussion:

Resolving patch:
diff --git a/bokeh/sampledata/__init__.py b/bokeh/sampledata/__init__.py
--- a/bokeh/sampledata/__init__.py
+++ b/bokeh/sampledata/__init__.py
@@ -75,6 +75,8 @@ def download(progress=True):
         (s3, 'world_cities.zip'),
         (s3, 'airports.json'),
         (s3, 'movies.db.zip'),
+        (s3, 'airports.csv'),
+        (s3, 'routes.csv'),
     ]
 
     for base_url, file_name in files:
diff --git a/bokeh/sampledata/airport_routes.py b/bokeh/sampledata/airport_routes.py
new file mode 100644
--- /dev/null
+++ b/bokeh/sampledata/airport_routes.py
@@ -0,0 +1,21 @@
+""" The data in airports.csv and routes.csv is a subset (limited to US airports)
+of data available from OpenFlights.org. The complete data was collected on
+September 07, 2017 and is available from:
+
+.. code-block:: none
+
+    https://openflights.org/data.html
+
+"""
+from __future__ import absolute_import
+
+from bokeh.util.dependencies import import_required
+pd = import_required('pandas',
+              'airports sample data requires Pandas (http://pandas.pydata.org) to be installed')
+
+import os
+
+from . import _data_dir
+
+airports = pd.read_csv(os.path.join(_data_dir(), 'airports.csv'))
+routes = pd.read_csv(os.path.join(_data_dir(), 'routes.csv'))


Test patch:
Repository: bokeh/bokeh

Issue:
y_range doesn't understand numpy arrays
in the example below, `source2` works, but `source` does not. In order to get `source` to work, I have to add a `tolist()` clause (i.e. `y_range=source.data['fruits'].tolist()`)

    import pandas as pd
    import numpy as np
    import random
    from bokeh.io import push_notebook, show, output_notebook, show
    from bokeh.plotting import figure
    from bokeh.models import ColumnDataSource
    output_notebook()

    f = ['Apples', 'Pears', 'Nectarines', 'Plums', 'Grapes', 'Strawberries']
    c = random.sample(range(0,100), 6)
    df = pd.DataFrame({'fruits':f, 'counts':c})

    source = ColumnDataSource(df)
    source2 = ColumnDataSource(data=dict(fruits=f, counts=c))

    p = figure(y_range=source.data['fruits'], plot_height=250, title="Fruit Counts",
           toolbar_location=None, tools="")
    p.hbar(y='fruits', right='counts', height=0.9, source=source)
    show(p)

    print(type(source.data['fruits'])) ## <class 'numpy.ndarray'>
    print(type(source2.data['fruits'])) ## <class 'list'>


Discussion:
@hiramf would you be interested in contributing a PR for this? I think you'd just need to update this `isinstance` check to check for `(Sequence, np.ndarray)` instead of just `Sequence`

https://github.com/bokeh/bokeh/blob/master/bokeh/plotting/helpers.py#L347

as well as add a test passing a numpy array as input in this area:

https://github.com/bokeh/bokeh/blob/master/bokeh/plotting/tests/test_helpers.py#L180

Resolving patch:
diff --git a/bokeh/plotting/helpers.py b/bokeh/plotting/helpers.py
--- a/bokeh/plotting/helpers.py
+++ b/bokeh/plotting/helpers.py
@@ -344,7 +344,7 @@ def _get_range(range_input):
         return FactorRange(factors=sorted(list(range_input.groups.keys())))
     if isinstance(range_input, Range):
         return range_input
-    if isinstance(range_input, Sequence):
+    if isinstance(range_input, (Sequence, np.ndarray)):
         if all(isinstance(x, string_types) for x in range_input):
             return FactorRange(factors=list(range_input))
         if len(range_input) == 2:


Test patch:
diff --git a/bokeh/plotting/tests/test_helpers.py b/bokeh/plotting/tests/test_helpers.py
--- a/bokeh/plotting/tests/test_helpers.py
+++ b/bokeh/plotting/tests/test_helpers.py
@@ -187,6 +187,20 @@ def test__get_range_with_Range():
         r = _get_range(rng)
         assert r is rng
 
+def test__get_range_with_ndarray():
+    import numpy as np
+    r = _get_range(np.array([10, 20]))
+    assert isinstance(r, Range1d)
+    assert r.start == 10
+    assert r.end == 20
+
+def test__get_range_with_ndarray_factors():
+    import numpy as np
+    f = np.array(["Crosby", "Stills", "Nash", "Young"])
+    r = _get_range(f)
+    assert isinstance(r, FactorRange)
+    assert r.factors == list(f)
+
 def test__get_range_with_string_seq():
     f = ["foo" ,"end", "baz"]
     for t in [list, tuple]:
Repository: bokeh/bokeh

Issue:
Generate UUIDs for sphinx docs JS script names
Currently computes md5 hash of input filename. This results in the same names across deployed docs, which causes problems when the script is cached by CloudFlare, but the dom (with different target div id's) is not. 


Discussion:

Resolving patch:
diff --git a/bokeh/sphinxext/bokeh_plot.py b/bokeh/sphinxext/bokeh_plot.py
--- a/bokeh/sphinxext/bokeh_plot.py
+++ b/bokeh/sphinxext/bokeh_plot.py
@@ -67,10 +67,10 @@
 from __future__ import absolute_import
 
 import ast
-import hashlib
 from os import getenv
 from os.path import basename, dirname, join
 import re
+from uuid import uuid4
 
 from docutils import nodes
 from docutils.parsers.rst import Directive, Parser
@@ -178,7 +178,7 @@ def parse(self, source, document):
             lineno = m.body[0].lineno # assumes docstring is m.body[0]
             source = "\n".join(lines[lineno:])
 
-        js_name = "bokeh-plot-%s.js" % hashlib.md5(env.docname.encode('utf-8')).hexdigest()
+        js_name = "bokeh-plot-%s.js" % uuid4().hex
 
         (script, js, js_path, source) = _process_script(source, filename, env.bokeh_plot_auxdir, js_name)
 
@@ -219,8 +219,7 @@ def run(self):
             source = '\n'.join(self.content)
             # need docname not to look like a path
             docname = env.docname.replace("/", "-")
-            serialno = env.new_serialno(env.docname)
-            js_name = "bokeh-plot-%s-inline-%d.js" % (docname, serialno)
+            js_name = "bokeh-plot-%s-inline-%s.js" % (docname, uuid4().hex)
             # the code runner just needs a real path to cd to, this will do
             path = join(env.bokeh_plot_auxdir, js_name)
 
@@ -242,8 +241,7 @@ def run(self):
                 source = open(self.arguments[0]).read()
                 source = decode_utf8(source)
                 docname = env.docname.replace("/", "-")
-                serialno = env.new_serialno(env.docname)
-                js_name = "bokeh-plot-%s-external-%d.js" % (docname, serialno)
+                js_name = "bokeh-plot-%s-external-%s.js" % (docname, uuid4().hex)
                 (script, js, js_path, source) = _process_script(source, self.arguments[0], env.bokeh_plot_auxdir, js_name)
                 env.bokeh_plot_files[js_name] = (script, js, js_path, source)
 


Test patch:
Repository: bokeh/bokeh

Issue:
Gridplot doctext formatting error
Current text for `ncols` parameter [formats](https://bokeh.pydata.org/en/latest/docs/reference/layouts.html#bokeh.layouts.gridplot) as   

     Int (ncols) – Specify the number of columns you would like ...

while something similar to  

     plot_width (int, optional) – The width you would like all your plots to be

is probably correct.


Discussion:

Resolving patch:
diff --git a/bokeh/layouts.py b/bokeh/layouts.py
--- a/bokeh/layouts.py
+++ b/bokeh/layouts.py
@@ -301,7 +301,7 @@ def gridplot(*args, **kwargs):
             toolbar will be located, with respect to the grid. Default is
             ``above``. If set to None, no toolbar will be attached to the grid.
 
-        ncols ``Int`` (optional): Specify the number of columns you would like in your grid.
+        ncols (int, optional): Specify the number of columns you would like in your grid.
             You must only pass an un-nested list of plots (as opposed to a list of lists of plots)
             when using ncols.
 


Test patch:
Repository: bokeh/bokeh

Issue:
from_networkx fails with networkx 2.0
Hi - When using networkx 2.0 (nx)  loading a graph from nx results in a ValueError.
`ValueError: expected an element of ColumnData(String, Seq(Any)), got {'index': NodeView((0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33))}`

This is because `nx 2.0` wraps `graph.nodes` in a View.  And therefore, `from_networkx`  code needs to be changed from:
 ```
nodes = graph.nodes()
edges = graph.edges()
```
to:
```
nodes = dict(graph.nodes())
edges = dict(graph.edges())
```

Lastly pip `nx` is version 2.x  on conda it is 1.x.   Most people are on 1,x


Discussion:

Resolving patch:
diff --git a/bokeh/models/graphs.py b/bokeh/models/graphs.py
--- a/bokeh/models/graphs.py
+++ b/bokeh/models/graphs.py
@@ -53,9 +53,11 @@ def from_networkx(graph, layout_function, **kwargs):
         # inline import to prevent circular imports
         from ..models.renderers import GraphRenderer
         from ..models.graphs import StaticLayoutProvider
-
-        nodes = graph.nodes()
-        edges = graph.edges()
+        
+        # Handles nx 1.x vs 2.x data structure change
+        nodes = list(graph.nodes())
+        edges = list(graph.edges())
+    
         edges_start = [edge[0] for edge in edges]
         edges_end = [edge[1] for edge in edges]
 


Test patch:
Repository: bokeh/bokeh

Issue:
twin_axis not showing label correctly in version 0.12.9
I recently upgraded from 0.12.6 to 0.12.9, then I found there is an issue with the LinearAxis object, which would not display the label correctly. 
I attach some code, and screen shots of expected and bug behavior, one from 12.6, the other from 12.9. In 12.9, you can see the y axis label "x" is missing. 

```
from numpy import pi, arange, sin, linspace
from bokeh.models import LinearAxis, Range1d
from bokeh.plotting import figure, show, output_file

x = arange(-2*pi, 2*pi, 0.1)
y = sin(x)
y2 = linspace(0, 100, len(x))
p = figure(x_range=(-6.5, 6.5), y_range=(-1.1, 1.1), min_border=80)
p.circle(x, y, fill_color="red", size=5, line_color="black")
p.extra_y_ranges['foo'] = Range1d(0, 100)
p.circle(x, y2, fill_color="blue", size=5, line_color="black", y_range_name="foo")
p.add_layout(LinearAxis(y_range_name="foo",
                        axis_label = "x"), 'left')
output_file("twin_axis.html", title="twin_axis.py example")
show(p)

```
![0 12 6](https://user-images.githubusercontent.com/8864839/31632009-1d426154-b281-11e7-91ea-3cd012e94b4c.PNG)
![0 12 9](https://user-images.githubusercontent.com/8864839/31632010-1d58cb24-b281-11e7-8cfb-35afe534c643.PNG)



Discussion:
Label is missing, but canvas layout is correct (the second screenshot may indicate otherwise).

Resolving patch:
diff --git a/examples/models/file/twin_axis.py b/examples/models/file/twin_axis.py
--- a/examples/models/file/twin_axis.py
+++ b/examples/models/file/twin_axis.py
@@ -21,20 +21,27 @@
 
 plot = Plot(x_range=Range1d(start=-6.5, end=6.5), y_range=Range1d(start=-1.1, end=1.1), min_border=80)
 
+plot.extra_x_ranges = {"qux": Range1d(start=100, end=0)}
 plot.extra_y_ranges = {"foo": Range1d(start=0, end=100)}
 
-circle = Circle(x="x", y="y", fill_color="red", size=5, line_color="black")
-plot.add_glyph(source, circle)
+plot.add_layout(LinearAxis(axis_label="default range"), 'above')
+plot.add_layout(LinearAxis(axis_label="qux range", x_range_name="qux"), 'above')
 
-plot.add_layout(LinearAxis(), 'below')
-plot.add_layout(LinearAxis(), 'left')
+plot.add_layout(LinearAxis(axis_label="default range"), 'below')
+plot.add_layout(LinearAxis(axis_label="qux range", x_range_name="qux"), 'below')
 
+plot.add_layout(LinearAxis(axis_label="default range"), 'left')
+plot.add_layout(LinearAxis(axis_label="foo range", y_range_name="foo"), 'left')
+
+plot.add_layout(LinearAxis(axis_label="default range"), 'right')
+plot.add_layout(LinearAxis(axis_label="foo range", y_range_name="foo"), 'right')
+
+circle = Circle(x="x", y="y", fill_color="red", size=5, line_color="black")
+plot.add_glyph(source, circle)
 
 circle2 = Circle(x="x", y="y2", fill_color="blue", size=5, line_color="black")
 plot.add_glyph(source, circle2, y_range_name="foo")
 
-plot.add_layout(LinearAxis(y_range_name="foo"), 'left')
-
 plot.add_tools(PanTool(), WheelZoomTool())
 
 doc = Document()


Test patch:
Repository: bokeh/bokeh

Issue:
session could auto-no-op any callbacks invoked after the session is destroyed
Right now, if you do something like this:

```
def update_all_sessions(server_context):
   for session_context in server_context.sessions:
      yield session_context.with_locked_document(update_document)
```

One of the sessions could expire and be destroyed before your code gets to it.

So you need to write a check for that:

```
def update_all_sessions(server_context):
   for session_context in server_context.sessions:
      if not session_context.destroyed:
        yield session_context.with_locked_document(update_document)
```

I think it would be better if `with_locked_document` did this automatically (just became a no-op on destroyed sessions). This could be done in session.py, `_needs_document_lock_wrapper` perhaps.



Discussion:

Resolving patch:
diff --git a/bokeh/server/session.py b/bokeh/server/session.py
--- a/bokeh/server/session.py
+++ b/bokeh/server/session.py
@@ -37,6 +37,9 @@ def _needs_document_lock_wrapper(self, *args, **kwargs):
         # from being discarded. This avoids potential weirdness
         # with the session vanishing in the middle of some async
         # task.
+        if self.destroyed:
+            log.debug("Ignoring locked callback on already-destroyed session.")
+            raise gen.Return(None)
         self.block_expiration()
         try:
             with (yield self._lock.acquire()):


Test patch:
diff --git a/bokeh/server/tests/test_server.py b/bokeh/server/tests/test_server.py
--- a/bokeh/server/tests/test_server.py
+++ b/bokeh/server/tests/test_server.py
@@ -102,6 +102,7 @@ def remover():
     # this has to be async too
     @gen.coroutine
     def on_session_destroyed(self, session_context):
+        # this should be no-op'd, because the session is already destroyed
         @gen.coroutine
         def shutdown_document(doc):
             doc.roots[0].hooks.append("session_destroyed")
@@ -187,13 +188,15 @@ def on_done():
     server_hook_list = server_doc.roots[0]
     assert handler.load_count == 1
     assert handler.unload_count == 1
-    assert handler.session_creation_async_value == 6
+    # this is 3 instead of 6 because locked callbacks on destroyed sessions
+    # are turned into no-ops
+    assert handler.session_creation_async_value == 3
     assert client_doc.title == "Modified"
     assert server_doc.title == "Modified"
-    # the client session doesn't see the event that adds "session_destroyed" since
-    # we shut down at that point.
+    # only the handler sees the event that adds "session_destroyed" since
+    # the session is shut down at that point.
     assert client_hook_list.hooks == ["session_created", "modify"]
-    assert server_hook_list.hooks == ["session_created", "modify", "session_destroyed"]
+    assert server_hook_list.hooks == ["session_created", "modify"]
 
 def test_prefix():
     application = Application()
Repository: bokeh/bokeh

Issue:
bokeh channel version of nodejs is no longer in sync with upstream anaconda/nodejs
At present this is impeding compilation of custom bokeh extensions due to a version check @ https://github.com/bokeh/bokeh/blob/master/bokeh/util/compiler.py#L142

Also probably a good idea in the long term not to let versions diverge too much.


Discussion:
cc @mattpap 
`defaults` contain the correct version. `bokeh` channel lags behind. I think we should just point to `defaults` and update the error message to `(...) npm install nodejs (...)`.

Resolving patch:
diff --git a/bokeh/util/compiler.py b/bokeh/util/compiler.py
--- a/bokeh/util/compiler.py
+++ b/bokeh/util/compiler.py
@@ -139,7 +139,7 @@ def _detect_nodejs():
     # if we've reached here, no valid version was found
     version = ".".join(map(str, nodejs_min_version))
     raise RuntimeError('node.js v%s or higher is needed to allow compilation of custom models ' % version +
-                       '("conda install -c bokeh nodejs" or follow https://nodejs.org/en/download/)')
+                       '("conda install nodejs" or follow https://nodejs.org/en/download/)')
 
 _nodejs = None
 _npmjs = None


Test patch:
Repository: bokeh/bokeh

Issue:
Double encode escapes in HTML-safe JSON strings
This was overlooked in PR #7203.


Discussion:

Resolving patch:
diff --git a/bokeh/embed/util.py b/bokeh/embed/util.py
--- a/bokeh/embed/util.py
+++ b/bokeh/embed/util.py
@@ -173,7 +173,10 @@ def script_for_render_items(docs_json_or_id, render_items, app_path=None, absolu
         # and encoding it would significantly increase size of generated files. Doing so
         # is safe, because " in strings was already encoded by JSON, and the semi-encoded
         # JSON string is included in JavaScript in single quotes.
-        docs_json =  "'" + escape(serialize_json(docs_json_or_id, pretty=False), quote=("'",)) + "'"
+        docs_json = serialize_json(docs_json_or_id, pretty=False) # JSON string
+        docs_json = escape(docs_json, quote=("'",))               # make HTML-safe
+        docs_json = docs_json.replace("\\", "\\\\")               # double encode escapes
+        docs_json =  "'" + docs_json + "'"                        # JS string
 
     js = DOC_JS.render(
         docs_json=docs_json,


Test patch: