Skip to content

Multi asset

Multi Asset Module

Defines the MultiAsset class for handling multiple BaseAsset instances.

MultiAsset #

MultiAsset(assets: Sequence[BaseAsset])

Bases: BaseAsset

MultiAsset Class

Represents a collection of multiple BaseAsset instances.

Parameters:

Name Type Description Default
assets List[BaseAsset]

A list of BaseAsset instances to be managed together.

required

Parameters:

Name Type Description Default
assets List[BaseAsset]

A list of BaseAsset instances to be managed together.

required
Source code in src/rapidata/rapidata_client/assets/multi_asset.py
def __init__(self, assets: Sequence[BaseAsset]) -> None:
    """
    Initialize a MultiAsset instance.

    Args:
        assets (List[BaseAsset]): A list of BaseAsset instances to be managed together.
    """
    if len(assets) != 2:
        raise ValueError("Assets must come in pairs for comparison tasks.")

    for asset in assets:
        if not isinstance(asset, (TextAsset, MediaAsset)):
            raise TypeError("All assets must be a TextAsset or MediaAsset.")    

    if not all(isinstance(asset, type(assets[0])) for asset in assets):
        raise ValueError("All assets must be of the same type.")

    self.assets = assets