bittensor-cli 9.3.0__py3-none-any.whl → 9.4.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
bittensor_cli/cli.py CHANGED
@@ -259,14 +259,15 @@ class Options:
259
259
  "--slippage-tolerance",
260
260
  "--tolerance",
261
261
  "--rate-tolerance",
262
- help="Set the rate tolerance percentage for transactions (default: 0.05%).",
262
+ help="Set the rate tolerance percentage for transactions (default: 0.05 for 5%).",
263
263
  callback=validate_rate_tolerance,
264
264
  )
265
265
  safe_staking = typer.Option(
266
266
  None,
267
267
  "--safe-staking/--no-safe-staking",
268
268
  "--safe/--unsafe",
269
- help="Enable or disable safe staking mode (default: enabled).",
269
+ show_default=False,
270
+ help="Enable or disable safe staking mode [dim](default: enabled)[/dim].",
270
271
  )
271
272
  allow_partial_stake = typer.Option(
272
273
  None,
@@ -274,7 +275,8 @@ class Options:
274
275
  "--partial/--no-partial",
275
276
  "--allow/--not-allow",
276
277
  "--allow-partial/--not-partial",
277
- help="Enable or disable partial stake mode (default: disabled).",
278
+ show_default=False,
279
+ help="Enable or disable partial stake mode [dim](default: disabled)[/dim].",
278
280
  )
279
281
  dashboard_path = typer.Option(
280
282
  None,
@@ -291,8 +293,11 @@ class Options:
291
293
  "--json-out",
292
294
  help="Outputs the result of the command as JSON.",
293
295
  )
294
- era: int = typer.Option(
295
- 3, help="Length (in blocks) for which the transaction should be valid."
296
+ period: int = typer.Option(
297
+ 16,
298
+ "--period",
299
+ "--era",
300
+ help="Length (in blocks) for which the transaction should be valid.",
296
301
  )
297
302
 
298
303
 
@@ -434,36 +439,49 @@ def parse_mnemonic(mnemonic: str) -> str:
434
439
  def get_creation_data(
435
440
  mnemonic: Optional[str],
436
441
  seed: Optional[str],
437
- json: Optional[str],
442
+ json_path: Optional[str],
438
443
  json_password: Optional[str],
439
444
  ) -> tuple[str, str, str, str]:
440
445
  """
441
446
  Determines which of the key creation elements have been supplied, if any. If None have been supplied,
442
447
  prompts to user, and determines what they've supplied. Returns all elements in a tuple.
443
448
  """
444
- if not mnemonic and not seed and not json:
445
- prompt_answer = Prompt.ask(
446
- "Enter the mnemonic, or the seed hex string, or the location of the JSON file."
449
+ if not mnemonic and not seed and not json_path:
450
+ choices = {
451
+ 1: "mnemonic",
452
+ 2: "seed hex string",
453
+ 3: "path to JSON File",
454
+ }
455
+ type_answer = IntPrompt.ask(
456
+ "Select one of the following to enter\n"
457
+ f"[{COLORS.G.HINT}][1][/{COLORS.G.HINT}] Mnemonic\n"
458
+ f"[{COLORS.G.HINT}][2][/{COLORS.G.HINT}] Seed hex string\n"
459
+ f"[{COLORS.G.HINT}][3][/{COLORS.G.HINT}] Path to JSON File\n",
460
+ choices=["1", "2", "3"],
461
+ show_choices=False,
447
462
  )
448
- if prompt_answer.startswith("0x"):
463
+ prompt_answer = Prompt.ask(f"Please enter your {choices[type_answer]}")
464
+ if type_answer == 1:
465
+ mnemonic = prompt_answer
466
+ elif type_answer == 2:
449
467
  seed = prompt_answer
450
- elif len(prompt_answer.split(" ")) > 1:
451
- mnemonic = parse_mnemonic(prompt_answer)
452
- else:
453
- json = prompt_answer
468
+ if seed.startswith("0x"):
469
+ seed = seed[2:]
470
+ elif type_answer == 3:
471
+ json_path = prompt_answer
454
472
  elif mnemonic:
455
473
  mnemonic = parse_mnemonic(mnemonic)
456
474
 
457
- if json:
458
- if not os.path.exists(json):
459
- print_error(f"The JSON file '{json}' does not exist.")
475
+ if json_path:
476
+ if not os.path.exists(json_path):
477
+ print_error(f"The JSON file '{json_path}' does not exist.")
460
478
  raise typer.Exit()
461
479
 
462
- if json and not json_password:
480
+ if json_path and not json_password:
463
481
  json_password = Prompt.ask(
464
482
  "Enter the backup password for JSON file.", password=True
465
483
  )
466
- return mnemonic, seed, json, json_password
484
+ return mnemonic, seed, json_path, json_password
467
485
 
468
486
 
469
487
  def config_selector(conf: dict, title: str):
@@ -873,6 +891,12 @@ class CLIManager:
873
891
  self.subnets_app.command(
874
892
  "get-identity", rich_help_panel=HELP_PANELS["SUBNETS"]["IDENTITY"]
875
893
  )(self.subnets_get_identity)
894
+ self.subnets_app.command(
895
+ "start", rich_help_panel=HELP_PANELS["SUBNETS"]["CREATION"]
896
+ )(self.subnets_start)
897
+ self.subnets_app.command(
898
+ "check-start", rich_help_panel=HELP_PANELS["SUBNETS"]["INFO"]
899
+ )(self.subnets_check_start)
876
900
 
877
901
  # weights commands
878
902
  self.weights_app.command(
@@ -1184,12 +1208,14 @@ class CLIManager:
1184
1208
  "--safe-staking/--no-safe-staking",
1185
1209
  "--safe/--unsafe",
1186
1210
  help="Enable or disable safe staking mode.",
1211
+ show_default=False,
1187
1212
  ),
1188
1213
  allow_partial_stake: Optional[bool] = typer.Option(
1189
1214
  None,
1190
1215
  "--allow-partial-stake/--no-allow-partial-stake",
1191
1216
  "--partial/--no-partial",
1192
1217
  "--allow/--not-allow",
1218
+ show_default=False,
1193
1219
  ),
1194
1220
  dashboard_path: Optional[str] = Options.dashboard_path,
1195
1221
  ):
@@ -1782,7 +1808,7 @@ class CLIManager:
1782
1808
  transfer_all: bool = typer.Option(
1783
1809
  False, "--all", prompt=False, help="Transfer all available balance."
1784
1810
  ),
1785
- era: int = Options.era,
1811
+ period: int = Options.period,
1786
1812
  wallet_name: str = Options.wallet_name,
1787
1813
  wallet_path: str = Options.wallet_path,
1788
1814
  wallet_hotkey: str = Options.wallet_hotkey,
@@ -1837,7 +1863,7 @@ class CLIManager:
1837
1863
  destination=destination_ss58_address,
1838
1864
  amount=amount,
1839
1865
  transfer_all=transfer_all,
1840
- era=era,
1866
+ era=period,
1841
1867
  prompt=prompt,
1842
1868
  json_output=json_output,
1843
1869
  )
@@ -2080,7 +2106,7 @@ class CLIManager:
2080
2106
  wallet_hotkey: Optional[str] = Options.wallet_hotkey,
2081
2107
  mnemonic: Optional[str] = Options.mnemonic,
2082
2108
  seed: Optional[str] = Options.seed,
2083
- json: Optional[str] = Options.json,
2109
+ json_path: Optional[str] = Options.json,
2084
2110
  json_password: Optional[str] = Options.json_password,
2085
2111
  use_password: Optional[bool] = Options.use_password,
2086
2112
  overwrite: bool = Options.overwrite,
@@ -2120,15 +2146,15 @@ class CLIManager:
2120
2146
 
2121
2147
  wallet = Wallet(wallet_name, wallet_hotkey, wallet_path)
2122
2148
 
