Uncaught Error: reference isn't known not in Document error

Hi,

When I update bokeh version installed in my local computer, I keep getting the following error from Column Data Sources that I have defined inside a class.

Uncaught Error: reference {“id”:“1242”,“type”:“Div”} isn’t known (not in Document?)

When I install an earlier version of bokeh, the error appears to be resolved. But I don’t want to do that since I want some of the functionality which doesn’t exist in earlier versions. The original code is quite long, that’ s why you can find a very similar case below. The code I am sharing is not causing any problems, but the original one is problematic. Are there anyone facing the same problem?

Thanks.

from random import random

from bokeh.layouts import column

from bokeh.models import Button

from bokeh.palettes import RdYlBu3

from bokeh.plotting import figure, curdoc

from bokeh.models import ColumnDataSource

import copy

from functools import partial

from random import random

from threading import Thread

import time

from bokeh.models import ColumnDataSource

from bokeh.plotting import curdoc, figure

from tornado import gen

create a plot and style its properties

i = 0

count = 0

class Dummy:

def init(self):

self._data = ColumnDataSource(dict(x = [1],y=[0],text_color=[RdYlBu3[1%3]],text=[str(1)]))

dummy = Dummy()

def make_doc(doc):

doc = doc

p = figure(x_range=(0, 100), y_range=(0, 100), toolbar_location=None)

p.border_fill_color = ‘black’

p.background_fill_color = ‘black’

p.outline_line_color = None

p.grid.grid_line_color = None

add a text renderer to our plot (no data yet)p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color=“navy”, alpha=0.5)

r = p.text(x=“x”, y=“y”, text=“text”, text_color=“text_color”, text_font_size=“20pt”,

text_baseline=“middle”, text_align=“center”,source = dummy._data)

#p.add_glyph(source, glyph)

#ds = r.data_source

@gen.coroutine

def update(x, y,text,text_color):

dummy._data.stream(dict(x=x, y=y,text=text,text_color=text_color))

def blocking_task():

while True:

do some blocking computation

time.sleep(60)

global i

global count

dummyDict = copy.deepcopy(dummy._data.data)

if count == 0:

x = dummyDict[‘x’][0]

y = dummyDict[‘y’][0]

else:

x = i

y = i*2

print(x,“xi alabiliyo mu blocking”)

BEST PRACTICE — update .data in one step with a new dict

new_data = dict()

new_data[‘x’] =

new_data[‘y’] = [y]

new_data[‘text_color’] = [RdYlBu3[i%3]]

new_data[‘text’] = [str(i)]

doc.add_next_tick_callback(partial(update, x=new_data[‘x’], y=new_data[‘y’],text=new_data[‘text’],text_color=new_data[‘text_color’]))

count += 1

i = i + 1

print(i,“i”)

#but update the document from callback

create a callback that will add a number in a random location

def callback():

global i

global count

dummyDict = copy.deepcopy(dummy._data.data)

if count == 0:

x = dummyDict[‘x’][0]

y = dummyDict[‘y’][0]

else:

x = 2

y = 4

print(x,“xi alabiliyo mu callback”)

BEST PRACTICE — update .data in one step with a new dict

new_data = dict()

new_data[‘x’] = dummy._data.data[‘x’] +

new_data[‘y’] = dummy._data.data[‘y’] + [y]

new_data[‘text_color’] = dummy._data.data[‘text_color’] + [RdYlBu3[i%3]]

new_data[‘text’] = dummy._data.data[‘text’] + [str(i)]

dummy._data.data = new_data

count += 1

i = i + 1

add a button widget and configure with the call back

button = Button(label=“Press Me”)

button.on_click(callback)

doc.add_root(column(button, p))

thread = Thread(target=blocking_task)

thread.start()

print(dummy._data,“data itself”)

doc = curdoc()

make_doc(doc)

Hi,

When I run this code with Bokeh 1.0.4 I don't see any error, either in the server logs of the browser console. Also it is working AFAICT (callback message print and the plot updates). Perhaps you can provide more information?

Thanks,

Bryan

···

On Jan 13, 2019, at 13:13, [email protected] wrote:

Hi,

When I update bokeh version installed in my local computer, I keep getting the following error from Column Data Sources that I have defined inside a class.

Uncaught Error: reference {"id":"1242","type":"Div"} isn't known (not in Document?)

When I install an earlier version of bokeh, the error appears to be resolved. But I don't want to do that since I want some of the functionality which doesn't exist in earlier versions. The original code is quite long, that' s why you can find a very similar case below. The code I am sharing is not causing any problems, but the original one is problematic. Are there anyone facing the same problem?

Thanks.

from random import random
from bokeh.layouts import column
from bokeh.models import Button
from bokeh.palettes import RdYlBu3
from bokeh.plotting import figure, curdoc
from bokeh.models import ColumnDataSource
import copy
from functools import partial
from random import random
from threading import Thread
import time

from bokeh.models import ColumnDataSource
from bokeh.plotting import curdoc, figure

from tornado import gen
# create a plot and style its properties
i = 0
count = 0
class Dummy:
    def __init__(self):
        self._data = ColumnDataSource(dict(x = [1],y=[0],text_color=[RdYlBu3[1%3]],text=[str(1)]))
