> ## Documentation Index
> Fetch the complete documentation index at: https://systematica.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Utils

> systematica.portfolio.utils

## `resolve_pipe`

```python theme={null}
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**:

| Name            | Type       | Default | Description                                                                                                  |
| --------------- | ---------- | ------- | ------------------------------------------------------------------------------------------------------------ |
| `pipeline_func` | `Callable` | `--`    | The function to be wrapped. Any `Pipe` instances in its keyword arguments will be resolved before execution. |

**Returns**:

| Type          | Description                                                                                                 |
| ------------- | ----------------------------------------------------------------------------------------------------------- |
| `tp.Callable` | A 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)`.

```python theme={null}
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`

```python theme={null}
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**:

| Name     | Type        | Default | Description                                                           |
| -------- | ----------- | ------- | --------------------------------------------------------------------- |
| `model`  | `Type`      | `--`    | The model or function to be instantiated with the provided arguments. |
| `kwargs` | `tp.Kwargs` | `None`  | The keyword arguments to be passed when instantiating `model`.        |

**Examples**:

`Pipe` can be used in model configurations to facilitate introspection and
parameter naming. For example:

```python theme={null}
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`

```python theme={null}
resolve(
    self,
) ‑> Type
```

Instantiate the model with the provided keyword arguments.

**Returns**:

| Type   | Description                                       |
| ------ | ------------------------------------------------- |
| `Type` | An instance of `model` initialized with `kwargs`. |
