Skip to content

Commit

Permalink
Added timeit calls for bokeh line dash functions to track python side…
Browse files Browse the repository at this point in the history
… execution times
  • Loading branch information
oislen committed Oct 14, 2024
1 parent ddfc0ed commit 453566c
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions dashboard/utilities/bokeh_line_dash.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pickle
import logging
from beartype import beartype
from typing import Union
from bokeh.models import Select, CheckboxGroup, Div, Button, MultiSelect
Expand All @@ -8,6 +9,7 @@
import cons
from utilities.bokeh_line_data import bokeh_line_data
from utilities.bokeh_line_plot import bokeh_line_plot
from utilities.timeit import timeit

@beartype
def bokeh_line_dash():
Expand All @@ -21,21 +23,20 @@ def bokeh_line_dash():
bokeh.layouts.row
The interactive bokeh line dashboard
"""
logging.info("Initialise line plot begin")
with open(cons.preaggregate_data_fpath, "rb") as handle:
pre_agg_data_dict = pickle.load(handle)
# generate bokeh data for line plot
bokeh_line_data_dict = bokeh_line_data(pre_agg_data_dict)
bokeh_line_data_params = {"pre_agg_data_dict":pre_agg_data_dict}
bokeh_line_data_dict = timeit(func=bokeh_line_data, params=bokeh_line_data_params)
# create bokeh plot
line_plot = bokeh_line_plot(
bokeh_line_data_dict,
col=cons.col_default,
stat=cons.stat_default,
agg_level=cons.line_agg_level_default,
selection=cons.counties,
)
bokeh_line_plot_params = {"bokeh_data_dict":bokeh_line_data_dict, "col":cons.col_default, "stat":cons.stat_default, "agg_level":cons.line_agg_level_default, "selection":cons.counties}
line_plot = timeit(func=bokeh_line_plot, params=bokeh_line_plot_params)
logging.info("Initialise line plot end")

# create call back function for bokeh dashboard interaction
def callback_line_plot(attr, old, new):
logging.info("Callback line plot begin")
# extract new selector value
agg_level = line_agg_level_selector.value
col = line_col_selector.value
Expand All @@ -44,15 +45,11 @@ def callback_line_plot(attr, old, new):
for i in line_county_multiselect.value:
selection.append(cons.counties[int(i)])
# update bokeh plot
line_plot = bokeh_line_plot(
bokeh_line_data_dict,
col=col,
stat=stat,
agg_level=agg_level,
selection=selection,
)
bokeh_line_plot_params = {"bokeh_data_dict":bokeh_line_data_dict, "col":col, "stat":stat, "agg_level":agg_level, "selection":selection}
line_plot = timeit(func=bokeh_line_plot, params=bokeh_line_plot_params)
# reassign bokeh plot to bokeh dashboard
dashboard_line.children[1] = line_plot
logging.info("Callback line plot end")

def callback_multiselect_selectall():
line_county_multiselect.value = cons.counties_values
Expand Down

0 comments on commit 453566c

Please sign in to comment.