Skip to content

Commit b29dc57

Browse files
author
opendansor
committed
# Add documentation for retrieve_children and render_table methods
Added detailed docstrings to the retrieve_children and render_table methods in stake.py to specify their purpose, parameters, and return values. This enhances code readability and assists other developers in understanding the methods' functionalities better.
1 parent 54214e1 commit b29dc57

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

bittensor/commands/stake.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,20 @@ def _run(cli: "bittensor.cli", subtensor: "bittensor.subtensor"):
794794
def retrieve_children(
795795
subtensor: "bittensor.subtensor", hotkey: str, netuid: int, render_table: bool
796796
):
797+
"""
798+
799+
Static method to retrieve children for a given subtensor.
800+
801+
Args:
802+
subtensor (bittensor.subtensor): The subtensor object used to interact with the Bittensor network.
803+
hotkey (str): The hotkey of the tensor owner.
804+
netuid (int): The network unique identifier of the subtensor.
805+
render_table (bool): Flag indicating whether to render the retrieved children in a table.
806+
807+
Returns:
808+
List[str]: A list of children hotkeys.
809+
810+
"""
797811
children = subtensor.get_children(hotkey, netuid)
798812
if render_table:
799813
GetChildrenCommand.render_table(subtensor, hotkey, children, netuid, False)
@@ -827,6 +841,31 @@ def render_table(
827841
netuid: int,
828842
prompt: bool,
829843
):
844+
"""
845+
846+
Render a table displaying information about child hotkeys on a particular subnet.
847+
848+
Parameters:
849+
- subtensor: An instance of the "bittensor.subtensor" class.
850+
- hotkey: The hotkey of the parent node.
851+
- children: A list of tuples containing information about child hotkeys. Each tuple should contain:
852+
- The proportion of the child's stake relative to the total stake.
853+
- The hotkey of the child node.
854+
- netuid: The ID of the subnet.
855+
- prompt: A boolean indicating whether to display a prompt for adding a child hotkey.
856+
857+
Returns:
858+
None
859+
860+
Example Usage:
861+
subtensor = bittensor.subtensor_instance
862+
hotkey = "parent_hotkey"
863+
children = [(0.5, "child1_hotkey"), (0.3, "child2_hotkey"), (0.2, "child3_hotkey")]
864+
netuid = 1234
865+
prompt = True
866+
render_table(subtensor, hotkey, children, netuid, prompt)
867+
868+
"""
830869
console = Console()
831870

832871
# Initialize Rich table for pretty printing

0 commit comments

Comments
 (0)