本文整理汇总了Python中bokeh.session.Session.publish方法的典型用法代码示例。如果您正苦于以下问题:Python Session.publish方法的具体用法?Python Session.publish怎么用?Python Session.publish使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bokeh.session.Session
的用法示例。
在下文中一共展示了Session.publish方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wrapper
# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import publish [as 别名]
def wrapper(*args, **kwargs):
document = Document()
session = Session(name=url, root_url=url)
session.use_doc(document.docid)
session.load_document(document)
session.publish()
document.autoadd = False
document.autostore = False
obj = func(*args, **kwargs)
obj._docid = session.docid
obj._root_url = session.root_url
document.add(obj)
session.store_document(document)
return obj
示例2: wrapper
# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import publish [as 别名]
def wrapper(*args, **kwargs):
reset_output()
docname = prefix + str(uuid.uuid4())
session = Session(name=url, root_url=url)
session.use_doc(docname)
session.load_document(curdoc())
session.publish()
curdoc().autoadd = False
curdoc().autostore = False
obj = func(*args, **kwargs)
tag = embed.autoload_server(obj, session, public=True)
obj._tag = tag
curdoc().add(obj)
changed = session.store_document(curdoc())
logger.debug("stored: %s", str(changed))
return obj
示例3: prepare_widgets
# 需要导入模块: from bokeh.session import Session [as 别名]
# 或者: from bokeh.session.Session import publish [as 别名]
def prepare_widgets():
print "initializing..."
# start bokeh-server session
global client
client = Session(root_url='http://0.0.0.0:7010/', load_from_config=False)
try:
client.register(bs_login,bs_password)
except:pass
client.login(bs_login,bs_password)
###CREATE WIDGETS
print "preaparing widgets..."
#hist1: hist with overlay
import analysis.distfit as distfit
import pandas as pd
xname,xmin,xmax,xbins = "invariantMass",0,10,50
bin_separators = np.histogram([],bins=xbins, range=[xmin,xmax])[1]
bin_centers = np.array([0.5*(bin_separators[i]+bin_separators[i+1]) for i in range(len(bin_separators)-1)])
bins = pd.DataFrame({"x":bin_centers})
expo_gap = lambda x,slope: (x>=xmin)*(x<=xmax)*distfit.exponential(x-xmin,slope)/(1.-np.e**(-(xmax-xmin)*slope))
mix_model = distfit.DistributionsMixture(
distributions={'sig': distfit.gauss, 'bck': expo_gap},
weights_ranges={'sig': [1.,10.], 'bck': [1.,10.]},
parameter_ranges={'mean': [xmin ,xmax], 'sigma': [0., xmax-xmin], 'slope': [0, 15.]},
column_ranges={'x': [xmin, xmax]},
sampling_strategy='grid',
)
mix_model.compile(bins,1000) #takes several seconds
hist1_base = WhiskeredHistWidget(xname,xmin,xmax,xbins,es,
fig = figure(plot_width=600, plot_height=600,tools=['wheel_zoom','ywheel_zoom','pan','resize','reset']))
hist1 = MLFitOverlayWidget(hist1_base,mix_model,n_pts=100)
widgets.append(hist1)
#hist2: just hist
hist2 = ClassicHistWidget("muonHits",0,100,30,es,
fig = figure(plot_width=600, plot_height=600,tools=['wheel_zoom','ywheel_zoom','pan','reset']))
widgets.append(hist2)
#hist3: heatmap
hist3 = HeatmapWidget("avgMass",0,35,50,
"muonHits",0,70,50,
es,fig = figure(plot_width=600, plot_height=600),)
widgets.append(hist3)
#hist4: hist with reference
hist4_base = ClassicHistWidget("dskkpi",1920,2020,30,es,
fig = figure(plot_width=600, plot_height=600,tools=['wheel_zoom','ywheel_zoom','pan','reset']))
from scipy.stats import laplace
pdf = laplace(1970,7).pdf
hist4 = ReferenceOverlay(hist4_base,pdf)
widgets.append(hist4)
###end CREATE PLOTS
print "publishing plots..."
#create a dashboard on bokeh_server
output_server(dashboard_name,client)
plots = [ hplot(widget.fig) for widget in widgets ]
global whole_dashboard
whole_dashboard = vplot(hplot(*plots[:2]),hplot(*plots[2:]))
plots.append(whole_dashboard)
for plot in plots:
client.show(plot)
client.publish()
print "creating static links..."
#publish the thing
from bokeh.embed import autoload_server
scripts = [autoload_server(plot,client,public=True) for plot in plots]
print "saving widget scripts..."
#remove previous widgets
for path_to_static in path_to_django_static,path_to_flask_static:
path_to_widgets = os.path.join(path_to_static,dashboard_name)
os.system("rm -rf " + path_to_widgets)
os.mkdir(path_to_widgets)
for i, source_script in enumerate(scripts):
#convert script...
#.........这里部分代码省略.........