diff --git a/gittensor/cli/issue_commands/admin.py b/gittensor/cli/issue_commands/admin.py index 286a8d9d..9a3db0e4 100644 --- a/gittensor/cli/issue_commands/admin.py +++ b/gittensor/cli/issue_commands/admin.py @@ -24,6 +24,7 @@ confirm_or_abort, err_console, format_alpha, + loading_context, print_error, print_network_header, print_success, @@ -72,7 +73,7 @@ def admin_cancel( print_network_header(network_name, contract_addr) try: - with err_console.status('[bold cyan]Connecting and reading issue...', spinner='dots'): + with loading_context('Connecting and reading issue...', as_json=False): wallet, client = _make_contract_client(contract_addr, ws_endpoint, wallet_name, wallet_hotkey) issue = client.get_issue(issue_id) @@ -93,7 +94,7 @@ def admin_cancel( if not confirm_or_abort(f'Cancel issue {issue_id}? This returns the bounty to the alpha pool.', yes): return - with err_console.status('[bold cyan]Submitting cancellation...', spinner='dots'): + with loading_context('Submitting cancellation...', as_json=False): result = client.cancel_issue(issue_id, wallet) if result: @@ -134,7 +135,7 @@ def admin_payout( print_network_header(network_name, contract_addr) try: - with err_console.status('[bold cyan]Connecting and reading issue...', spinner='dots'): + with loading_context('Connecting and reading issue...', as_json=False): wallet, client = _make_contract_client(contract_addr, ws_endpoint, wallet_name, wallet_hotkey) issue = client.get_issue(issue_id) @@ -155,7 +156,7 @@ def admin_payout( if not confirm_or_abort(f'Pay out issue {issue_id}?', yes): return - with err_console.status('[bold cyan]Submitting payout...', spinner='dots'): + with loading_context('Submitting payout...', as_json=False): result = client.payout_bounty(issue_id, wallet) if result: @@ -204,7 +205,7 @@ def admin_set_owner( return try: - with err_console.status('[bold cyan]Transferring ownership...', spinner='dots'): + with loading_context('Transferring ownership...', as_json=False): wallet, client = _make_contract_client(contract_addr, ws_endpoint, wallet_name, wallet_hotkey) result = client.set_owner(new_owner, wallet) @@ -258,7 +259,7 @@ def admin_set_treasury( return try: - with err_console.status('[bold cyan]Updating treasury hotkey...', spinner='dots'): + with loading_context('Updating treasury hotkey...', as_json=False): wallet, client = _make_contract_client(contract_addr, ws_endpoint, wallet_name, wallet_hotkey) result = client.set_treasury_hotkey(new_treasury, wallet) @@ -313,7 +314,7 @@ def admin_add_validator( return try: - with err_console.status('[bold cyan]Adding validator...', spinner='dots'): + with loading_context('Adding validator...', as_json=False): wallet, client = _make_contract_client(contract_addr, ws_endpoint, wallet_name, wallet_hotkey) result = client.add_validator(hotkey, wallet) @@ -367,7 +368,7 @@ def admin_remove_validator( return try: - with err_console.status('[bold cyan]Removing validator...', spinner='dots'): + with loading_context('Removing validator...', as_json=False): wallet, client = _make_contract_client(contract_addr, ws_endpoint, wallet_name, wallet_hotkey) result = client.remove_validator(hotkey, wallet) diff --git a/gittensor/cli/issue_commands/mutations.py b/gittensor/cli/issue_commands/mutations.py index c239bde4..e2574703 100644 --- a/gittensor/cli/issue_commands/mutations.py +++ b/gittensor/cli/issue_commands/mutations.py @@ -24,6 +24,7 @@ err_console, format_alpha, load_config, + loading_context, print_error, print_network_header, print_success, @@ -179,7 +180,7 @@ def issue_register( from substrateinterface import Keypair, SubstrateInterface from substrateinterface.contracts import ContractInstance - with err_console.status('[bold cyan]Connecting to network...', spinner='dots'): + with loading_context('Connecting to network...', as_json=False): substrate = SubstrateInterface(url=ws_endpoint) # CLI flags override config; fall back to config if not explicitly supplied @@ -327,12 +328,12 @@ def issue_harvest(wallet_name: str, wallet_hotkey: str, network: str, rpc_url: s IssueCompetitionContractClient, ) - with err_console.status('[bold cyan]Loading wallet...', spinner='dots'): + with loading_context('Loading wallet...', as_json=False): wallet = bt.Wallet(name=wallet_name, hotkey=wallet_hotkey) hotkey_addr = wallet.hotkey.ss58_address err_console.print(f'[green]Hotkey address:[/green] {hotkey_addr}') - with err_console.status('[bold cyan]Connecting to network...', spinner='dots'): + with loading_context('Connecting to network...', as_json=False): subtensor = bt.Subtensor(network=ws_endpoint) # Show wallet balance (informational only) @@ -343,7 +344,7 @@ def issue_harvest(wallet_name: str, wallet_hotkey: str, network: str, rpc_url: s except Exception as e: err_console.print(f'[dim]Could not fetch balance: {e}[/dim]') - with err_console.status('[bold cyan]Initializing contract client...', spinner='dots'): + with loading_context('Initializing contract client...', as_json=False): client = IssueCompetitionContractClient( contract_address=contract_addr, subtensor=subtensor, @@ -367,7 +368,7 @@ def issue_harvest(wallet_name: str, wallet_hotkey: str, network: str, rpc_url: s except Exception as e: err_console.print(f'[yellow]Warning: Could not read contract state: {e}[/yellow]') - with err_console.status('[bold cyan]Calling harvest_emissions()...', spinner='dots'): + with loading_context('Calling harvest_emissions()...', as_json=False): result = client.harvest_emissions(wallet) if result: diff --git a/gittensor/cli/issue_commands/vote.py b/gittensor/cli/issue_commands/vote.py index 905e5c41..61343131 100644 --- a/gittensor/cli/issue_commands/vote.py +++ b/gittensor/cli/issue_commands/vote.py @@ -143,7 +143,7 @@ def val_vote_solution( return try: - with err_console.status('[bold cyan]Submitting vote...', spinner='dots'): + with loading_context('Submitting vote...', as_json=False): wallet, client = _make_contract_client(contract_addr, ws_endpoint, wallet_name, wallet_hotkey) result = client.vote_solution(issue_id, solver_hotkey, solver_coldkey, pr_number, wallet) @@ -202,7 +202,7 @@ def val_vote_cancel_issue( return try: - with err_console.status('[bold cyan]Submitting cancel vote...', spinner='dots'): + with loading_context('Submitting cancel vote...', as_json=False): wallet, client = _make_contract_client(contract_addr, ws_endpoint, wallet_name, wallet_hotkey) result = client.vote_cancel_issue(issue_id, reason, wallet) diff --git a/gittensor/cli/miner_commands/score.py b/gittensor/cli/miner_commands/score.py index ac608a93..034496db 100644 --- a/gittensor/cli/miner_commands/score.py +++ b/gittensor/cli/miner_commands/score.py @@ -22,6 +22,7 @@ from rich.console import Console from rich.table import Table +from gittensor.cli.issue_commands.helpers import loading_context from gittensor.cli.json_output import emit_json from gittensor.cli.miner_commands.helpers import _error @@ -269,7 +270,7 @@ def score_command(pat: Optional[str], log_level: str, json_mode: bool) -> None: programming_languages = load_programming_language_weights() token_config = load_token_config() else: - with console.status('[bold cyan]Loading weights', spinner='dots'): + with loading_context('Loading weights', as_json=True): master_repositories = load_master_repo_weights() programming_languages = load_programming_language_weights() token_config = load_token_config()