holoviz / panel

Panel: The powerful data exploration & web app framework for Python

Home Page:https://panel.holoviz.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to panel serve from a notebook

singharpit94 opened this issue · comments

Hi,

I am using panel 1.4.1 and bokeh 3.4.0 and found the following notebook does not render correctly

Cell 1:

import panel as pn
import pandas as pd
from tempfile     import TemporaryDirectory

Cell 2:

df = pd.DataFrame({
   'A': ['foo', 'bar', 'baz'],
   'B': ['one', 'one', 'two'],
   'C': ['small', 'large', 'medium'],
   'D': [1, 2, 3],
   'E': [2, 3, 4]
})
pn.extension()

def gen_excel_output():
    with TemporaryDirectory() as d:

        outfile =  f"{d}/test.xlsx"
        df.to_excel(outfile, index=False, sheet_name='Sheet1')

        # Testing comment
        dl_button = pn.widgets.FileDownload(label = 'Download Output as .xlsx', file=outfile, embed=True, width = 300)
            
    return dl_button

Cell 3:

pn.Column(gen_excel_output()).servable()

The same code works when used in a python script, lately I am getting into lot of notebook parsing issues, can we try to make it more robust

I can reproduce the issue using panel==1.4.1.

pip install panel pandas openpyxl

issue.ipynb.csv

If I serve from a python script it works

import panel as pn
import pandas as pd
from tempfile import TemporaryDirectory


df = pd.DataFrame({
   'A': ['foo', 'bar', 'baz'],
   'B': ['one', 'one', 'two'],
   'C': ['small', 'large', 'medium'],
   'D': [1, 2, 3],
   'E': [2, 3, 4]
})
pn.extension()

def gen_excel_output():
    with TemporaryDirectory() as d:

        outfile =  f"{d}/test.xlsx"
        df.to_excel(outfile, index=False, sheet_name='Sheet1')

        # Testing comment
        dl_button = pn.widgets.FileDownload(label = 'Download Output as .xlsx', file=outfile, embed=True, width = 300)
            
    return dl_button


pn.Column(gen_excel_output()).servable()

image

Both files are located in the same folder as I panel serve it from.

This was fixed in #6736. I'll prioritize a release by tomorrow or Friday.