Module: router
Module containing the RouterClient class, which is a client for the Infernet Router's REST API.
Example Usage
You can use the Router client as follows:
from infernet_client import RouterClient
client = RouterClient()
# Get a list of all containers running in the network
containers = await client.get_containers()
# Get a list of nodes that support the given container IDs
nodes = await client.get_nodes_by_container_ids(
[containers[0]["id"], containers[1]["id"]]
)
RouterClient
Source code in src/infernet_client/router.py
__init__(base_url='infernet-router.ritual.net')
Initializes the client
Parameters:
Name | Type | Description | Default |
---|---|---|---|
base_url |
str
|
The base URL of the REST server |
'infernet-router.ritual.net'
|
check_model_support(model_id)
async
Check model support on the containers of each node
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_id |
str
|
The model ID to check support for |
required |
Returns:
Type | Description |
---|---|
dict[str, dict[str, ModelSupport]]
|
dict[str, int]: A mapping of hostname / IP address to a model support status for each container on the node |
Raises:
Type | Description |
---|---|
ClientResponseError
|
If the request returns an error code |
TimeoutError
|
If the request times out |
Source code in src/infernet_client/router.py
get_containers()
async
Get a list of all containers running in the network
Returns:
Type | Description |
---|---|
list[NetworkContainer]
|
list[NetworkContainer]: A list of containers, with counts and descriptions |
Source code in src/infernet_client/router.py
get_nodes_by_container_ids(container_ids, n=3, offset=0)
async
Get a list of node IPs that support the given container IDs
Parameters:
Name | Type | Description | Default |
---|---|---|---|
container_ids |
list[str]
|
The container IDs to get the nodes for |
required |
n |
int
|
The number of nodes to return |
3
|
offset |
int
|
The offset to start at, for pagination |
0
|
Returns:
Type | Description |
---|---|
list[str]
|
list[dict[str, Any]]: A list of node IPs |
Source code in src/infernet_client/router.py
get_resources()
async
Collect resources available on the network
Returns:
Type | Description |
---|---|
dict[str, dict[str, ServiceResources]]
|
dict[str, int]: A mapping of hostname / IP address to a node's resources, including hardware resources and supported models. |
Raises:
Type | Description |
---|---|
ClientResponseError
|
If the request returns an error code |
TimeoutError
|
If the request times out |