Skip to content

feat: add support for the --all to proxy remove#834

Open
eureka928 wants to merge 11 commits intoopentensor:stagingfrom
eureka928:feat/proxy-remove-all-v2
Open

feat: add support for the --all to proxy remove#834
eureka928 wants to merge 11 commits intoopentensor:stagingfrom
eureka928:feat/proxy-remove-all-v2

Conversation

@eureka928
Copy link
Contributor

@eureka928 eureka928 commented Feb 23, 2026

Summary

Refactor of #791, addressing reviewer feedback from @thewhaleking.

This PR adds the --all flag to btcli proxy remove so users can remove all proxies in a single operation. The two review comments on #791 have been addressed:

  1. Error on conflicting args instead of warning (comment): Providing --delegate together with --all now returns an error instead of silently ignoring the delegate.
  2. Combine into single function with a flag (comment): The separate remove_proxies() function has been merged into the existing remove_proxy() function using a remove_all: bool = False parameter, reducing code duplication.

Type of change

  • New feature (non-breaking)
  • Refactor (addresses code review feedback)

What's changed

File Change
`bittensor_cli/cli.py` Added `--all` flag to `proxy_remove` command; validation rejects conflicting `--delegate` + `--all`; routes `remove_all` flag to the unified function
`bittensor_cli/src/commands/proxy.py` Combined `remove_proxies()` into `remove_proxy()` with `remove_all` flag; branches prompt, call composition, and extrinsic based on the flag
`tests/e2e_tests/test_proxy.py` E2E tests: remove all proxies, validation errors, single proxy removal
`tests/unit_tests/test_cli.py` Unit tests: missing args error, conflicting args error, `--all` flag routing, single delegate routing

CLI validation flow

  1. Neither `--delegate` nor `--all` provided → error
  2. Both `--delegate` and `--all` provided → error
  3. `--all` only → calls `remove_proxy(..., remove_all=True)`
  4. `--delegate` only → calls `remove_proxy(..., remove_all=False)`

Usage

Remove a single proxy

btcli proxy remove --delegate 5GDel... --proxy-type Transfer --delay 0

Remove all proxies (requires typing "REMOVE" to confirm)

btcli proxy remove --all

Remove all proxies without prompt

btcli proxy remove --all --no-prompt

Testing

Unit tests

$ pytest tests/unit_tests/test_cli.py -v -k proxy
tests/unit_tests/test_cli.py::test_proxy_remove_requires_delegate_or_all PASSED
tests/unit_tests/test_cli.py::test_proxy_remove_requires_delegate_or_all_json PASSED
tests/unit_tests/test_cli.py::test_proxy_remove_with_all_and_delegate_errors PASSED
tests/unit_tests/test_cli.py::test_proxy_remove_with_all_flag PASSED
tests/unit_tests/test_cli.py::test_proxy_remove_with_delegate_calls_remove_proxy PASSED

Lint

$ ruff format --check bittensor_cli tests
All checks passed!

Checklist

Contribution by Gittensor, learn more at https://gittensor.io/

@eureka928 eureka928 changed the title refactor: combine remove_proxies into remove_proxy with remove_all flag feat: add support for the --all to proxy remove Feb 23, 2026
@eureka928
Copy link
Contributor Author

Hi @thewhaleking would you review my PR?
Thank you

@eureka928 eureka928 force-pushed the feat/proxy-remove-all-v2 branch from f576009 to 874e5e6 Compare February 23, 2026 15:45
@thewhaleking thewhaleking requested a review from a team February 23, 2026 15:51
),
] = "",
] = None,
all: bool = typer.Option(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all is a builtin fn in Python. Use all_

f"era: {period}\n"
)
# Validate that either delegate is provided or --all is used, but not both
if not all and not delegate:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the flow. Previously if a user did not provide --delegate, he would be prompted. Now he is not. This should fall back to prompting a delegate if --all is not explicitly used (or allow "all" as a keyword)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants