bokeh server: Is there a way to "manually" sync all models between python and JS

Thanks for the answer !

Here is a specific small example:

from bokeh.models import ColumnDataSource, CustomJS, Button
from bokeh.io import curdoc
from bokeh.plotting import figure
from bokeh.layouts import Row

def callback(attr,old,new):
source = curdoc().select_one({‘name’:‘source’})
print source.data

source = ColumnDataSource(data={‘x’:,‘y’:},name=‘source’)

fig = figure(tools=‘tap’)
fig.scatter(‘x’,‘y’,size=10,source=source)

source.on_change(‘selected’,callback)

button = Button(label=‘test’,width=100)

button_code = “”"
var data = source.data;
data[‘x’] = ;
data[‘y’] = ;
for (i=0;i<10;i++){
data[‘x’].push(i);
data[‘y’].push(i);
}
source.change.emit();
“”"

button.callback = CustomJS(args={‘source’:source},code=button_code)

curdoc().add_root(Row(fig,button))

``

After clicking the button the plot is updated with the points

After clicking on a point the terminal output is:
{‘y’: , ‘x’: }

``