panel icon indicating copy to clipboard operation
panel copied to clipboard

In Colab, code to display some Panel widget components needs to be run 3 times before displaying. First run produces a warning, second no output.

Open Coderambling opened this issue 1 year ago • 0 comments

ALL software version info

Colab and panel

Description of expected behavior and the observed behavior

Expected behavior: When the code below is run once in a code cell, the Panel component displays in the notebook.

Observed behavior: When code is run for first time, the below WARNING output is returned. When cell is run a second time without changing any code in the cell, and without restarting, no output (and no error or warning) is returned. On the 3d run, the component appears correctly. Changing pn.extension() to pn.extension('tabulator') is NOT necessary. The same issue and warning for Perspective occurs when using pn.widgets.Perspective . I have not tested other Panel widget components so far.

Below is the exact content of the output of the first run of the cell. So the WARNING messasge is printed twice in the output when the cell is run for the first time.

WARNING:param.main: DataTabulator was not imported on instantiation and may not render in a notebook. Restart the notebook kernel and ensure you load it as part of the extension using:

pn.extension('tabulator')

WARNING:param.main:DataTabulator was not imported on instantiation and may not render in a notebook. Restart the notebook kernel and ensure you load it as part of the extension using:

pn.extension('tabulator')

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

import panel as pn
pn.extension()
data = pd.DataFrame({
    "int": np.arange(100),
    "float": [i * 1.5 for i in range(100)],
    "bool": [True for i in range(100)],
    "date": [date.today() for i in range(100)],
    "datetime": [datetime.now() for i in range(100)],
    "string": [str(i) for i in range(100)]
})
df = data
pn.widgets.Tabulator(df, theme='site', pagination='remote', page_size=5)

Coderambling avatar Feb 10 '24 18:02 Coderambling