dummy = Dummy()
def make_doc(doc):
    doc = doc

    p = figure(x_range=(0, 100), y_range=(0, 100), toolbar_location=None)
    p.border_fill_color = 'black'
    p.background_fill_color = 'black'
    p.outline_line_color = None
    p.grid.grid_line_color = None

    # add a text renderer to our plot (no data yet)p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
    r = p.text(x="x", y="y", text="text", text_color="text_color", text_font_size="20pt",
               text_baseline="middle", text_align="center",source = dummy._data)
    #p.add_glyph(source, glyph)
    
    #ds = r.data_source
    @gen.coroutine
    def update(x, y,text,text_color):
        dummy._data.stream(dict(x=x, y=y,text=text,text_color=text_color))

    def blocking_task():
        while True:
            # do some blocking computation
            time.sleep(60)
            global i
            global count
            dummyDict = copy.deepcopy(dummy._data.data)
            if count == 0:
                x = dummyDict['x'][0]
                y = dummyDict['y'][0]
            else:
                x = i
                y = i*2
            print(x,"xi alabiliyo mu blocking")
            # BEST PRACTICE --- update .data in one step with a new dict
            new_data = dict()
            new_data['x'] =
            new_data['y'] = [y]
            new_data['text_color'] = [RdYlBu3[i%3]]
            new_data['text'] = [str(i)]
            doc.add_next_tick_callback(partial(update, x=new_data['x'], y=new_data['y'],text=new_data['text'],text_color=new_data['text_color']))
            count += 1
            i = i + 1
            print(i,"i")
            #but update the document from callback
        
    # create a callback that will add a number in a random location
    def callback():
        global i
        global count
        dummyDict = copy.deepcopy(dummy._data.data)
        if count == 0:
            x = dummyDict['x'][0]
            y = dummyDict['y'][0]
        else:
            x = 2
            y = 4
        print(x,"xi alabiliyo mu callback")
        # BEST PRACTICE --- update .data in one step with a new dict
        new_data = dict()
        new_data['x'] = dummy._data.data['x'] +
        new_data['y'] = dummy._data.data['y'] + [y]
        new_data['text_color'] = dummy._data.data['text_color'] + [RdYlBu3[i%3]]
        new_data['text'] = dummy._data.data['text'] + [str(i)]
        dummy._data.data = new_data
        count += 1
        i = i + 1

    # add a button widget and configure with the call back
    button = Button(label="Press Me")
    button.on_click(callback)
    doc.add_root(column(button, p))
    thread = Thread(target=blocking_task)
    thread.start()
    print(dummy._data,"data itself")
doc = curdoc()
make_doc(doc)

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4bfe7017-dddf-49e1-949a-75dc103332eb%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan,

Thanks for your reply. After an extensive debugging, I found out that the problem is with the plots that are updated via custom javascript callback functions. Whenever I tried to pass a bokeh model inside a customJS fuction, it gives me an error saying that this model I am trying to pass is not document. But I am for sure that I defined the bokeh model that I am passing, in fact just before the javascript callback . Why do you think that this is the case? By the way, when I execute the same code in earlier versions like 0.12.15, there is no such error.

···

On Monday, January 14, 2019 at 1:42:30 AM UTC+3, Bryan Van de ven wrote:

Hi,

When I run this code with Bokeh 1.0.4 I don’t see any error, either in the server logs of the browser console. Also it is working AFAICT (callback message print and the plot updates). Perhaps you can provide more information?

Thanks,

Bryan

On Jan 13, 2019, at 13:13, [email protected] wrote:

Hi,

When I update bokeh version installed in my local computer, I keep getting the following error from Column Data Sources that I have defined inside a class.

Uncaught Error: reference {“id”:“1242”,“type”:“Div”} isn’t known (not in Document?)

When I install an earlier version of bokeh, the error appears to be resolved. But I don’t want to do that since I want some of the functionality which doesn’t exist in earlier versions. The original code is quite long, that’ s why you can find a very similar case below. The code I am sharing is not causing any problems, but the original one is problematic. Are there anyone facing the same problem?

Thanks.

from random import random

from bokeh.layouts import column

from bokeh.models import Button

from bokeh.palettes import RdYlBu3

from bokeh.plotting import figure, curdoc

from bokeh.models import ColumnDataSource

import copy

from functools import partial

from random import random

from threading import Thread

import time

from bokeh.models import ColumnDataSource

from bokeh.plotting import curdoc, figure

from tornado import gen

create a plot and style its properties

i = 0

count = 0

class Dummy:

def __init__(self):
    self._data = ColumnDataSource(dict(x = [1],y=[0],text_color=[RdYlBu3[1%3]],text=[str(1)]))

dummy = Dummy()

def make_doc(doc):

doc = doc
p = figure(x_range=(0, 100), y_range=(0, 100), toolbar_location=None)
p.border_fill_color = 'black'
p.background_fill_color = 'black'
p.outline_line_color = None
p.grid.grid_line_color = None
# add a text renderer to our plot (no data yet)p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
r = p.text(x="x", y="y", text="text", text_color="text_color", text_font_size="20pt",
           text_baseline="middle", text_align="center",source = dummy._data)
#p.add_glyph(source, glyph)
#ds = r.data_source
@gen.coroutine
def update(x, y,text,text_color):
    dummy._data.stream(dict(x=x, y=y,text=text,text_color=text_color))
def blocking_task():
    while True:
        # do some blocking computation
        time.sleep(60)
        global i
        global count
        dummyDict = copy.deepcopy(dummy._data.data)
        if count == 0:
            x = dummyDict['x'][0]
            y = dummyDict['y'][0]
        else:
            x = i
            y = i*2
        print(x,"xi alabiliyo mu blocking")
        # BEST PRACTICE --- update .data in one step with a new dict
        new_data = dict()
        new_data['x'] = [x]
        new_data['y'] = [y]
        new_data['text_color'] = [RdYlBu3[i%3]]
        new_data['text'] = [str(i)]
        doc.add_next_tick_callback(partial(update, x=new_data['x'], y=new_data['y'],text=new_data['text'],text_color=new_data['text_color']))
        count += 1
        i = i + 1
        print(i,"i")
        #but update the document from callback
# create a callback that will add a number in a random location
def callback():
    global i
    global count
    dummyDict = copy.deepcopy(dummy._data.data)
    if count == 0:
        x = dummyDict['x'][0]
        y = dummyDict['y'][0]
    else:
        x = 2
        y = 4
    print(x,"xi alabiliyo mu callback")
    # BEST PRACTICE --- update .data in one step with a new dict
    new_data = dict()
    new_data['x'] = dummy._data.data['x'] + [x]
    new_data['y'] = dummy._data.data['y'] + [y]
    new_data['text_color'] = dummy._data.data['text_color'] + [RdYlBu3[i%3]]
    new_data['text'] = dummy._data.data['text'] + [str(i)]
    dummy._data.data = new_data
    count += 1
    i = i + 1
# add a button widget and configure with the call back
button = Button(label="Press Me")
button.on_click(callback)
doc.add_root(column(button, p))
thread = Thread(target=blocking_task)
thread.start()
print(dummy._data,"data itself")

doc = curdoc()

make_doc(doc)


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4bfe7017-dddf-49e1-949a-75dc103332eb%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan,

I just wanted to tell that the reason why I am using the latest release is because I wanted to add range tool attribute to my code as in example below. Other than that I can use 0.12.15, as it doesn’t produce any errors.

