Interactive does not work as expected

Hello,
im trying to build a data pipeline with .interactive and a function as a pipeline start as described in Interactive — hvPlot 0.8.0 documentation

I was assuming that an interactive pipeline is only run once at the end and that it updates only
at the steps where the parameters are changing.
But apparently it runs the pipeline for each added step multiple times?
Can anyone explain my the following output of the code?

import panel as pn
import pandas as pd
import hvplot

dataconfig = pn.widgets.Select(options=["Conf1", "Conf2"])


def load_data(dataconfig):
    print("Load Data")
    return pd.DataFrame([{"config": dataconfig}])


def transform_data(df, transform):
    print(f"Transforming {transform}")
    return df


print("-------------")

bound_loader = hvplot.bind(load_data, dataconfig)

print("-------------")

interactive_loader = bound_loader.interactive()

print("-------------")

transformed_loader = interactive_loader.pipe(transform_data, transform="Step 1")

print("-------------")

transformed_loader = transformed_loader.pipe(transform_data, transform="Step 2")

print("-------------")

transformed_loader = transformed_loader.pipe(transform_data, transform="Step 3")

The output of this is

-------------
-------------
Load Data
Load Data
-------------
Transforming Step 1
-------------
Transforming Step 1
Transforming Step 1
Transforming Step 1
Transforming Step 2
-------------
Transforming Step 1
Transforming Step 2
Transforming Step 1
Transforming Step 2
Transforming Step 1
Transforming Step 2
Transforming Step 3

And i dont unterstand why the functions get called so many times?

Hi @Stubatiger,

Thanks for reporting that. In your example you can see that load_data is called twice, this is a bug we have recently fixed and that should be released shortly. However the other issue you reported - i.e. the many calls to the piped function - is a bug we were not aware of, I’ve just opened an issue to track it: Interactive: using `.pipe`/`.apply` in a pipeline triggers the piped/applied function too many times · Issue #832 · holoviz/hvplot · GitHub

Thanks for raising that!

1 Like

Hey thanks for the quick feedbag,

can you link me the pr for the fix of the load_data function?

And if you have ideas where to start looking for the other bug, i could make some digging :slight_smile: