Skip to main content

resolve_pipe

resolve_pipe(
    pipeline_func,
) ‑> Callable
Decorator that resolves Pipe instances in function arguments. This function wraps a given function and ensures that any Pipe instances in its keyword arguments are instantiated before the function is executed. If a Pipe instance is found, it is replaced with the result of its resolve method. Parameters:
NameTypeDefaultDescription
pipeline_funcCallable--The function to be wrapped. Any Pipe instances in its keyword arguments will be resolved before execution.
Returns:
TypeDescription
tp.CallableA wrapped function where Pipe instances in keyword arguments are replaced with their instantiated values.
Examples: Here, transform is an instance of Pipe, and before run_pipeline is executed, it is replaced with MyTransformer(arg1, arg2).
class BaseStrategy:
    @classmethod
    @vbt.parameterized
    @run_pipe
    def run_pipeline(data: vbt.Data, model: tp.Type):
        ...

class MyModel(BaseStrategy)
    ...

model = Pipe(MyModel, dict(arg1="...", arg2=vbt.Param([...]))
result = BaseStrategy.run_pipeline(data, model=model)

Pipe

Pipe(
    model: Type,
    kwargs: Dict[str, Any] = None,
)
Wrapper that allows introspection for complex objects. This class provides a way to wrap models and their parameters in a structure that allows easy traversal of nested tuples and dictionaries. It is particularly useful for frameworks that do not support direct introspection of complex objects. Parameters:
NameTypeDefaultDescription
modelType--The model or function to be instantiated with the provided arguments.
kwargstp.KwargsNoneThe keyword arguments to be passed when instantiating model.
Examples: Pipe can be used in model configurations to facilitate introspection and parameter naming. For example:
transform = Pipe(MyTransformer, dict(arg1="...", arg2=vbt.Param([...]))
Using this approach ensures that parameter names are structured appropriately, e.g., transform.arg1 and transform.arg2.

Ancestors

  • builtins.tuple

Instance variables

  • model: Type: The model or function to be instantiated with the provided arguments.
  • kwargs: Dict[str, Any]: The keyword arguments to be passed when instantiating model.

Methods

resolve

resolve(
    self,
) ‑> Type
Instantiate the model with the provided keyword arguments. Returns:
TypeDescription
TypeAn instance of model initialized with kwargs.