types - Infernet ML
Description: Infernet ML Documentation

Skip to content

# Module: `types`

## `StorageId`

Bases: `StrEnum`

Enum for the different types of storage capabilities within ritual's

services. Models/Artifacts can be stored in different storage backends.

Attributes:

Name | Type | Description
--- | --- | ---
`Local` | `str` | Local storage
`Huggingface` | `str` | Huggingface model hub
`Arweave` | `str` | Arewave storage

Source code in `src/infernet_ml/resource/types.py`

     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    class StorageId(StrEnum):
        """
        StorageId: Enum for the different types of storage capabilities within ritual's
            services. Models/Artifacts can be stored in different storage backends.

        Attributes:
            Local: Local storage
            Huggingface: Huggingface model hub
            Arweave: Arewave storage
        """

        Local: str = "local"
        Arweave: str = "arweave"
        Huggingface: str = "huggingface"

        def to_storage_id_int(self) -> StorageIdInt:
            """
            Convert the StorageId to StorageIdInt

            Returns:
                StorageIdInt: The StorageIdInt equivalent of the StorageId
            """
            match self:
                case StorageId.Local:
                    return StorageIdInt.Local
                case StorageId.Arweave:
                    return StorageIdInt.Arweave
                case StorageId.Huggingface:
                    return StorageIdInt.Huggingface

### `to_storage_id_int()`

Convert the StorageId to StorageIdInt

Returns:

Name | Type | Description
--- | --- | ---
`StorageIdInt` | `StorageIdInt` | The StorageIdInt equivalent of the StorageId

Source code in `src/infernet_ml/resource/types.py`

    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    def to_storage_id_int(self) -> StorageIdInt:
        """
        Convert the StorageId to StorageIdInt

        Returns:
            StorageIdInt: The StorageIdInt equivalent of the StorageId
        """
        match self:
            case StorageId.Local:
                return StorageIdInt.Local
            case StorageId.Arweave:
                return StorageIdInt.Arweave
            case StorageId.Huggingface:
                return StorageIdInt.Huggingface

## `StorageIdInt`

Bases: `IntEnum`

Enum for the different types of storage capabilities within infernet.

The int version of this model is simply used for serialization purposes on web3.py. It's more gas-optimized to send an int over the wire.

Attributes:

Name | Type | Description
--- | --- | ---
`Local` | `int` | Local storage
`Huggingface` | `int` | Huggingface model hub
`Arweave` | `int` | Arewave storage

Source code in `src/infernet_ml/resource/types.py`

    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    class StorageIdInt(IntEnum):
        """
        StorageIdInt: Enum for the different types of storage capabilities within infernet.
            The int version of this model is simply used for serialization purposes on
            web3.py. It's more gas-optimized to send an int over the wire.

        Attributes:
            Local: Local storage
            Huggingface: Huggingface model hub
            Arweave: Arewave storage
        """

        Local: int = 0
        Arweave: int = 1
        Huggingface: int = 2

        def to_storage_id(self) -> StorageId:
            """
            Convert the StorageIdInt to StorageId, this is the inverse of the
            to_storage_id_int method, and is used in deserialization of on-chain
            data.

            Returns:
                StorageId: The StorageId equivalent of the StorageIdInt
            """
            match self:
                case StorageIdInt.Local:
                    return StorageId.Local
                case StorageIdInt.Arweave:
                    return StorageId.Arweave
                case StorageIdInt.Huggingface:
                    return StorageId.Huggingface

### `to_storage_id()`

Convert the StorageIdInt to StorageId, this is the inverse of the to_storage_id_int method, and is used in deserialization of on-chain data.

Returns:

Name | Type | Description
--- | --- | ---
`StorageId` | `StorageId` | The StorageId equivalent of the StorageIdInt

Source code in `src/infernet_ml/resource/types.py`

    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    def to_storage_id(self) -> StorageId:
        """
        Convert the StorageIdInt to StorageId, this is the inverse of the
        to_storage_id_int method, and is used in deserialization of on-chain
        data.

        Returns:
            StorageId: The StorageId equivalent of the StorageIdInt
        """
        match self:
            case StorageIdInt.Local:
                return StorageId.Local
            case StorageIdInt.Arweave:
                return StorageId.Arweave
            case StorageIdInt.Huggingface:
                return StorageId.Huggingface