binone
binone

Reputation: 1

How does the holoviz @param.depends invoke a callback function

I have the following simple test code:

import param
import panel as pn
import logging

# Configure logging to display DEBUG level messages and higher
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')

class D(param.Parameterized):
    t = param.Number(default=0)
    i = param.Integer(default=10, bounds=(5, 15))
    s = param.String(default='a string', doc='The simulation name')
    option = param.Selector(objects=['a', 'b', 'c'])

    @param.depends('t', 'i')
    def compute(self):
        # Use logging to debug instead of print
        logging.debug("came here")
        return self.t * self.i

d = D()

# Setup Panel UI to interact with the parameters
layout = pn.Column(d.param, d.compute)
layout.servable()

The code displays a panel and the call back function is invoked as expected - i.e. the values change dynamically.

I am trying to figure out why the log event is not triggered each time the panel slider/input is changed. Clearly the call back function is getting invoked as I cn see the result d.compute update as expected. Basically, I see only one log event and then nothing. Maybe the wrapper function is 'eating' the log message and routing to some null file?

Just trying to understand what is going on here. Appreciate any help.

Thanks,

Upvotes: 0

Views: 57

Answers (0)

Related Questions