Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin page with panel.serve error log #3979

Closed
hyamanieu opened this issue Oct 10, 2022 · 0 comments · Fixed by #4033
Closed

Admin page with panel.serve error log #3979

hyamanieu opened this issue Oct 10, 2022 · 0 comments · Fixed by #4033
Labels
component: admin Related to the Admin Panel

Comments

@hyamanieu
Copy link
Collaborator

ALL software version info

Panel Server running on following versions:
Python 3.9.12 (main, Apr 4 2022, 05:22:27) [MSC v.1916 64 bit (AMD64)]
Panel: 0.14.0
Bokeh: 2.4.2
Param: 1.12.1

Description of expected behavior and the observed behavior

Version 0.14.0 claims than passing admin=True into the pn.serve function should work exactly like the command line panel serve --admin.

However after starting python main.py and accessing any dashboard served

  1. I have "0 active session" shown in the Admin Overview tab when accessing any dashboard (although I can see the session in the Admin Logs tab, see further)
  2. I get the following error upon accessing for the first time the "admin" page: WARNING:bokeh.core.validation.check:W-1002 (EMPTY_LAYOUT): Layout has no children: Row(id='17416', ...)
  3. I get an error in the terminal upon accessing for the first time the dashboard (see below)
  4. I get an error in the terminal upon clicking on one of the row within the Admin Logs (see also below)

Complete, minimal, self-contained example code that reproduces the issue

Here below is saved under a main.py

Due to #3970 , I had to add a self-made index.html which is not in this MVE.
You can copy the 0.13.1 index.html in the same folder as main.py and rename it index_mvp_panel014.html

import param
import panel as pn

import numpy as np
import holoviews as hv

pn.extension(sizing_mode="stretch_width")


class Meta_Dashboard(param.Parameterized):
    site = "MVP Panel 0.14 with admin"
    title = "abstract"


    def make_panel(self):
        """
        Abstract function. Must be defined in children classes
        """
        pass
    
    @classmethod
    def instantiate_new_dashboard(cls):
        dashboard_instance = cls()
        return dashboard_instance.make_panel()


class Random_Number_Generator(Meta_Dashboard):

    title="Random_Number_Generator"

    def make_panel(self):
        def generate_random_number(event=None):
            static_text.value = np.random.randint(low=100000, high=200000)

        def toggle_periodic_callback(event):
            if event.new is True:
                periodic_cb.start()
                periodic_toggle.name="STOP Periodic Generation"
            else:
                periodic_cb.stop()
                periodic_toggle.name="START Periodic Generation"
                
        def update_period(event):
            periodic_cb.period = event.new

        static_text = pn.widgets.StaticText(name='Periodic Random Number Generator',
                                            value='000000')

        generate_button = pn.widgets.Button(name='GENERATE New Number')
        generate_button.on_click(generate_random_number)

        periodic_toggle = pn.widgets.Toggle(name='START Periodic Generation',
                                            value=False, button_type='primary')
        periodic_toggle.param.watch(toggle_periodic_callback, 'value')

        period = pn.widgets.Spinner(name="Period (ms)", value=500, step=50, start=50)
        period.param.watch(update_period, 'value')

        periodic_cb = pn.state.add_periodic_callback(
            generate_random_number, period=period.value, start=False)

        col = pn.Column(generate_button, period, periodic_toggle, static_text)
        dashboard = pn.template.FastListTemplate(
            site=self.site, 
            title=self.title, 
            base_url='localhost',
            main=[
                "This example creates a **random number generator** that updates periodically or with the click of a button.\n\nThis demonstrates how to add a **periodic callback** and how to link a button and a toggle to a couple of callbacks.",
                col,
            ], main_max_width="768px",
        )
        return dashboard
    

class Distribution_Tabs(Meta_Dashboard):
    title = "Distribution_Tabs"
    def make_panel(self):
        distributions = {
            'NORMAL': np.random.normal,
            'UNIFORM': np.random.uniform,
            'LOG-NORMAL': np.random.lognormal,
            'EXPONENTIAL': np.random.exponential
        }

        checkboxes = pn.widgets.ToggleGroup(options=distributions, behavior='radio', button_type="success")
        slider = pn.widgets.IntSlider(name='Number of observations', value=500, start=0, end=2000)

        @pn.depends(checkboxes.param.value, slider.param.value)
        def tabs(distribution, n):
            values = hv.Dataset(distribution(size=n), 'values')
            return pn.Tabs(
                ('Plot', values.hist(adjoin=False).opts(
                    responsive=True, max_height=500, padding=0.1, color="#00aa41")),
                ('Summary', values.dframe().describe().T),
                ('Table', hv.Table(values)),
            )

        selections = pn.Column('### Distribution Type', checkboxes, slider)

        return pn.template.BootstrapTemplate(site=self.site, 
        title=self.title, 
        base_url='localhost',
        main=["This example demonstrates **how to plot several different types of outputs in a Tab**.", 
        selections, 
        tabs])


if __name__ == '__main__':
    from pathlib import Path
    index_html = str(Path('.').absolute()/'index_mvp_panel014.html')
    pn.serve({
        Random_Number_Generator.title: Random_Number_Generator.instantiate_new_dashboard,
        Distribution_Tabs.title: Distribution_Tabs.instantiate_new_dashboard,
    },    
    show=False,
    port=8082,
    autoreload=True,
    websocket_origin=['localhost:8082', 
                    ],
    admin=True,
    index=index_html,
    )

Stack traceback and/or browser JavaScript console output

Logs from the terminal upon starting a dashboard

ERROR:tornado.application:Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x00000274CB87CD60>>, <Task finished name='Task-2657' coro=<_needs_document_lock.<locals>._needs_document_lock_wrapper() done, defined at C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\server\session.py:77> exception=ValueError("'Session 2700658953424 launching' is not in list")>)
Traceback (most recent call last):
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\tornado\ioloop.py", line 741, in _run_callback
    ret = callback()
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\tornado\ioloop.py", line 765, in _discard_future_result       
    future.result()
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\server\session.py", line 93, in _needs_document_lock_wrapper
    result = func(self, *args, **kwargs)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\server\session.py", line 227, in with_document_locked   
    return func(*args, **kwargs)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\document\callbacks.py", line 450, in wrapper
    return invoke_with_curdoc(doc, invoke)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\document\callbacks.py", line 408, in invoke_with_curdoc 
    return f()
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\document\callbacks.py", line 449, in invoke
    return f(*args, **kwargs)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\document\callbacks.py", line 179, in remove_then_invoke 
    return callback()
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\panel\io\admin.py", line 219, in update_cds
    index = cds.data['msg'].index(LOG_SESSION_LAUNCHING % sid)
ValueError: 'Session 2700658953424 launching' is not in list
ERROR:tornado.application:Exception in callback functools.partial(<bound method IOLoop._discard_future_result of <tornado.platform.asyncio.AsyncIOMainLoop object at 0x00000274CB87CD60>>, <Task finished name='Task-2656' coro=<_needs_document_lock.<locals>._needs_document_lock_wrapper() done, defined at C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\server\session.py:77> exception=ValueError("'Session 2700658953424 launching' is not in list")>)
Traceback (most recent call last):
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\tornado\ioloop.py", line 741, in _run_callback
    ret = callback()
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\tornado\ioloop.py", line 765, in _discard_future_result       
    future.result()
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\server\session.py", line 93, in _needs_document_lock_wrapper
    result = func(self, *args, **kwargs)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\server\session.py", line 227, in with_document_locked   
    return func(*args, **kwargs)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\document\callbacks.py", line 450, in wrapper
    return invoke_with_curdoc(doc, invoke)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\document\callbacks.py", line 408, in invoke_with_curdoc 
    return f()
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\document\callbacks.py", line 449, in invoke
    return f(*args, **kwargs)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\document\callbacks.py", line 179, in remove_then_invoke 
    return callback()
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\panel\io\admin.py", line 219, in update_cds
    index = cds.data['msg'].index(LOG_SESSION_LAUNCHING % sid)
