|
23 | 23 | NeuronInfo, |
24 | 24 | ProposalVoteData, |
25 | 25 | StakeInfo, |
26 | | - SelectiveMetagraphIndex, |
27 | 26 | SubnetHyperparameters, |
28 | 27 | SubnetIdentity, |
29 | 28 | SubnetInfo, |
@@ -1543,83 +1542,38 @@ async def get_minimum_required_stake(self): |
1543 | 1542 | async def get_metagraph_info( |
1544 | 1543 | self, |
1545 | 1544 | netuid: int, |
1546 | | - field_indices: Optional[list["SelectiveMetagraphIndex"]] = None, |
1547 | 1545 | block: Optional[int] = None, |
1548 | 1546 | block_hash: Optional[str] = None, |
1549 | 1547 | reuse_block: bool = False, |
1550 | 1548 | ) -> Optional[MetagraphInfo]: |
1551 | 1549 | """ |
1552 | | - Retrieves full or partial metagraph information for the specified subnet (netuid). |
| 1550 | + Retrieves the MetagraphInfo dataclass from the node for a single subnet (netuid) |
1553 | 1551 |
|
1554 | 1552 | Arguments: |
1555 | | - netuid: The NetUID of the subnet to query. |
1556 | | - field_indices: An optional list of SelectiveMetagraphIndex values specifying which fields to retrieve. If |
1557 | | - not provided, all available fields will be returned. |
| 1553 | + netuid: The NetUID of the subnet. |
1558 | 1554 | block: the block number at which to retrieve the hyperparameter. Do not specify if using block_hash or |
1559 | 1555 | reuse_block |
1560 | 1556 | block_hash: The hash of blockchain block number for the query. Do not specify if using |
1561 | 1557 | block or reuse_block |
1562 | 1558 | reuse_block: Whether to reuse the last-used block hash. Do not set if using block_hash or block. |
1563 | 1559 |
|
1564 | 1560 | Returns: |
1565 | | - Optional[MetagraphInfo]: A MetagraphInfo object containing the requested subnet data, or None if the subnet |
1566 | | - with the given netuid does not exist. |
1567 | | -
|
1568 | | - Example: |
1569 | | - meta_info = await subtensor.get_metagraph_info(netuid=2) |
1570 | | -
|
1571 | | - partial_meta_info = await subtensor.get_metagraph_info( |
1572 | | - netuid=2, |
1573 | | - field_indices=[SelectiveMetagraphIndex.Name, SelectiveMetagraphIndex.OwnerHotkeys] |
1574 | | - ) |
| 1561 | + MetagraphInfo dataclass |
1575 | 1562 | """ |
1576 | 1563 | block_hash = await self.determine_block_hash(block, block_hash, reuse_block) |
1577 | 1564 | if not block_hash and reuse_block: |
1578 | 1565 | block_hash = self.substrate.last_block_hash |
1579 | 1566 |
|
1580 | | - if field_indices is None: |
1581 | | - query = await self.substrate.runtime_call( |
1582 | | - "SubnetInfoRuntimeApi", |
1583 | | - "get_metagraph", |
1584 | | - params=[netuid], |
1585 | | - block_hash=block_hash, |
1586 | | - ) |
1587 | | - if query.value is None: |
1588 | | - logging.error(f"Subnet {netuid} does not exist.") |
1589 | | - return None |
1590 | | - return MetagraphInfo.from_dict(query.value) |
1591 | | - |
1592 | | - indexes = SelectiveMetagraphIndex.all_indices() |
1593 | | - |
1594 | | - if field_indices: |
1595 | | - if isinstance(field_indices, list) and all( |
1596 | | - isinstance(f, (SelectiveMetagraphIndex, int)) for f in field_indices |
1597 | | - ): |
1598 | | - indexes = [ |
1599 | | - f.value if isinstance(f, SelectiveMetagraphIndex) else f |
1600 | | - for f in field_indices |
1601 | | - ] |
1602 | | - else: |
1603 | | - raise ValueError( |
1604 | | - "`field_indices` must be a list of SelectiveMetagraphIndex items." |
1605 | | - ) |
1606 | | - |
1607 | 1567 | query = await self.substrate.runtime_call( |
1608 | 1568 | "SubnetInfoRuntimeApi", |
1609 | | - "get_selective_metagraph", |
1610 | | - params=[netuid, indexes if 0 in indexes else [0] + indexes], |
| 1569 | + "get_metagraph", |
| 1570 | + params=[netuid], |
1611 | 1571 | block_hash=block_hash, |
1612 | 1572 | ) |
1613 | 1573 | if query.value is None: |
1614 | 1574 | logging.error(f"Subnet {netuid} does not exist.") |
1615 | 1575 | return None |
1616 | | - meta: MetagraphInfo = MetagraphInfo.from_dict(query.value) |
1617 | | - # TODO: remove this after SelectiveMetagraph is updated in mainnet. |
1618 | | - if meta.netuid == 0 and meta.name != "root": |
1619 | | - logging.warning( |
1620 | | - "Do not use the 'field_indices' argument while you see this message. Mainnet update pending." |
1621 | | - ) |
1622 | | - return meta |
| 1576 | + return MetagraphInfo.from_dict(query.value) |
1623 | 1577 |
|
1624 | 1578 | async def get_all_metagraphs_info( |
1625 | 1579 | self, |
|
0 commit comments