2123
- mnemonic, seed, json, json_password = get_creation_data(
2124
- mnemonic, seed, json, json_password
2149
+ mnemonic, seed, json_path, json_password = get_creation_data(
2150
+ mnemonic, seed, json_path, json_password
2125
2151
  )
2126
2152
  return self._run_command(
2127
2153
  wallets.regen_coldkey(
2128
2154
  wallet,
2129
2155
  mnemonic,
2130
2156
  seed,
2131
- json,
2157
+ json_path,
2132
2158
  json_password,
2133
2159
  use_password,
2134
2160
  overwrite,
@@ -2204,7 +2230,7 @@ class CLIManager:
2204
2230
  wallet_hotkey: Optional[str] = Options.wallet_hotkey,
2205
2231
  mnemonic: Optional[str] = Options.mnemonic,
2206
2232
  seed: Optional[str] = Options.seed,
2207
- json: Optional[str] = Options.json,
2233
+ json_path: Optional[str] = Options.json,
2208
2234
  json_password: Optional[str] = Options.json_password,
2209
2235
  use_password: bool = typer.Option(
2210
2236
  False, # Overriden to False
@@ -2240,15 +2266,15 @@ class CLIManager:
2240
2266
  ask_for=[WO.NAME, WO.PATH, WO.HOTKEY],
2241
2267
  validate=WV.WALLET,
2242
2268
  )
2243
- mnemonic, seed, json, json_password = get_creation_data(
2244
- mnemonic, seed, json, json_password
2269
+ mnemonic, seed, json_path, json_password = get_creation_data(
2270
+ mnemonic, seed, json_path, json_password
2245
2271
  )
2246
2272
  return self._run_command(
2247
2273
  wallets.regen_hotkey(
2248
2274
  wallet,
2249
2275
  mnemonic,
2250
2276
  seed,
2251
- json,
2277
+ json_path,
2252
2278
  json_password,
2253
2279
  use_password,
2254
2280
  overwrite,
@@ -3180,7 +3206,7 @@ class CLIManager:
3180
3206
  rate_tolerance: Optional[float] = Options.rate_tolerance,
3181
3207
  safe_staking: Optional[bool] = Options.safe_staking,
3182
3208
  allow_partial_stake: Optional[bool] = Options.allow_partial_stake,
3183
- era: int = Options.era,
3209
+ period: int = Options.period,
3184
3210
  prompt: bool = Options.prompt,
3185
3211
  quiet: bool = Options.quiet,
3186
3212
  verbose: bool = Options.verbose,
@@ -3376,7 +3402,7 @@ class CLIManager:
3376
3402
  rate_tolerance,
3377
3403
  allow_partial_stake,
3378
3404
  json_output,
3379
- era,
3405
+ period,
3380
3406
  )
3381
3407
  )
3382
3408
 
@@ -3428,7 +3454,7 @@ class CLIManager:
3428
3454
  rate_tolerance: Optional[float] = Options.rate_tolerance,
3429
3455
  safe_staking: Optional[bool] = Options.safe_staking,
3430
3456
  allow_partial_stake: Optional[bool] = Options.allow_partial_stake,
3431
- era: int = Options.era,
3457
+ period: int = Options.period,
3432
3458
  prompt: bool = Options.prompt,
3433
3459
  interactive: bool = typer.Option(
3434
3460
  False,
@@ -3621,7 +3647,7 @@ class CLIManager:
3621
3647
  exclude_hotkeys=exclude_hotkeys,
3622
3648
  prompt=prompt,
3623
3649
  json_output=json_output,
3624
- era=era,
3650
+ era=period,
3625
3651
  )
3626
3652
  )
3627
3653
  elif (
@@ -3677,7 +3703,7 @@ class CLIManager:
3677
3703
  rate_tolerance=rate_tolerance,
3678
3704
  allow_partial_stake=allow_partial_stake,
3679
3705
  json_output=json_output,
3680
- era=era,
3706
+ era=period,
3681
3707
  )
3682
3708
  )
3683
3709
 
@@ -3705,7 +3731,7 @@ class CLIManager:
3705
3731
  stake_all: bool = typer.Option(
3706
3732
  False, "--stake-all", "--all", help="Stake all", prompt=False
3707
3733
  ),
3708
- era: int = Options.era,
3734
+ period: int = Options.period,
3709
3735
  prompt: bool = Options.prompt,
3710
3736
  quiet: bool = Options.quiet,
3711
3737
  verbose: bool = Options.verbose,
@@ -3835,7 +3861,7 @@ class CLIManager:
3835
3861
  destination_hotkey=destination_hotkey,
3836
3862
  amount=amount,
3837
3863
  stake_all=stake_all,
3838
- era=era,
3864
+ era=period,
3839
3865
  interactive_selection=interactive_selection,
3840
3866
  prompt=prompt,
3841
3867
  )
@@ -3876,7 +3902,7 @@ class CLIManager:
3876
3902
  stake_all: bool = typer.Option(
3877
3903
  False, "--stake-all", "--all", help="Stake all", prompt=False
3878
3904
  ),
3879
- era: int = Options.era,
3905
+ period: int = Options.period,
3880
3906
  prompt: bool = Options.prompt,
3881
3907
  quiet: bool = Options.quiet,
3882
3908
  verbose: bool = Options.verbose,
@@ -3998,7 +4024,7 @@ class CLIManager:
3998
4024
  dest_netuid=dest_netuid,
3999
4025
  dest_coldkey_ss58=dest_ss58,
4000
4026
  amount=amount,
4001
- era=era,
4027
+ era=period,
4002
4028
  interactive_selection=interactive_selection,
4003
4029
  stake_all=stake_all,
4004
4030
  prompt=prompt,
@@ -4040,7 +4066,7 @@ class CLIManager:
4040
4066
  "--all",
4041
4067
  help="Swap all available stake",
4042
4068
  ),
4043
- era: int = Options.era,
4069
+ period: int = Options.period,
4044
4070
  prompt: bool = Options.prompt,
4045
4071
  wait_for_inclusion: bool = Options.wait_for_inclusion,
4046
4072
  wait_for_finalization: bool = Options.wait_for_finalization,
@@ -4105,7 +4131,7 @@ class CLIManager:
4105
4131
  destination_netuid=dest_netuid,
4106
4132
  amount=amount,
4107
4133
  swap_all=swap_all,
4108
- era=era,
4134
+ era=period,
4109
4135
  interactive_selection=interactive_selection,
4110
4136
  prompt=prompt,
4111
4137
  wait_for_inclusion=wait_for_inclusion,
@@ -4420,6 +4446,7 @@ class CLIManager:
4420
4446
  param_value: Optional[str] = typer.Option(
4421
4447
  "", "--value", help="Value to set the hyperparameter to."
4422
4448
  ),
4449
+ prompt: bool = Options.prompt,
4423
4450
  quiet: bool = Options.quiet,
4424
4451
  verbose: bool = Options.verbose,
4425
4452
  json_output: bool = Options.json_output,
@@ -4444,6 +4471,11 @@ class CLIManager:
4444
4471
  raise typer.Exit()
4445
4472
 
4446
4473
  if not param_name:
4474
+ if not prompt:
4475
+ err_console.print(
4476
+ "Param name not supplied with `--no-prompt` flag. Cannot continue"
4477
+ )
4478
+ return False
4447
4479
  hyperparam_list = [field.name for field in fields(SubnetHyperparameters)]
4448
4480
  console.print("Available hyperparameters:\n")
4449
4481
  for idx, param in enumerate(hyperparam_list, start=1):
@@ -4457,6 +4489,11 @@ class CLIManager:
4457
4489
  param_name = hyperparam_list[choice - 1]
4458
4490
 
4459
4491
  if param_name in ["alpha_high", "alpha_low"]:
4492
+ if not prompt:
4493
+ err_console.print(
4494
+ "`alpha_high` and `alpha_low` values cannot be set with `--no-prompt`"
4495
+ )
4496
+ return False
4460
4497
  param_name = "alpha_values"
4461
4498
  low_val = FloatPrompt.ask(
4462
4499
  "Enter the new value for [dark_orange]alpha_low[/dark_orange]"
@@ -4467,6 +4504,11 @@ class CLIManager:
4467
4504
  param_value = f"{low_val},{high_val}"
4468
4505
 
4469
4506
  if not param_value:
4507
+ if not prompt:
4508
+ err_console.print(
4509
+ "Param value not supplied with `--no-prompt` flag. Cannot continue."
4510
+ )
4511
+ return False
4470
4512
  if HYPERPARAMS.get(param_name):
4471
4513
  param_value = Prompt.ask(
4472
4514
  f"Enter the new value for [{COLORS.G.SUBHEAD}]{param_name}[/{COLORS.G.SUBHEAD}] "
@@ -4485,6 +4527,7 @@ class CLIManager:
4485
4527
  netuid,
4486
4528
  param_name,
4487
4529
  param_value,
4530
+ prompt,
4488
4531
  json_output,
4489
4532
  )
4490
4533
  )
@@ -4975,6 +5018,70 @@ class CLIManager:
4975
5018
  )
4976
5019
  )
4977
5020
 
5021
+ def subnets_check_start(
5022
+ self,
5023
+ network: Optional[list[str]] = Options.network,
5024
+ netuid: int = Options.netuid,
5025
+ quiet: bool = Options.quiet,
5026
+ verbose: bool = Options.verbose,
5027
+ ):
5028
+ """
5029
+ Checks if a subnet's emission schedule can be started.
5030
+
5031
+ This command verifies if a subnet's emission schedule can be started based on the subnet's registration block.
5032
+
5033
+ Example:
5034
+ [green]$[/green] btcli subnets check_start --netuid 1
5035
+ """
5036
+ self.verbosity_handler(quiet, verbose)
5037
+ return self._run_command(
5038
+ subnets.get_start_schedule(self.initialize_chain(network), netuid)
5039
+ )
5040
+
5041
+ def subnets_start(
5042
+ self,
5043
+ wallet_name: str = Options.wallet_name,
5044
+ wallet_path: str = Options.wallet_path,
5045
+ wallet_hotkey: str = Options.wallet_hotkey,
5046
+ network: Optional[list[str]] = Options.network,
5047
+ netuid: int = Options.netuid,
5048
+ prompt: bool = Options.prompt,
5049
+ quiet: bool = Options.quiet,
5050
+ verbose: bool = Options.verbose,
5051
+ ):
5052
+ """
5053
+ Starts a subnet's emission schedule.
5054
+
5055
+ The owner of the subnet must call this command to start the emission schedule.
5056
+
5057
+ Example:
5058
+ [green]$[/green] btcli subnets start --netuid 1
5059
+ [green]$[/green] btcli subnets start --netuid 1 --wallet-name alice
5060
+ """
5061
+ self.verbosity_handler(quiet, verbose)
5062
+ if not wallet_name:
5063
+ wallet_name = Prompt.ask(
5064
+ "Enter the [blue]wallet name[/blue] [dim](which you used to create the subnet)[/dim]",
5065
+ default=self.config.get("wallet_name") or defaults.wallet.name,
5066
+ )
5067
+ wallet = self.wallet_ask(
5068
+ wallet_name,
5069
+ wallet_path,
5070
+ wallet_hotkey,
5071
+ ask_for=[
5072
+ WO.NAME,
5073
+ ],
5074
+ validate=WV.WALLET,
5075
+ )
5076
+ return self._run_command(
5077
+ subnets.start_subnet(
5078
+ wallet,
5079
+ self.initialize_chain(network),
5080
+ netuid,
5081
+ prompt,
5082
+ )
5083
+ )
5084
+
4978
5085
  def subnets_get_identity(
4979
5086
  self,
4980
5087
  network: Optional[list[str]] = Options.network,
@@ -5184,10 +5291,12 @@ class CLIManager:
5184
5291
  wallet_hotkey: str = Options.wallet_hotkey,
5185
5292
  network: Optional[list[str]] = Options.network,
5186
5293
  netuid: int = Options.netuid,
5187
- era: Optional[
5294
+ period: Optional[
5188
5295
  int
5189
- ] = typer.Option( # Should not be Options.era bc this needs to be an Optional[int]
5296
+ ] = typer.Option( # Should not be Options.period bc this needs to be an Optional[int]
5190
5297
  None,
5298
+ "--period",
5299
+ "--era",
5191
5300
  help="Length (in blocks) for which the transaction should be valid. Note that it is possible that if you "
5192
5301
  "use an era for this transaction that you may pay a different fee to register than the one stated.",
5193
5302
  ),
@@ -5220,7 +5329,7 @@ class CLIManager:
5220
5329
  wallet,
5221
5330
  self.initialize_chain(network),
5222
5331
  netuid,
5223
- era,
5332
+ period,
5224
5333
  json_output,
5225
5334
  prompt,
5226
5335
  )