@@ -4878,6 +4878,7 @@ def subnets_burn_cost(
4878
4878
network : Optional [list [str ]] = Options .network ,
4879
4879
quiet : bool = Options .quiet ,
4880
4880
verbose : bool = Options .verbose ,
4881
+ json_output : bool = Options .json_output ,
4881
4882
):
4882
4883
"""
4883
4884
Shows the required amount of TAO to be recycled for creating a new subnet, i.e., cost of registering a new subnet.
@@ -4888,8 +4889,10 @@ def subnets_burn_cost(
4888
4889
4889
4890
[green]$[/green] btcli subnets burn_cost
4890
4891
"""
4891
- self .verbosity_handler (quiet , verbose )
4892
- return self ._run_command (subnets .burn_cost (self .initialize_chain (network )))
4892
+ self .verbosity_handler (quiet , verbose , json_output )
4893
+ return self ._run_command (
4894
+ subnets .burn_cost (self .initialize_chain (network ), json_output )
4895
+ )
4893
4896
4894
4897
def subnets_create (
4895
4898
self ,
@@ -4922,6 +4925,7 @@ def subnets_create(
4922
4925
additional_info : Optional [str ] = typer .Option (
4923
4926
None , "--additional-info" , help = "Additional information"
4924
4927
),
4928
+ json_output : bool = Options .json_output ,
4925
4929
prompt : bool = Options .prompt ,
4926
4930
quiet : bool = Options .quiet ,
4927
4931
verbose : bool = Options .verbose ,
@@ -4940,7 +4944,7 @@ def subnets_create(
4940
4944
2. Create with GitHub repo and contact email:
4941
4945
[green]$[/green] btcli subnets create --subnet-name MySubnet --github-repo https://github.com/myorg/mysubnet --subnet-contact [email protected]
4942
4946
"""
4943
- self .verbosity_handler (quiet , verbose )
4947
+ self .verbosity_handler (quiet , verbose , json_output )
4944
4948
wallet = self .wallet_ask (
4945
4949
wallet_name ,
4946
4950
wallet_path ,
@@ -4962,34 +4966,19 @@ def subnets_create(
4962
4966
description = description ,
4963
4967
additional = additional_info ,
4964
4968
)
4965
- success = self ._run_command (
4966
- subnets .create (wallet , self .initialize_chain (network ), identity , prompt ),
4967
- exit_early = False ,
4969
+ self ._run_command (
4970
+ subnets .create (
4971
+ wallet , self .initialize_chain (network ), identity , json_output , prompt
4972
+ )
4968
4973
)
4969
4974
4970
- if success and prompt :
4971
- set_id = Confirm .ask (
4972
- "[dark_sea_green3]Do you want to set/update your identity?" ,
4973
- default = False ,
4974
- show_default = True ,
4975
- )
4976
- if set_id :
4977
- self .wallet_set_id (
4978
- wallet_name = wallet .name ,
4979
- wallet_hotkey = wallet .hotkey ,
4980
- wallet_path = wallet .path ,
4981
- network = network ,
4982
- prompt = prompt ,
4983
- quiet = quiet ,
4984
- verbose = verbose ,
4985
- )
4986
-
4987
4975
def subnets_get_identity (
4988
4976
self ,
4989
4977
network : Optional [list [str ]] = Options .network ,
4990
4978
netuid : int = Options .netuid ,
4991
4979
quiet : bool = Options .quiet ,
4992
4980
verbose : bool = Options .verbose ,
4981
+ json_output : bool = Options .json_output ,
4993
4982
):
4994
4983
"""
4995
4984
Get the identity information for a subnet.
@@ -4998,11 +4987,10 @@ def subnets_get_identity(
4998
4987
4999
4988
[green]$[/green] btcli subnets get-identity --netuid 1
5000
4989
"""
5001
- self .verbosity_handler (quiet , verbose )
4990
+ self .verbosity_handler (quiet , verbose , json_output )
5002
4991
return self ._run_command (
5003
4992
subnets .get_identity (
5004
- self .initialize_chain (network ),
5005
- netuid ,
4993
+ self .initialize_chain (network ), netuid , json_output = json_output
5006
4994
)
5007
4995
)
5008
4996
@@ -5038,6 +5026,7 @@ def subnets_set_identity(
5038
5026
additional_info : Optional [str ] = typer .Option (
5039
5027
None , "--additional-info" , help = "Additional information"
5040
5028
),
5029
+ json_output : bool = Options .json_output ,
5041
5030
prompt : bool = Options .prompt ,
5042
5031
quiet : bool = Options .quiet ,
5043
5032
verbose : bool = Options .verbose ,
@@ -5055,7 +5044,7 @@ def subnets_set_identity(
5055
5044
2. Set subnet identity with specific values:
5056
5045
[green]$[/green] btcli subnets set-identity --netuid 1 --subnet-name MySubnet --github-repo https://github.com/myorg/mysubnet --subnet-contact [email protected]
5057
5046
"""
5058
- self .verbosity_handler (quiet , verbose )
5047
+ self .verbosity_handler (quiet , verbose , json_output )
5059
5048
wallet = self .wallet_ask (
5060
5049
wallet_name ,
5061
5050
wallet_path ,
@@ -5073,7 +5062,9 @@ def subnets_set_identity(
5073
5062
exit_early = False ,
5074
5063
)
5075
5064
if current_identity is None :
5076
- raise typer .Exit ()
5065
+ if json_output :
5066
+ json_console .print ('{"success": false}' )
5067
+ return
5077
5068
5078
5069
identity = prompt_for_subnet_identity (
5079
5070
current_identity = current_identity ,
@@ -5086,15 +5077,13 @@ def subnets_set_identity(
5086
5077
additional = additional_info ,
5087
5078
)
5088
5079
5089
- return self ._run_command (
5080
+ success = self ._run_command (
5090
5081
subnets .set_identity (
5091
- wallet ,
5092
- self .initialize_chain (network ),
5093
- netuid ,
5094
- identity ,
5095
- prompt ,
5082
+ wallet , self .initialize_chain (network ), netuid , identity , prompt
5096
5083
)
5097
5084
)
5085
+ if json_output :
5086
+ json_console .print (json .dumps ({"success" : success }))
5098
5087
5099
5088
def subnets_pow_register (
5100
5089
self ,
@@ -5199,6 +5188,7 @@ def subnets_register(
5199
5188
help = "Length (in blocks) for which the transaction should be valid. Note that it is possible that if you "
5200
5189
"use an era for this transaction that you may pay a different fee to register than the one stated." ,
5201
5190
),
5191
+ json_output : bool = Options .json_output ,
5202
5192
prompt : bool = Options .prompt ,
5203
5193
quiet : bool = Options .quiet ,
5204
5194
verbose : bool = Options .verbose ,
@@ -5214,7 +5204,7 @@ def subnets_register(
5214
5204
5215
5205
[green]$[/green] btcli subnets register --netuid 1
5216
5206
"""
5217
- self .verbosity_handler (quiet , verbose )
5207
+ self .verbosity_handler (quiet , verbose , json_output )
5218
5208
wallet = self .wallet_ask (
5219
5209
wallet_name ,
5220
5210
wallet_path ,
@@ -5228,6 +5218,7 @@ def subnets_register(
5228
5218
self .initialize_chain (network ),
5229
5219
netuid ,
5230
5220
era ,
5221
+ json_output ,
5231
5222
prompt ,
5232
5223
)
5233
5224
)
@@ -5353,6 +5344,7 @@ def weights_reveal(
5353
5344
"-s" ,
5354
5345
help = "Corresponding salt for the hash function, e.g. -s 163,241,217 ..." ,
5355
5346
),
5347
+ json_output : bool = Options .json_output ,
5356
5348
quiet : bool = Options .quiet ,
5357
5349
verbose : bool = Options .verbose ,
5358
5350
prompt : bool = Options .prompt ,
@@ -5366,7 +5358,7 @@ def weights_reveal(
5366
5358
5367
5359
[green]$[/green] btcli wt reveal --netuid 1 --uids 1,2,3,4 --weights 0.1,0.2,0.3,0.4 --salt 163,241,217,11,161,142,147,189
5368
5360
"""
5369
- self .verbosity_handler (quiet , verbose )
5361
+ self .verbosity_handler (quiet , verbose , json_output )
5370
5362
uids = list_prompt (uids , int , "UIDs of interest for the specified netuid" )
5371
5363
weights = list_prompt (
5372
5364
weights , float , "Corresponding weights for the specified UIDs"
@@ -5399,7 +5391,7 @@ def weights_reveal(
5399
5391
err_console .print (
5400
5392
"The number of UIDs you specify must match up with the specified number of weights"
5401
5393
)
5402
- raise typer . Exit ()
5394
+ return
5403
5395
5404
5396
if salt :
5405
5397
salt = parse_to_list (
@@ -5428,6 +5420,7 @@ def weights_reveal(
5428
5420
salt ,
5429
5421
__version_as_int__ ,
5430
5422
prompt = prompt ,
5423
+ json_output = json_output ,
5431
5424
)
5432
5425
)
5433
5426
@@ -5451,6 +5444,7 @@ def weights_commit(
5451
5444
"-s" ,
5452
5445
help = "Corresponding salt for the hash function, e.g. -s 163 -s 241 -s 217 ..." ,
5453
5446
),
5447
+ json_output : bool = Options .json_output ,
5454
5448
quiet : bool = Options .quiet ,
5455
5449
verbose : bool = Options .verbose ,
5456
5450
prompt : bool = Options .prompt ,
@@ -5468,7 +5462,7 @@ def weights_commit(
5468
5462
[italic]Note[/italic]: This command is used to commit weights for a specific subnet and requires the user to have the necessary
5469
5463
permissions.
5470
5464
"""
5471
- self .verbosity_handler (quiet , verbose )
5465
+ self .verbosity_handler (quiet , verbose , json_output )
5472
5466
5473
5467
if uids :
5474
5468
uids = parse_to_list (
@@ -5497,7 +5491,7 @@ def weights_commit(
5497
5491
err_console .print (
5498
5492
"The number of UIDs you specify must match up with the specified number of weights"
5499
5493
)
5500
- raise typer . Exit ()
5494
+ return
5501
5495
5502
5496
if salt :
5503
5497
salt = parse_to_list (
@@ -5524,6 +5518,7 @@ def weights_commit(
5524
5518
weights ,
5525
5519
salt ,
5526
5520
__version_as_int__ ,
5521
+ json_output = json_output ,
5527
5522
prompt = prompt ,
5528
5523
)
5529
5524
)
0 commit comments