https://bokeh.pydata.org/en/dev/docs/gallery/range_tool.html

Thanks,

Baran.

···

On Saturday, January 19, 2019 at 4:52:22 PM UTC+3, Baran Köseoğlu wrote:

Hi Bryan,

Thanks for your reply. After an extensive debugging, I found out that the problem is with the plots that are updated via custom javascript callback functions. Whenever I tried to pass a bokeh model inside a customJS fuction, it gives me an error saying that this model I am trying to pass is not document. But I am for sure that I defined the bokeh model that I am passing, in fact just before the javascript callback . Why do you think that this is the case? By the way, when I execute the same code in earlier versions like 0.12.15, there is no such error.

On Monday, January 14, 2019 at 1:42:30 AM UTC+3, Bryan Van de ven wrote:

Hi,

When I run this code with Bokeh 1.0.4 I don’t see any error, either in the server logs of the browser console. Also it is working AFAICT (callback message print and the plot updates). Perhaps you can provide more information?

Thanks,

Bryan

On Jan 13, 2019, at 13:13, [email protected] wrote:

Hi,

When I update bokeh version installed in my local computer, I keep getting the following error from Column Data Sources that I have defined inside a class.

Uncaught Error: reference {“id”:“1242”,“type”:“Div”} isn’t known (not in Document?)

When I install an earlier version of bokeh, the error appears to be resolved. But I don’t want to do that since I want some of the functionality which doesn’t exist in earlier versions. The original code is quite long, that’ s why you can find a very similar case below. The code I am sharing is not causing any problems, but the original one is problematic. Are there anyone facing the same problem?

Thanks.

from random import random

from bokeh.layouts import column

from bokeh.models import Button

from bokeh.palettes import RdYlBu3

from bokeh.plotting import figure, curdoc

from bokeh.models import ColumnDataSource

import copy

from functools import partial

from random import random

from threading import Thread

import time

from bokeh.models import ColumnDataSource

from bokeh.plotting import curdoc, figure

from tornado import gen

create a plot and style its properties

i = 0

count = 0

class Dummy:

def __init__(self):
    self._data = ColumnDataSource(dict(x = [1],y=[0],text_color=[RdYlBu3[1%3]],text=[str(1)]))

dummy = Dummy()

def make_doc(doc):

doc = doc
p = figure(x_range=(0, 100), y_range=(0, 100), toolbar_location=None)
p.border_fill_color = 'black'
p.background_fill_color = 'black'
p.outline_line_color = None
p.grid.grid_line_color = None
# add a text renderer to our plot (no data yet)p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
r = p.text(x="x", y="y", text="text", text_color="text_color", text_font_size="20pt",
           text_baseline="middle", text_align="center",source = dummy._data)
#p.add_glyph(source, glyph)
#ds = r.data_source
@gen.coroutine
def update(x, y,text,text_color):
    dummy._data.stream(dict(x=x, y=y,text=text,text_color=text_color))
def blocking_task():
    while True:
        # do some blocking computation
        time.sleep(60)
        global i
        global count
        dummyDict = copy.deepcopy(dummy._data.data)
        if count == 0:
            x = dummyDict['x'][0]
            y = dummyDict['y'][0]
        else:
            x = i
            y = i*2
        print(x,"xi alabiliyo mu blocking")
        # BEST PRACTICE --- update .data in one step with a new dict
        new_data = dict()
        new_data['x'] = [x]
        new_data['y'] = [y]
        new_data['text_color'] = [RdYlBu3[i%3]]
        new_data['text'] = [str(i)]
        doc.add_next_tick_callback(partial(update, x=new_data['x'], y=new_data['y'],text=new_data['text'],text_color=new_data['text_color']))
        count += 1
        i = i + 1
        print(i,"i")
        #but update the document from callback
# create a callback that will add a number in a random location
def callback():
    global i
    global count
    dummyDict = copy.deepcopy(dummy._data.data)
    if count == 0:
        x = dummyDict['x'][0]
        y = dummyDict['y'][0]
    else:
        x = 2
        y = 4
    print(x,"xi alabiliyo mu callback")
    # BEST PRACTICE --- update .data in one step with a new dict
    new_data = dict()
    new_data['x'] = dummy._data.data['x'] + [x]
    new_data['y'] = dummy._data.data['y'] + [y]
    new_data['text_color'] = dummy._data.data['text_color'] + [RdYlBu3[i%3]]
    new_data['text'] = dummy._data.data['text'] + [str(i)]
    dummy._data.data = new_data
    count += 1
    i = i + 1
# add a button widget and configure with the call back
button = Button(label="Press Me")
button.on_click(callback)
doc.add_root(column(button, p))
thread = Thread(target=blocking_task)
thread.start()
print(dummy._data,"data itself")

doc = curdoc()

make_doc(doc)


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4bfe7017-dddf-49e1-949a-75dc103332eb%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Baran,

I feel like I might have tun into a similar example just a day or two ago. If this were a completely general issue it would be a serious regression. That said, we rely on executing CustomJS callbacks as a central part of our integration test machinery for bokeh server functionality. So, there must be something specific that only happens under certain circumstances going on. Can you construct a minimal reproducing script, and make a new GH issue with that information, so that it can be investigated properly?

Thanks,

Bryan

···

On Jan 19, 2019, at 06:03, [email protected] wrote:

Hi Bryan,

I just wanted to tell that the reason why I am using the latest release is because I wanted to add range tool attribute to my code as in example below. Other than that I can use 0.12.15, as it doesn't produce any errors.

https://bokeh.pydata.org/en/dev/docs/gallery/range_tool.html

Thanks,

Baran.

On Saturday, January 19, 2019 at 4:52:22 PM UTC+3, Baran Köseoğlu wrote:
Hi Bryan,

Thanks for your reply. After an extensive debugging, I found out that the problem is with the plots that are updated via custom javascript callback functions. Whenever I tried to pass a bokeh model inside a customJS fuction, it gives me an error saying that this model I am trying to pass is not document. But I am for sure that I defined the bokeh model that I am passing, in fact just before the javascript callback . Why do you think that this is the case? By the way, when I execute the same code in earlier versions like 0.12.15, there is no such error.

On Monday, January 14, 2019 at 1:42:30 AM UTC+3, Bryan Van de ven wrote:
Hi,

