-
Notifications
You must be signed in to change notification settings - Fork 48
feat: add cli for axon set and reset #726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Conversation
thewhaleking
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is at least better than #725, but still has a lot going on that should have been verified before submitting.
|
@thewhaleking |
thewhaleking
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better. Will do a full review tomorrow.
| # is_success is a property that returns a coroutine | ||
| async def mock_is_success(): | ||
| return True | ||
| mock_response.is_success = mock_is_success() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be careful with this. It's fine here, but be careful in future situations as this will assign the coroutine object as is_success rather than the coroutine function property as it is usually used.
Typically you can do
await response.is_success
await response.is_success
await response.is_success
...because it's a property, but by assigning the result of a coroutine function to it, you can only do it once, and then you'll raise exceptions if you try to await it again. It can be a pain to debug.
thewhaleking
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
|
@thewhaleking |
Think we're not going to include this in 9.16, as it's already quite filled up. Should merge to staging after release of 9.16 (either today or Monday, coinciding with the release of mainnet) |
Add CLI commands for axon management
Closes #225
Summary
This PR adds two new CLI commands to manage axon serving information for neurons on the Bittensor network:
btcli axon reset- Resets axon to stop serving (sets IP to 0.0.0.0 and port to 1 as chain doesn't accept 0 as invalid port)btcli axon set- Sets axon serving endpoint with specified IP and portMotivation
Miners and validators need a convenient way to manage their axon serving endpoints directly from the CLI without writing custom scripts. This is particularly useful for:
Changes
New Files
bittensor_cli/src/bittensor/extrinsics/serving.pyreset_axon_extrinsic()- Handles axon reset logicset_axon_extrinsic()- Handles axon set logicip_to_int()- Utility for IP address conversiontests/unit_tests/test_axon_commands.pytests/e2e_tests/test_axon.pyModified Files
bittensor_cli/cli.pyservingextrinsics moduleaxon_appTyper applicationaxon_reset()command handleraxon_set()command handlerUsage
Reset Axon
Stop a neuron from serving by resetting its axon information:
Set Axon
Configure a neuron's serving endpoint:
Available Options
Both commands support:
--netuid- Subnet ID (required)--wallet-name- Wallet name--wallet-hotkey- Hotkey name--wallet-path- Custom wallet path--network- Network to connect to (default: finney)--prompt/--no-prompt- Interactive confirmation--wait-for-inclusion- Wait for block inclusion--wait-for-finalization- Wait for finalization--quiet- Minimal output--verbose- Detailed outputAdditional for
set:--ip- IP address (required)--port- Port number 0-65535 (required)--ip-type- 4 for IPv4, 6 for IPv6 (default: 4)--protocol- Protocol version (default: 4)Examples
Example 1: Reset axon for maintenance
Example 2: Set axon with public IP
btcli axon set --netuid 1 --ip 203.0.113.42 --port 8091 \ --wallet-name miner --wallet-hotkey defaultExample 3: Set axon without prompts (automation)
btcli axon set --netuid 1 --ip 192.168.1.100 --port 8091 \ --wallet-name miner --wallet-hotkey default --no-promptTesting
Unit Tests
# Run all unit tests python -m pytest tests/unit_tests/test_axon_commands.py -vTest Coverage:
E2E Tests
# Run e2e tests (requires Docker) python -m pytest tests/e2e_tests/test_axon.py -vTest Coverage:
Implementation Details
Technical Approach
Extrinsic Composition
SubtensorModule::serve_axoncallIP Address Handling
netaddrlibraryError Handling
User Experience
Security Considerations
Contribution by Gittensor, learn more at https://gittensor.io/