ValueError: 'Session 2700658953424 launching' is not in list

Admin Logs copied from the generated CSV:

datetime level app session message
10.10.2022 14:52 DEBUG panel.viewable.Location 2,70066E+12 finished processing events {'pathname': '/Distribution_Tabs', 'href': 'http://localhost:8082/Distribution_Tabs', 'hostname': 'localhost', 'protocol': 'http:', 'port': '8082'}
10.10.2022 14:52 DEBUG panel.viewable.Location 2,70066E+12 received events {'pathname': '/Distribution_Tabs', 'href': 'http://localhost:8082/Distribution_Tabs', 'hostname': 'localhost', 'protocol': 'http:', 'port': '8082'}
10.10.2022 14:52 INFO panel.io.server 2,70066E+12 created

Error in the terminal upon clicking on one of the rows within the Admin Logs tab (in this example the second row, Key 1):

ERROR:bokeh.server.protocol_handler:error handling message
 message: Message 'PATCH-DOC' content: {'events': [{'kind': 'MessageSent', 'msg_type': 'bokeh_event', 'msg_data': {'event_name': 'cell-click', 'event_values': {'column': 'message', 'row': 1}}}], 'references': []}
 error: KeyError(1)
Traceback (most recent call last):
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\server\protocol_handler.py", line 97, in handle
    work = await handler(message, connection)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\server\session.py", line 93, in _needs_document_lock_wrapper
    result = func(self, *args, **kwargs)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\server\session.py", line 287, in _handle_patch
    message.apply_to_document(self.document, self)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\protocol\messages\patch_doc.py", line 115, in apply_to_document
    invoke_with_curdoc(doc, lambda: doc.apply_json_patch(self.content, setter))
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\document\callbacks.py", line 408, in invoke_with_curdoc 
    return f()
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\protocol\messages\patch_doc.py", line 115, in <lambda>  
    invoke_with_curdoc(doc, lambda: doc.apply_json_patch(self.content, setter))
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\document\document.py", line 391, in apply_json_patch    
    DocumentPatchedEvent.handle_json(self, event_json, references, setter)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\document\events.py", line 259, in handle_json
    handler(doc, event_json, references, setter)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\document\events.py", line 300, in _handle_json
    cb(event_json["msg_data"])
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\document\callbacks.py", line 355, in trigger_json_event 
    model._trigger_event(event)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\util\callback_manager.py", line 119, in _trigger_event  
    self.document.callbacks.notify_event(cast(Model, self), event, invoke)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\document\callbacks.py", line 247, in notify_event       
    invoke_with_curdoc(doc, callback_invoker)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\document\callbacks.py", line 408, in invoke_with_curdoc 
    return f()
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\bokeh\util\callback_manager.py", line 115, in invoke
    cast(EventCallbackWithEvent, callback)(event)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\panel\reactive.py", line 428, in _server_event
    self._comm_event(doc, event)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\panel\reactive.py", line 415, in _comm_event
    state._handle_exception(e)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\panel\io\state.py", line 391, in _handle_exception
    raise exception
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\panel\reactive.py", line 413, in _comm_event
    self._process_bokeh_event(doc, event)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\panel\reactive.py", line 350, in _process_bokeh_event
    self._process_event(event)
  File "C:\Users\hy.amanieu\Anaconda3\envs\youpi\lib\site-packages\panel\widgets\tables.py", line 1158, in _process_event        
    idx = self._index_mapping[event.row]
KeyError: 1

Screenshots or screencasts of the bug in action

image

@hyamanieu hyamanieu added TRIAGE Default label for untriaged issues type: bug component: admin Related to the Admin Panel and removed TRIAGE Default label for untriaged issues labels Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: admin Related to the Admin Panel
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant