Skip to content

Commit

Permalink
Add public API to get and set custom model cache
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Oct 16, 2018
1 parent 02caf9d commit ec3122d
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions bokeh/util/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,10 +378,21 @@ def _get_custom_models(models):
return None
return custom_models

def _get_cached_implementation(implementation):
def _model_cache_no_op(implementation):
"""Return cached compiled implementation"""
return None

_CACHING_IMPLEMENTATION = _model_cache_no_op

def get_cache_hook():
'''Returns the current cache hook used to look up the compiled code given an Implementation'''
return _CACHING_IMPLEMENTATION

def set_cache_hook(hook):
'''Sets a compiled model cache hook used to look up the compiled code given an Implementation'''
global _CACHING_IMPLEMENTATION
_CACHING_IMPLEMENTATION = hook

def _compile_models(models):
"""Returns the compiled implementation of supplied `models`. """
custom_models = _get_custom_models(models)
Expand All @@ -401,7 +412,7 @@ def _compile_models(models):

for model in ordered_models:
impl = model.implementation
compiled = _get_cached_implementation(impl)
compiled = _CACHING_IMPLEMENTATION(impl)
if compiled is None:
compiled = nodejs_compile(impl.code, lang=impl.lang, file=impl.file)

Expand Down

0 comments on commit ec3122d

Please sign in to comment.