Hi,
Bokeh dynamically creates module new module objects every time a user session is initiated, and the app code is run inside that new module for isolation. If you are saving/reading between different sessions. then the modules will necessarily be different. The pickle docs suggest that this is this is not permissible:
"""
pickle can save and restore class instances transparently, however the class definition must be importable and live in the same module as when the object was stored.
"""
The only potential solution I can imagine is to move *all* code for loading and saving pickles to functions in a separate module, completely outside the Bokeh app script, that the app script imports. That might coax Python to use that (external, fixed) module instead of the dynamic Bokeh app module for __class__. However, you will simply have to try and see, I can't say for certain. Otherwise, here are may other common serialization methods (if you want to continue using Bokeh), or a handful of other potential visualization tools (if you want to continue to use pickle).
Thanks,
Bryan
ยทยทยท
On Feb 21, 2019, at 00:05, [email protected] wrote:
Hello friends,
I am using bokeh server for my application.
I use command: bokeh serve mydir
in my dir there is main.py file in which I have defined DataCollector class.
I need to pickle this class and read it periodically but under bokeh serve it gives me an error while deserializing: ModuleNotFoundError: No module named 'bk_script_1001'.I think it is because the __class__ method of DataCollector gets value of bk_script_1001.DataCollector while running with bokeh server.
Can anyone help me in avoiding this ModuleNotFoundError?
Thank you very much.
--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/0a1047b0-4095-457b-b468-6fc78331a0e5%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.