Skip to content

Commit 456acd4

Browse files
author
Roman
committed
let users use int indexes, not only enum
1 parent c691fa0 commit 456acd4

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

bittensor/core/async_subtensor.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,9 +1480,9 @@ async def get_metagraph_info(
14801480
Retrieves full or partial metagraph information for the specified subnet (netuid).
14811481
14821482
Arguments:
1483-
netuid (int): The NetUID of the subnet to query.
1484-
field_indices (Optional[list[SelectiveMetagraphIndex]]): An optional list of SelectiveMetagraphIndex values
1485-
specifying which fields to retrieve. If not provided, all available fields will be returned.
1483+
netuid: The NetUID of the subnet to query.
1484+
field_indices: An optional list of SelectiveMetagraphIndex values specifying which fields to retrieve. If
1485+
not provided, all available fields will be returned.
14861486
block: the block number at which to retrieve the hyperparameter. Do not specify if using block_hash or
14871487
reuse_block
14881488
block_hash: The hash of blockchain block number for the query. Do not specify if using
@@ -1505,9 +1505,12 @@ async def get_metagraph_info(
15051505

15061506
if field_indices:
15071507
if isinstance(field_indices, list) and all(
1508-
isinstance(f, SelectiveMetagraphIndex) for f in field_indices
1508+
isinstance(f, (SelectiveMetagraphIndex, int)) for f in field_indices
15091509
):
1510-
indexes = [f.value for f in field_indices]
1510+
indexes = [
1511+
f.value if isinstance(f, SelectiveMetagraphIndex) else f
1512+
for f in field_indices
1513+
]
15111514
else:
15121515
raise ValueError(
15131516
"`field_indices` must be a list of SelectiveMetagraphIndex items."

bittensor/core/subtensor.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,18 +1133,18 @@ def get_minimum_required_stake(self) -> Balance:
11331133
def get_metagraph_info(
11341134
self,
11351135
netuid: int,
1136-
field_indices: Optional[list["SelectiveMetagraphIndex"]] = None,
1136+
field_indices: Optional[list[Union["SelectiveMetagraphIndex", int]]] = None,
11371137
block: Optional[int] = None,
11381138
) -> Optional[MetagraphInfo]:
11391139
"""
11401140
Retrieves full or partial metagraph information for the specified subnet (netuid).
11411141
11421142
Arguments:
1143-
netuid (int): The NetUID of the subnet to query.
1144-
field_indices (Optional[list[SelectiveMetagraphIndex]]): An optional list of SelectiveMetagraphIndex values
1145-
specifying which fields to retrieve. If not provided, all available fields will be returned.
1146-
block (Optional[int]):The block number at which to query the data. If not specified, the current block or
1147-
one determined via reuse_block or block_hash will be used.
1143+
netuid: The NetUID of the subnet to query.
1144+
field_indices: An optional list of SelectiveMetagraphIndex values specifying which fields to retrieve. If
1145+
not provided, all available fields will be returned.
1146+
block: The block number at which to query the data. If not specified, the current block or one determined
1147+
via reuse_block or block_hash will be used.
11481148
11491149
Returns:
11501150
Optional[MetagraphInfo]: A MetagraphInfo object containing the requested subnet data, or None if the subnet
@@ -1162,9 +1162,12 @@ def get_metagraph_info(
11621162

11631163
if field_indices:
11641164
if isinstance(field_indices, list) and all(
1165-
isinstance(f, SelectiveMetagraphIndex) for f in field_indices
1165+
isinstance(f, (SelectiveMetagraphIndex, int)) for f in field_indices
11661166
):
1167-
indexes = [f.value for f in field_indices]
1167+
indexes = [
1168+
f.value if isinstance(f, SelectiveMetagraphIndex) else f
1169+
for f in field_indices
1170+
]
11681171
else:
11691172
raise ValueError(
11701173
"`field_indices` must be a list of SelectiveMetagraphIndex items."

0 commit comments

Comments
 (0)