Loading Indicator does not stop for partial parameters

Hello, im trying around with the new loading_indicator option, which is really useful, but somehow shows the loading indicator even when a parameter changes which is not bound to the actual method the loading indicator is applied on.

With the minimal example here:

class MinimalLoadingExample(param.Parameterized):
    some_param = param.Integer()
    some_other_param = param.Integer()
    
    
    def panel(self):
        return pn.Row(
            self.param,
            pn.panel(self.view, loading_indicator=True)
        )
    
    @pn.depends("some_param")
    def view(self):
        return pn.Row(self.some_param, self.some_other_param)
    
minimal_loading_example = MinimalLoadingExample()
minimal_loading_example.panel().servable()

when some_param is changed, the view is correctly updated and a loading indicator is shown and then removed.
If i change some_other_param, the loading indicator is also shown but is then never removed.

The Docs for ParamMethod here https://panel.holoviz.org/_modules/panel/param.html say:

    By default ParamMethod will watch all parameters on the class owning
    the method or can be restricted to certain parameters by annotating
    the method using the param.depends decorator.

So i would have thought that the loading indicator is only shown when some_param changes?
I guess it the loading indicator shouldnt have started in the first place, and that it does not stop because the actual parameter it depends on does not finish or so?

1 Like

Hi @Stubatiger

Welcome to the community :+1:

I actually don’t understand the behaviour of what you see. Maybe the example should be filed as a bug on Github?

But the below will work

import time

import panel as pn
import param


class MinimalLoadingExample(param.Parameterized):
    some_param = param.Integer()
    some_other_param = param.Integer()

    _number_row = param.Parameter(precedence=-1)

    def panel(self):
        self._create_number_row()

        return pn.Row(
            self.param,
            self._number_row,
        )

    def _create_number_row(self):
        if not self._number_row:
            self._number_row = pn.Row()
            self._update_number_row()

    @pn.depends("some_param", watch=True)
    def _update_number_row(self):
        self._number_row.loading=True
        time.sleep(1)
        self._number_row[:]=[self.some_param, self.some_other_param]
        self._number_row.loading=False

minimal_loading_example = MinimalLoadingExample()
minimal_loading_example.panel().servable()

Hey @Marc , thanks for the quick help and the warm welcome.

I filed a bug report for it here https://github.com/holoviz/panel/issues/2158

And just to clarify the behaviour of what i see, i created a video
(and uploaded it to youtube, cause i cant upload attachments here as a new user :frowning_face:) :

https://www.youtube.com/watch?v=H2Nb9GLr7Jc

1 Like