When I run this code with Bokeh 1.0.4 I don't see any error, either in the server logs of the browser console. Also it is working AFAICT (callback message print and the plot updates). Perhaps you can provide more information?

Thanks,

Bryan

> On Jan 13, 2019, at 13:13, [email protected] wrote:
>
> Hi,
>
> When I update bokeh version installed in my local computer, I keep getting the following error from Column Data Sources that I have defined inside a class.
>
> Uncaught Error: reference {"id":"1242","type":"Div"} isn't known (not in Document?)
>
> When I install an earlier version of bokeh, the error appears to be resolved. But I don't want to do that since I want some of the functionality which doesn't exist in earlier versions. The original code is quite long, that' s why you can find a very similar case below. The code I am sharing is not causing any problems, but the original one is problematic. Are there anyone facing the same problem?
>
> Thanks.
>
>
> from random import random
> from bokeh.layouts import column
> from bokeh.models import Button
> from bokeh.palettes import RdYlBu3
> from bokeh.plotting import figure, curdoc
> from bokeh.models import ColumnDataSource
> import copy
> from functools import partial
> from random import random
> from threading import Thread
> import time
>
> from bokeh.models import ColumnDataSource
> from bokeh.plotting import curdoc, figure
>
> from tornado import gen
> # create a plot and style its properties
> i = 0
> count = 0
> class Dummy:
> def __init__(self):
> self._data = ColumnDataSource(dict(x = [1],y=[0],text_color=[RdYlBu3[1%3]],text=[str(1)]))
> dummy = Dummy()
> def make_doc(doc):
> doc = doc
>
>
> p = figure(x_range=(0, 100), y_range=(0, 100), toolbar_location=None)
> p.border_fill_color = 'black'
> p.background_fill_color = 'black'
> p.outline_line_color = None
> p.grid.grid_line_color = None
>
> # add a text renderer to our plot (no data yet)p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
> r = p.text(x="x", y="y", text="text", text_color="text_color", text_font_size="20pt",
> text_baseline="middle", text_align="center",source = dummy._data)
> #p.add_glyph(source, glyph)
>
>
> #ds = r.data_source
> @gen.coroutine
> def update(x, y,text,text_color):
> dummy._data.stream(dict(x=x, y=y,text=text,text_color=text_color))
>
> def blocking_task():
> while True:
> # do some blocking computation
> time.sleep(60)
> global i
> global count
> dummyDict = copy.deepcopy(dummy._data.data)
> if count == 0:
> x = dummyDict['x'][0]
> y = dummyDict['y'][0]
> else:
> x = i
> y = i*2
> print(x,"xi alabiliyo mu blocking")
> # BEST PRACTICE --- update .data in one step with a new dict
> new_data = dict()
> new_data['x'] =
> new_data['y'] = [y]
> new_data['text_color'] = [RdYlBu3[i%3]]
> new_data['text'] = [str(i)]
> doc.add_next_tick_callback(partial(update, x=new_data['x'], y=new_data['y'],text=new_data['text'],text_color=new_data['text_color']))
> count += 1
> i = i + 1
> print(i,"i")
> #but update the document from callback
>
>
> # create a callback that will add a number in a random location
> def callback():
> global i
> global count
> dummyDict = copy.deepcopy(dummy._data.data)
> if count == 0:
> x = dummyDict['x'][0]
> y = dummyDict['y'][0]
> else:
> x = 2
> y = 4
> print(x,"xi alabiliyo mu callback")
> # BEST PRACTICE --- update .data in one step with a new dict
> new_data = dict()
> new_data['x'] = dummy._data.data['x'] +
> new_data['y'] = dummy._data.data['y'] + [y]
> new_data['text_color'] = dummy._data.data['text_color'] + [RdYlBu3[i%3]]
> new_data['text'] = dummy._data.data['text'] + [str(i)]
> dummy._data.data = new_data
> count += 1
> i = i + 1
>
> # add a button widget and configure with the call back
> button = Button(label="Press Me")
> button.on_click(callback)
> doc.add_root(column(button, p))
> thread = Thread(target=blocking_task)
> thread.start()
> print(dummy._data,"data itself")
> doc = curdoc()
> make_doc(doc)
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4bfe7017-dddf-49e1-949a-75dc103332eb%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0c683017-8547-48cb-b447-d1b47d392d65%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan,

Thanks for your reply. I tried to run a very similar script with latest versions of bokeh, but I can’t reproduce the error. Could you please share or describe the issue you faced so that I can better understand the problem and reproduce it?

Thanks,

Baran.

···

On Saturday, January 19, 2019 at 10:03:25 PM UTC+3, Bryan Van de ven wrote:

Hi Baran,

I feel like I might have tun into a similar example just a day or two ago. If this were a completely general issue it would be a serious regression. That said, we rely on executing CustomJS callbacks as a central part of our integration test machinery for bokeh server functionality. So, there must be something specific that only happens under certain circumstances going on. Can you construct a minimal reproducing script, and make a new GH issue with that information, so that it can be investigated properly?

Thanks,

Bryan

On Jan 19, 2019, at 06:03, [email protected] wrote:

Hi Bryan,

I just wanted to tell that the reason why I am using the latest release is because I wanted to add range tool attribute to my code as in example below. Other than that I can use 0.12.15, as it doesn’t produce any errors.

https://bokeh.pydata.org/en/dev/docs/gallery/range_tool.html

Thanks,

Baran.

On Saturday, January 19, 2019 at 4:52:22 PM UTC+3, Baran Köseoğlu wrote:

Hi Bryan,

Thanks for your reply. After an extensive debugging, I found out that the problem is with the plots that are updated via custom javascript callback functions. Whenever I tried to pass a bokeh model inside a customJS fuction, it gives me an error saying that this model I am trying to pass is not document. But I am for sure that I defined the bokeh model that I am passing, in fact just before the javascript callback . Why do you think that this is the case? By the way, when I execute the same code in earlier versions like 0.12.15, there is no such error.

On Monday, January 14, 2019 at 1:42:30 AM UTC+3, Bryan Van de ven wrote:

Hi,

When I run this code with Bokeh 1.0.4 I don’t see any error, either in the server logs of the browser console. Also it is working AFAICT (callback message print and the plot updates). Perhaps you can provide more information?

Thanks,

Bryan

On Jan 13, 2019, at 13:13, [email protected] wrote:

Hi,

When I update bokeh version installed in my local computer, I keep getting the following error from Column Data Sources that I have defined inside a class.

Uncaught Error: reference {“id”:“1242”,“type”:“Div”} isn’t known (not in Document?)

When I install an earlier version of bokeh, the error appears to be resolved. But I don’t want to do that since I want some of the functionality which doesn’t exist in earlier versions. The original code is quite long, that’ s why you can find a very similar case below. The code I am sharing is not causing any problems, but the original one is problematic. Are there anyone facing the same problem?

Thanks.

from random import random
from bokeh.layouts import column
from bokeh.models import Button
from bokeh.palettes import RdYlBu3
from bokeh.plotting import figure, curdoc
from bokeh.models import ColumnDataSource
import copy
from functools import partial
from random import random
from threading import Thread
import time

from bokeh.models import ColumnDataSource
from bokeh.plotting import curdoc, figure

from tornado import gen

create a plot and style its properties

i = 0
count = 0
class Dummy:
def init(self):
self._data = ColumnDataSource(dict(x = [1],y=[0],text_color=[RdYlBu3[1%3]],text=[str(1)]))
dummy = Dummy()
def make_doc(doc):
doc = doc

p = figure(x_range=(0, 100), y_range=(0, 100), toolbar_location=None)
p.border_fill_color = 'black'
p.background_fill_color = 'black'
p.outline_line_color = None
p.grid.grid_line_color = None

# add a text renderer to our plot (no data yet)p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
r = p.text(x="x", y="y", text="text", text_color="text_color", text_font_size="20pt",
           text_baseline="middle", text_align="center",source = dummy._data)
#p.add_glyph(source, glyph)


#ds = r.data_source
@gen.coroutine
def update(x, y,text,text_color):
    dummy._data.stream(dict(x=x, y=y,text=text,text_color=text_color))

def blocking_task():
    while True:
        # do some blocking computation
        time.sleep(60)
        global i
        global count
        dummyDict = copy.deepcopy(dummy._data.data)
        if count == 0:
            x = dummyDict['x'][0]
            y = dummyDict['y'][0]
        else:
            x = i
            y = i*2
        print(x,"xi alabiliyo mu blocking")
        # BEST PRACTICE --- update .data in one step with a new dict
        new_data = dict()
        new_data['x'] = [x]
        new_data['y'] = [y]
        new_data['text_color'] = [RdYlBu3[i%3]]
        new_data['text'] = [str(i)]
        doc.add_next_tick_callback(partial(update, x=new_data['x'], y=new_data['y'],text=new_data['text'],text_color=new_data['text_color']))
        count += 1
        i = i + 1
        print(i,"i")
        #but update the document from callback
   

# create a callback that will add a number in a random location
def callback():
    global i
    global count
    dummyDict = copy.deepcopy(dummy._data.data)
    if count == 0:
        x = dummyDict['x'][0]
        y = dummyDict['y'][0]
    else:
        x = 2
        y = 4
    print(x,"xi alabiliyo mu callback")
    # BEST PRACTICE --- update .data in one step with a new dict
    new_data = dict()
    new_data['x'] = dummy._data.data['x'] + [x]
    new_data['y'] = dummy._data.data['y'] + [y]
    new_data['text_color'] = dummy._data.data['text_color'] + [RdYlBu3[i%3]]
    new_data['text'] = dummy._data.data['text'] + [str(i)]
    dummy._data.data = new_data
    count += 1
    i = i + 1

# add a button widget and configure with the call back
button = Button(label="Press Me")
button.on_click(callback)
doc.add_root(column(button, p))
thread = Thread(target=blocking_task)
thread.start()
print(dummy._data,"data itself")

doc = curdoc()
make_doc(doc)


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4bfe7017-dddf-49e1-949a-75dc103332eb%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0c683017-8547-48cb-b447-d1b47d392d65%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan,

I just wanted to let you know that after some search on the issue, I found a very similar problem related with what I face in following link.

Thanks,

Baran.

···

On Saturday, January 19, 2019 at 10:03:25 PM UTC+3, Bryan Van de ven wrote:

Hi Baran,

I feel like I might have tun into a similar example just a day or two ago. If this were a completely general issue it would be a serious regression. That said, we rely on executing CustomJS callbacks as a central part of our integration test machinery for bokeh server functionality. So, there must be something specific that only happens under certain circumstances going on. Can you construct a minimal reproducing script, and make a new GH issue with that information, so that it can be investigated properly?

Thanks,

Bryan

On Jan 19, 2019, at 06:03, [email protected] wrote:

Hi Bryan,

I just wanted to tell that the reason why I am using the latest release is because I wanted to add range tool attribute to my code as in example below. Other than that I can use 0.12.15, as it doesn’t produce any errors.

https://bokeh.pydata.org/en/dev/docs/gallery/range_tool.html

Thanks,

Baran.

On Saturday, January 19, 2019 at 4:52:22 PM UTC+3, Baran Köseoğlu wrote:

Hi Bryan,

Thanks for your reply. After an extensive debugging, I found out that the problem is with the plots that are updated via custom javascript callback functions. Whenever I tried to pass a bokeh model inside a customJS fuction, it gives me an error saying that this model I am trying to pass is not document. But I am for sure that I defined the bokeh model that I am passing, in fact just before the javascript callback . Why do you think that this is the case? By the way, when I execute the same code in earlier versions like 0.12.15, there is no such error.

On Monday, January 14, 2019 at 1:42:30 AM UTC+3, Bryan Van de ven wrote:

Hi,

When I run this code with Bokeh 1.0.4 I don’t see any error, either in the server logs of the browser console. Also it is working AFAICT (callback message print and the plot updates). Perhaps you can provide more information?

Thanks,

Bryan

On Jan 13, 2019, at 13:13, [email protected] wrote:

Hi,

When I update bokeh version installed in my local computer, I keep getting the following error from Column Data Sources that I have defined inside a class.

Uncaught Error: reference {“id”:“1242”,“type”:“Div”} isn’t known (not in Document?)

When I install an earlier version of bokeh, the error appears to be resolved. But I don’t want to do that since I want some of the functionality which doesn’t exist in earlier versions. The original code is quite long, that’ s why you can find a very similar case below. The code I am sharing is not causing any problems, but the original one is problematic. Are there anyone facing the same problem?

