Refactor set-children function in children_hotkeys.py
#812
+823
−72
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Refactors
stake child setto be simpler and more consistent, adds a parent hotkey override in the CLI, and adds e2e coverage.Changes
set_childrenrefactor: Simplifiedbittensor_cli/src/commands/stake/children_hotkeys.py:set_children()into a single loop over target netuids (dict_outputkeyed by netuid).--wallet-hotkeyto:btcli stake child setand plumbed it through tochildren_hotkeys.set_children(..., hotkey=...).set_childrento reject when (\sum proportions > 1.0) (prints an error; when--json-outputis set, returns a JSON error payload).set_childrentotests/e2e_tests/test_children_hotkeys.py:test_set_childrentest_set_children_multiple_proportionsBefore vs After
Before:
After:
netuidswith consistentdict_outputstructure.hotkeyparameter (CLI:--wallet-hotkey) to manage children for a different parent hotkey SS58.Test Coverage
Added 7 comprehensive e2e tests in
tests/e2e_tests/test_children_hotkeys.py:stake child getTests:test_get_children_json_output- Tests getting children with--json-outputflag, verifies JSON structure and validates response formattest_get_children_non_json_output- Tests getting children without JSON flag, verifies table format outputstake child setTests:test_set_children_single_child- Tests setting a single child hotkey with 50% proportion, verifiescompletion_blockandset_blockin responsetest_set_children_multiple_proportions- Tests setting multiple children (Bob 30%, Charlie 40%) with different proportions, verifies both are set correctlyTest Commands Verified
Added e2e tests in
tests/e2e_tests/test_children_hotkeys.py:btcli stake child get --netuid <netuid>btcli stake child get --all-netuidsbtcli stake child set --children <address> --proportions <proportion> --netuid <netuid>btcli stake child setwith multiple children and proportionsFiles Changed
bittensor_cli/src/commands/stake/children_hotkeys.pybittensor_cli/cli.pytests/e2e_tests/test_children_hotkeys.py