Ohhhh! Makes more sense why it’s not working then haha. I still am very curious as to how the figures and etc. makes it into the result of pull_session but not other customization (done in the app itself too)! In any case though, there are a few possibilities that I can think of right now for implementation (I’ll give one a go
) -
The simplest version is just attaching a list of changes to a document every time the document is pulled, i.e. we don’t completely store the document, just the changes are stored.
So now pull_session has the functionality:
with pull_session(url=app_url) as session:
session.document.x # added by pull_session
session.document.y # added by pull_session
While it would be fine to just expect the user to mutate all their data from there how they please, it may be nice to enhance pull_session to accept functions that act on various properties of the document. I wouldn’t recommend this as a standalone improvement to pull_session since it’s unnecessarily over-complicating it - but if we’re already enhancing it I think it becomes more viable.
In terms of the hooks, I think it makes sense to also put them in bokeh.client, given its purpose: Creating and customizing specific sessions of a Bokeh application running in a Bokeh Server, before passing them to a viewer. Since we don’t want to implement the actual storage functionality ourselves it’s as simple as providing to bokeh.client a class/object that implements store and retrieve.
class MyChangeManager:
def store(self, change, property_name):
'redis or other store details, associate with property_name provided by bokeh'
def retrieve(self, property_name):
item = 'retrieve from store by id'
return item
On our side we implement the generation of uniqueIDs. The only remaining issue is ‘where do these changes get specified’? Well ideally they get specified in the bokeh application, whether it be a curdoc() version or a def app(doc):. Therefore, the MyChangeManager needs to also live within the bokeh server and be synced across processes, and then we provide the method save that can be used actually in the app to indicate to bokeh that a property needs to be saved to the store.
Largely spitballing here, overall I don’t think it’s that large of an implementation on the bokeh side, and should only remain complex enough to enable any type of store. Thoughts?