Thanks.

from random import random
from bokeh.layouts import column
from bokeh.models import Button
from bokeh.palettes import RdYlBu3
from bokeh.plotting import figure, curdoc
from bokeh.models import ColumnDataSource
import copy
from functools import partial
from random import random
from threading import Thread
import time

from bokeh.models import ColumnDataSource
from bokeh.plotting import curdoc, figure

from tornado import gen

create a plot and style its properties

i = 0
count = 0
class Dummy:
def init(self):
self._data = ColumnDataSource(dict(x = [1],y=[0],text_color=[RdYlBu3[1%3]],text=[str(1)]))
dummy = Dummy()
def make_doc(doc):
doc = doc

p = figure(x_range=(0, 100), y_range=(0, 100), toolbar_location=None)
p.border_fill_color = 'black'
p.background_fill_color = 'black'
p.outline_line_color = None
p.grid.grid_line_color = None

# add a text renderer to our plot (no data yet)p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
r = p.text(x="x", y="y", text="text", text_color="text_color", text_font_size="20pt",
           text_baseline="middle", text_align="center",source = dummy._data)
#p.add_glyph(source, glyph)


#ds = r.data_source
@gen.coroutine
def update(x, y,text,text_color):
    dummy._data.stream(dict(x=x, y=y,text=text,text_color=text_color))

def blocking_task():
    while True:
        # do some blocking computation
        time.sleep(60)
        global i
        global count
        dummyDict = copy.deepcopy(dummy._data.data)
        if count == 0:
            x = dummyDict['x'][0]
            y = dummyDict['y'][0]
        else:
            x = i
            y = i*2
        print(x,"xi alabiliyo mu blocking")
        # BEST PRACTICE --- update .data in one step with a new dict
        new_data = dict()
        new_data['x'] = [x]
        new_data['y'] = [y]
        new_data['text_color'] = [RdYlBu3[i%3]]
        new_data['text'] = [str(i)]
        doc.add_next_tick_callback(partial(update, x=new_data['x'], y=new_data['y'],text=new_data['text'],text_color=new_data['text_color']))
        count += 1
        i = i + 1
        print(i,"i")
        #but update the document from callback
   

# create a callback that will add a number in a random location
def callback():
    global i
    global count
    dummyDict = copy.deepcopy(dummy._data.data)
    if count == 0:
        x = dummyDict['x'][0]
        y = dummyDict['y'][0]
    else:
        x = 2
        y = 4
    print(x,"xi alabiliyo mu callback")
    # BEST PRACTICE --- update .data in one step with a new dict
    new_data = dict()
    new_data['x'] = dummy._data.data['x'] + [x]
    new_data['y'] = dummy._data.data['y'] + [y]
    new_data['text_color'] = dummy._data.data['text_color'] + [RdYlBu3[i%3]]
    new_data['text'] = dummy._data.data['text'] + [str(i)]
    dummy._data.data = new_data
    count += 1
    i = i + 1

# add a button widget and configure with the call back
button = Button(label="Press Me")
button.on_click(callback)
doc.add_root(column(button, p))
thread = Thread(target=blocking_task)
thread.start()
print(dummy._data,"data itself")

doc = curdoc()
make_doc(doc)


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4bfe7017-dddf-49e1-949a-75dc103332eb%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0c683017-8547-48cb-b447-d1b47d392d65%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi Bryan,

You can find the codes below. One is giving an error about the bokeh model passed to CustomJS function but the other one, although is taking more bokeh models as argument, is not giving any error.

#not giving any error

from bokeh.plotting import figure,curdoc

import numpy as np

from bokeh.models import ColumnDataSource, CustomJS, Div

from bokeh.models.widgets import Panel, Tabs

from bokeh.layouts import row,column

N = 9

x = np.linspace(-2, 2, N)

y = x**2

r = x/15.0+0.3

start_angle =

end_angle =

color =

fill_alpha =

line_alpha =

for element in range(len®):

start_angle.append(0.6)

end_angle.append(4.1)

color.append('blue')

fill_alpha.append(1)

line_alpha.append(1)

def make_doc():

source = ColumnDataSource(dict(x=x, y=y, r=r,start_angle=start_angle,end_angle=end_angle,

	color=color,fill_alpha=fill_alpha,line_alpha=line_alpha))

plot = figure(

    title=None, plot_width=300, plot_height=300,

    h_symmetry=False, v_symmetry=False, min_border=0, toolbar_location=None)

pCustomerDetails = Div(text="hey man",

    width=300, height=100)

#glyph = Wedge(x="x", y="y", radius="r", start_angle=0.6, end_angle=4.1, fill_color="#b3de69")

#plot.add_glyph(source, glyph)

sequencePlot1 = figure(plot_width=450,plot_height = 530,toolbar_location=None,y_range = (-0.2,11), x_range = (-1,33.6))

sequencePlot2 = figure(plot_width=450,plot_height = 530,toolbar_location=None,y_range = (-0.2,11), x_range = (-1,33.6))

plot.wedge(x="x",line_alpha="line_alpha", source = source, y="y", radius="r", start_angle="start_angle", end_angle="end_angle",

 color="color",fill_alpha = "fill_alpha")

tabSequencePressed = CustomJS(args=dict(source=source),code="""

	console.log("do nothing")

""")

tabSequencePlot1 = Panel(child=sequencePlot1, title="time")

tabSequencePlot2 = Panel(child=sequencePlot2, title="order")

tabsSequencePlot = Tabs(tabs=[tabSequencePlot1, tabSequencePlot2 ],callback = tabSequencePressed)

callback = CustomJS(args = dict(div = pCustomerDetails,tabsSequencePlot = tabsSequencePlot,source = source,pCustomerDetails=pCustomerDetails),code="""

	dict = source.data

	dict['x'] = []

	dict['y'] = []

	dict['r'] = []

	dict['start_angle'] = []

	dict['end_angle'] = []

	dict['color'] = []

	dict['fill_alpha'] = []

	dict['line_alpha'] = []

	source.data = dict

	source.change.emit();

	""")

plot.js_on_event('tap', callback)

#xaxis = LinearAxis()

#plot.add_layout(xaxis, 'below')

#yaxis = LinearAxis()

#plot.add_layout(yaxis, 'left')

#plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))

#plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))

curdoc().add_root(row(column(plot,tabsSequencePlot),pCustomerDetails))

make_doc()

#gives error

from bokeh.plotting import figure

from bokeh.layouts import layout

from bokeh.models import Div, CustomJS

from bokeh.io import curdoc

from bokeh.layouts import row,column

prepare some data

x = [1, 2, 3, 4, 5]

y = [6, 7, 2, 4, 5]

create a new plot with a title and axis labels

p = figure(title=“simple line example”, x_axis_label=‘x’, y_axis_label=‘y’)

add a line renderer with legend and line thickness

p.line(x, y, legend=“Temp.”, line_width=2)

div = Div(text=“hey man”)

code = “”"

console.log(‘nothing’);

“”"

callback = CustomJS(args=dict(d=div), code=code)

#p.x_range.callback = CustomJS(args=dict(d=div), code=code)

p.js_on_event(‘tap’, callback)

#l = layout([[p]])

curdoc().add_root(column(p,div))

Thanks,

Baran.

···

On Saturday, January 19, 2019 at 10:03:25 PM UTC+3, Bryan Van de ven wrote:

Hi Baran,

I feel like I might have tun into a similar example just a day or two ago. If this were a completely general issue it would be a serious regression. That said, we rely on executing CustomJS callbacks as a central part of our integration test machinery for bokeh server functionality. So, there must be something specific that only happens under certain circumstances going on. Can you construct a minimal reproducing script, and make a new GH issue with that information, so that it can be investigated properly?

Thanks,

Bryan

On Jan 19, 2019, at 06:03, [email protected] wrote:

Hi Bryan,

I just wanted to tell that the reason why I am using the latest release is because I wanted to add range tool attribute to my code as in example below. Other than that I can use 0.12.15, as it doesn’t produce any errors.

https://bokeh.pydata.org/en/dev/docs/gallery/range_tool.html

Thanks,

Baran.

On Saturday, January 19, 2019 at 4:52:22 PM UTC+3, Baran Köseoğlu wrote:

Hi Bryan,

Thanks for your reply. After an extensive debugging, I found out that the problem is with the plots that are updated via custom javascript callback functions. Whenever I tried to pass a bokeh model inside a customJS fuction, it gives me an error saying that this model I am trying to pass is not document. But I am for sure that I defined the bokeh model that I am passing, in fact just before the javascript callback . Why do you think that this is the case? By the way, when I execute the same code in earlier versions like 0.12.15, there is no such error.

On Monday, January 14, 2019 at 1:42:30 AM UTC+3, Bryan Van de ven wrote:

Hi,

When I run this code with Bokeh 1.0.4 I don’t see any error, either in the server logs of the browser console. Also it is working AFAICT (callback message print and the plot updates). Perhaps you can provide more information?

Thanks,

Bryan

On Jan 13, 2019, at 13:13, [email protected] wrote:

Hi,

When I update bokeh version installed in my local computer, I keep getting the following error from Column Data Sources that I have defined inside a class.

Uncaught Error: reference {“id”:“1242”,“type”:“Div”} isn’t known (not in Document?)

When I install an earlier version of bokeh, the error appears to be resolved. But I don’t want to do that since I want some of the functionality which doesn’t exist in earlier versions. The original code is quite long, that’ s why you can find a very similar case below. The code I am sharing is not causing any problems, but the original one is problematic. Are there anyone facing the same problem?

Thanks.

from random import random
from bokeh.layouts import column
from bokeh.models import Button
from bokeh.palettes import RdYlBu3
from bokeh.plotting import figure, curdoc
from bokeh.models import ColumnDataSource
import copy
from functools import partial
from random import random
from threading import Thread
import time

from bokeh.models import ColumnDataSource
from bokeh.plotting import curdoc, figure

from tornado import gen

create a plot and style its properties

i = 0
count = 0
class Dummy:
def init(self):
self._data = ColumnDataSource(dict(x = [1],y=[0],text_color=[RdYlBu3[1%3]],text=[str(1)]))
dummy = Dummy()
def make_doc(doc):
doc = doc

p = figure(x_range=(0, 100), y_range=(0, 100), toolbar_location=None)
p.border_fill_color = 'black'
p.background_fill_color = 'black'
p.outline_line_color = None
p.grid.grid_line_color = None

# add a text renderer to our plot (no data yet)p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
r = p.text(x="x", y="y", text="text", text_color="text_color", text_font_size="20pt",
           text_baseline="middle", text_align="center",source = dummy._data)
#p.add_glyph(source, glyph)


#ds = r.data_source
@gen.coroutine
def update(x, y,text,text_color):
    dummy._data.stream(dict(x=x, y=y,text=text,text_color=text_color))

def blocking_task():
    while True:
        # do some blocking computation
        time.sleep(60)
        global i
        global count
        dummyDict = copy.deepcopy(dummy._data.data)
        if count == 0:
            x = dummyDict['x'][0]
            y = dummyDict['y'][0]
        else:
            x = i
            y = i*2
        print(x,"xi alabiliyo mu blocking")
        # BEST PRACTICE --- update .data in one step with a new dict
        new_data = dict()
        new_data['x'] = [x]
        new_data['y'] = [y]
        new_data['text_color'] = [RdYlBu3[i%3]]
        new_data['text'] = [str(i)]
        doc.add_next_tick_callback(partial(update, x=new_data['x'], y=new_data['y'],text=new_data['text'],text_color=new_data['text_color']))
        count += 1
        i = i + 1
        print(i,"i")
        #but update the document from callback
   

# create a callback that will add a number in a random location
def callback():
    global i
    global count
    dummyDict = copy.deepcopy(dummy._data.data)
    if count == 0:
        x = dummyDict['x'][0]
        y = dummyDict['y'][0]
    else:
        x = 2
        y = 4
    print(x,"xi alabiliyo mu callback")
    # BEST PRACTICE --- update .data in one step with a new dict
    new_data = dict()
    new_data['x'] = dummy._data.data['x'] + [x]
    new_data['y'] = dummy._data.data['y'] + [y]
    new_data['text_color'] = dummy._data.data['text_color'] + [RdYlBu3[i%3]]
    new_data['text'] = dummy._data.data['text'] + [str(i)]
    dummy._data.data = new_data
    count += 1
    i = i + 1

