panel icon indicating copy to clipboard operation
panel copied to clipboard

Autoreload not working when you forget to include extension

Open MarcSkovMadsen opened this issue 1 year ago • 2 comments

I'm on panel==1.5.2. I've experienced that autoreload is not working if you forget to include an extension

Reproducible Example

import panel as pn

pn.extension()

pn.widgets.CodeEditor(
    value="import panel as pn\npn.extension()", language="python"
).servable()

Serve the app

panel serve script.py --dev --index script

Open the app in your browser and verify you see the below in the terminal

pn.extension was initialized but 'codeeditor' extension was not loaded. In order for the required resources to be initialized ensure the extension is loaded with the following argument(s):

pn.extension('codeeditor')

Reload the app and verify you have a blank window.

Change pn.extension() to pn.extension('codeeditor') and verify the app does not reload.

https://github.com/user-attachments/assets/0ab16c95-a076-4cba-b2ce-ef2532747c5e

I often see this triggered when I support multiple people with their code. Then I serve a script.py file with autoreload and as I move to a new problem and work on an example I often experience this. Then I have to kill the server, start it again and reload the browser. This is mental overhead.

MarcSkovMadsen avatar Oct 14 '24 06:10 MarcSkovMadsen

Both this and https://github.com/holoviz/panel/issues/7396 are regressions introduced in https://github.com/holoviz/panel/pull/6913

philippjfr avatar Oct 14 '24 12:10 philippjfr

So I can't reproduce this as described, specifically in my testing there's not actually any need to restart the server. The problem is simply that after the app is rendered initially without the extension it won't automatically reload when the extension is added, manually reloading the page fixes it.

The bad part is that I don't see an easy to fix this. The problem is that because the app errors on initial load the Location component isn't rendered correctly, which in turn means the auto-refresh of the page doesn't work. The only way I see to fix this is to ensure that all models that use an external resource should error gracefully, i.e. by issuing a warning instead of an error if the library can't be loaded.

philippjfr avatar Oct 15 '24 13:10 philippjfr