Module: types
This file contains pydantic-style data types for Infernet's services.
InfernetInput
Bases: BaseModel
Infernet containers must accept InfernetInput. Depending on the source (onchain vs. offchain), the associated data object is either a hex string from an onchain source meant to be decoded directly, or a data dictionary (off chain source).
Attributes:
Name | Type | Description |
---|---|---|
source |
JobLocation
|
JobLocation source of the input. |
destination |
JobLocation
|
JobLocation destination of the input |
data |
Union[HexStr, dict[str, Any]]
|
Union[HexStr, dict[str, Any]]: The data associated with the input. For on-chain sources, this is a hex string. For off-chain sources, this can be any dictionary. |
requires_proof |
Optional[bool]
|
Optional[bool]: Whether the input requires a proof. Defaults to False. |
Source code in src/infernet_ml/services/types.py
offchain_data: dict[str, Any]
property
Return the offchain data if the source is offchain. This is a dictionary.
Raises:
Type | Description |
---|---|
AssertionError
|
If the source is not offchain. |
onchain_data: HexStr
property
Return the onchain data if the source is onchain. This is a hex string.
Raises:
Type | Description |
---|---|
AssertionError
|
If the source is not onchain. |
check_data_correct()
This function checks that the data type is correct for the source.
Raises:
Type | Description |
---|---|
ValueError
|
If the data type is incorrect for the source. |
Source code in src/infernet_ml/services/types.py
JobLocation
Bases: IntEnum
Enum for the location of the job data. This is used to specify both the source of an infernet job input and the destination of an infernet job output.
Attributes:
Name | Type | Description |
---|---|---|
ONCHAIN |
The data is onchain. |
|
OFFCHAIN |
The data is offchain. |
|
STREAM |
The data is a stream. |