# add a button widget and configure with the call back
button = Button(label="Press Me")
button.on_click(callback)
doc.add_root(column(button, p))
thread = Thread(target=blocking_task)
thread.start()
print(dummy._data,"data itself")

doc = curdoc()
make_doc(doc)


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4bfe7017-dddf-49e1-949a-75dc103332eb%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0c683017-8547-48cb-b447-d1b47d392d65%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

I was able to produce same errors with the first code by replacing tittle=None with something not Null and erasing toolbar_location=None. So I assume keyword arguments are not inherited from super class of figure.

···

On Saturday, January 19, 2019 at 10:03:25 PM UTC+3, Bryan Van de ven wrote:

Hi Baran,

I feel like I might have tun into a similar example just a day or two ago. If this were a completely general issue it would be a serious regression. That said, we rely on executing CustomJS callbacks as a central part of our integration test machinery for bokeh server functionality. So, there must be something specific that only happens under certain circumstances going on. Can you construct a minimal reproducing script, and make a new GH issue with that information, so that it can be investigated properly?

Thanks,

Bryan

On Jan 19, 2019, at 06:03, [email protected] wrote:

Hi Bryan,

I just wanted to tell that the reason why I am using the latest release is because I wanted to add range tool attribute to my code as in example below. Other than that I can use 0.12.15, as it doesn’t produce any errors.

https://bokeh.pydata.org/en/dev/docs/gallery/range_tool.html

Thanks,

Baran.

On Saturday, January 19, 2019 at 4:52:22 PM UTC+3, Baran Köseoğlu wrote:

Hi Bryan,

Thanks for your reply. After an extensive debugging, I found out that the problem is with the plots that are updated via custom javascript callback functions. Whenever I tried to pass a bokeh model inside a customJS fuction, it gives me an error saying that this model I am trying to pass is not document. But I am for sure that I defined the bokeh model that I am passing, in fact just before the javascript callback . Why do you think that this is the case? By the way, when I execute the same code in earlier versions like 0.12.15, there is no such error.

On Monday, January 14, 2019 at 1:42:30 AM UTC+3, Bryan Van de ven wrote:

Hi,

When I run this code with Bokeh 1.0.4 I don’t see any error, either in the server logs of the browser console. Also it is working AFAICT (callback message print and the plot updates). Perhaps you can provide more information?

Thanks,

Bryan

On Jan 13, 2019, at 13:13, [email protected] wrote:

Hi,

When I update bokeh version installed in my local computer, I keep getting the following error from Column Data Sources that I have defined inside a class.

Uncaught Error: reference {“id”:“1242”,“type”:“Div”} isn’t known (not in Document?)

When I install an earlier version of bokeh, the error appears to be resolved. But I don’t want to do that since I want some of the functionality which doesn’t exist in earlier versions. The original code is quite long, that’ s why you can find a very similar case below. The code I am sharing is not causing any problems, but the original one is problematic. Are there anyone facing the same problem?

Thanks.

from random import random
from bokeh.layouts import column
from bokeh.models import Button
from bokeh.palettes import RdYlBu3
from bokeh.plotting import figure, curdoc
from bokeh.models import ColumnDataSource
import copy
from functools import partial
from random import random
from threading import Thread
import time

from bokeh.models import ColumnDataSource
from bokeh.plotting import curdoc, figure

from tornado import gen

create a plot and style its properties

i = 0
count = 0
class Dummy:
def init(self):
self._data = ColumnDataSource(dict(x = [1],y=[0],text_color=[RdYlBu3[1%3]],text=[str(1)]))
dummy = Dummy()
def make_doc(doc):
doc = doc

p = figure(x_range=(0, 100), y_range=(0, 100), toolbar_location=None)
p.border_fill_color = 'black'
p.background_fill_color = 'black'
p.outline_line_color = None
p.grid.grid_line_color = None

# add a text renderer to our plot (no data yet)p.circle([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], size=20, color="navy", alpha=0.5)
r = p.text(x="x", y="y", text="text", text_color="text_color", text_font_size="20pt",
           text_baseline="middle", text_align="center",source = dummy._data)
#p.add_glyph(source, glyph)


#ds = r.data_source
@gen.coroutine
def update(x, y,text,text_color):
    dummy._data.stream(dict(x=x, y=y,text=text,text_color=text_color))

def blocking_task():
    while True:
        # do some blocking computation
        time.sleep(60)
        global i
        global count
        dummyDict = copy.deepcopy(dummy._data.data)
        if count == 0:
            x = dummyDict['x'][0]
            y = dummyDict['y'][0]
        else:
            x = i
            y = i*2
        print(x,"xi alabiliyo mu blocking")
        # BEST PRACTICE --- update .data in one step with a new dict
        new_data = dict()
        new_data['x'] = [x]
        new_data['y'] = [y]
        new_data['text_color'] = [RdYlBu3[i%3]]
        new_data['text'] = [str(i)]
        doc.add_next_tick_callback(partial(update, x=new_data['x'], y=new_data['y'],text=new_data['text'],text_color=new_data['text_color']))
        count += 1
        i = i + 1
        print(i,"i")
        #but update the document from callback
   

# create a callback that will add a number in a random location
def callback():
    global i
    global count
    dummyDict = copy.deepcopy(dummy._data.data)
    if count == 0:
        x = dummyDict['x'][0]
        y = dummyDict['y'][0]
    else:
        x = 2
        y = 4
    print(x,"xi alabiliyo mu callback")
    # BEST PRACTICE --- update .data in one step with a new dict
    new_data = dict()
    new_data['x'] = dummy._data.data['x'] + [x]
    new_data['y'] = dummy._data.data['y'] + [y]
    new_data['text_color'] = dummy._data.data['text_color'] + [RdYlBu3[i%3]]
    new_data['text'] = dummy._data.data['text'] + [str(i)]
    dummy._data.data = new_data
    count += 1
    i = i + 1

# add a button widget and configure with the call back
button = Button(label="Press Me")
button.on_click(callback)
doc.add_root(column(button, p))
thread = Thread(target=blocking_task)
thread.start()
print(dummy._data,"data itself")

doc = curdoc()
make_doc(doc)


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/4bfe7017-dddf-49e1-949a-75dc103332eb%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0c683017-8547-48cb-b447-d1b47d392d65%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.