Bokeh Server app can't load python object with shelve module

I’m trying to load an object with shelve module. This object allows me to retrieve custom formatted numpy matrix from a pandas dataframe in .parquet format.

I’m getting this error.

(base) C:\Users*>bokeh serve --show "C:\Users***\Code\graph\statistics.py"

2018-02-17 12:39:52,727 Starting Bokeh server version 0.12.10 (running on Tornado 4.5.2)

2018-02-17 12:39:52,727 Bokeh app running at: http://localhost:5006/statistics

2018-02-17 12:39:52,727 Starting Bokeh server with process id: 9240

2018-02-17 12:39:54,025 Error running application handler <bokeh.application.handlers.script.ScriptHandler object at 0x00000197F9B79F28>: No module named ‘asset’

File “shelve.py”, line 114, in getitem:

value = Unpickler(f).load() Traceback (most recent call last):

File “C:\Users***\Anaconda3\lib\shelve.py”, line 111, in getitem

value = self.cache[key]

KeyError: ‘evaluator’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File “C:\Users***\Anaconda3\lib\site-packages\bokeh\application\handlers\code_runner.py”, line 125, in run

exec(self._code, module.dict)

File “C:\Users*****\Code\graph\statistics.py”, line 119, in

layout = row(widgets, create_figure())

File “C:\Users*****\Code\graph\statistics.py”, line 54, in create_figure

evaluator = save[‘evaluator’]

File “C:\Users***\Anaconda3\lib\shelve.py”, line 114, in getitem

value = Unpickler(f).load()

ModuleNotFoundError: No module named 'asset’

2018-02-17 12:39:54,025 200 GET /statistics (::1) 62.51ms

2018-02-17 12:39:54,322 101 GET /statistics/ws?bokeh-protocol-version=1.0&bokeh-session-id=USYr1G4GploKLcQiZ8Ppwm9BRGisBnXH0rUGGfAjBeb4 (::1) 0.00ms

2018-02-17 12:39:54,322 WebSocket connection opened

2018-02-17 12:39:54,322 ServerConnection created

2018-02-17 12:40:22,234 WebSocket connection closed: code=1001, reason=None

The evaluator object i’m trying to load does not need the asset module, indeed. Also, the asset module is a Python Package folder created with PyCharm that contains the classic init.py empty file. I don’t understand why Bokeh cant load that f*****g object.

Hi,

I am not sure offhand. In order to greatly reduce the code required by users (and developers) to have an automatic, transparent Python-JS viz and app framework, Bokeh employs some measure of both meta-programming as well explicit source code evaluation ala Jupyter kernels. I can certainly imagine some part of that interacts badly with shelve. Maybe something can be done to improve things, or maybe not and we simply will have to document the incompatibility. But it will take investigation. To that end, the very best thing you can provide is a GitHub issue with a 100% complete, self-contained example that reproduces the issue (i.e. including any necessary data files, or a script to generate them):

  Issues · bokeh/bokeh · GitHub

Thanks,

Bryan

···

On Feb 17, 2018, at 03:52, Thomas Cercato <[email protected]> wrote:

I'm trying to load an object with shelve module. This object allows me to retrieve custom formatted numpy matrix from a pandas dataframe in .parquet format.

I'm getting this error.

(base) C:\Users\***>bokeh serve --show "C:\Users\***\***\***\Code\graph\statistics.py"
2018-02-17 12:39:52,727 Starting Bokeh server version 0.12.10 (running on Tornado 4.5.2)
2018-02-17 12:39:52,727 Bokeh app running at: http://localhost:5006/statistics
2018-02-17 12:39:52,727 Starting Bokeh server with process id: 9240
2018-02-17 12:39:54,025 Error running application handler <bokeh.application.handlers.script.ScriptHandler object at 0x00000197F9B79F28>: No module named 'asset'
File "shelve.py", line 114, in __getitem__:
value = Unpickler(f).load() Traceback (most recent call last):
  File "C:\Users\***\Anaconda3\lib\shelve.py", line 111, in __getitem__
    value = self.cache[key]
KeyError: 'evaluator'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\***\Anaconda3\lib\site-packages\bokeh\application\handlers\code_runner.py", line 125, in run
    exec(self._code, module.__dict__)
  File "C:\Users\***\***\***\Code\graph\statistics.py", line 119, in <module>
    layout = row(widgets, create_figure())
  File "C:\Users\***\***\***\Code\graph\statistics.py", line 54, in create_figure
    evaluator = save['evaluator']
  File "C:\Users\***\Anaconda3\lib\shelve.py", line 114, in __getitem__
    value = Unpickler(f).load()
ModuleNotFoundError: No module named 'asset'

2018-02-17 12:39:54,025 200 GET /statistics (::1) 62.51ms
2018-02-17 12:39:54,322 101 GET /statistics/ws?bokeh-protocol-version=1.0&bokeh-session-id=USYr1G4GploKLcQiZ8Ppwm9BRGisBnXH0rUGGfAjBeb4 (::1) 0.00ms
2018-02-17 12:39:54,322 WebSocket connection opened
2018-02-17 12:39:54,322 ServerConnection created
2018-02-17 12:40:22,234 WebSocket connection closed: code=1001, reason=None

The evaluator object i'm trying to load does not need the asset module, indeed. Also, the asset module is a Python Package folder created with PyCharm that contains the classic __init__.py empty file. I don't understand why Bokeh cant load that f*****g object.

--
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/45c1cd2f-b2a8-4cb4-a30d-14dc664232b9%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.