Skip to content

Commit

Permalink
[Revolution] Fix overview (#1509)
Browse files Browse the repository at this point in the history
* fix overview pickling

* undo hacky fix

* change subcmd help check. make required

* fix indents with return

* more explicit if/else
  • Loading branch information
camfairchild authored Sep 1, 2023
1 parent cac6e5a commit 4f3efb0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
19 changes: 9 additions & 10 deletions bittensor/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def __create_parser__() -> "argparse.ArgumentParser":
help=command["help"],
)
subparser = subcmd_parser.add_subparsers(
help=command["help"], dest="subcommand"
help=command["help"], dest="subcommand", required=True
)

for subcommand in command["commands"].values():
Expand Down Expand Up @@ -241,19 +241,18 @@ def check_config(config: "bittensor.config"):
command_data = COMMANDS[command]

if isinstance(command_data, dict):
if config["subcommand"] == None:
# This probably isn't the best solution, refactor
for action in config["__parser"]._subparsers._actions:
if action.dest == "command" and action.choices[command]:
action.choices[command].print_help()
sys.exit()

command_data["commands"][config["subcommand"]].check_config(config)
if config["subcommand"] != None:
command_data["commands"][config["subcommand"]].check_config(config)
else:
console.print(
f":cross_mark:[red]Missing subcommand for: {config.command}[/red]"
)
sys.exit(1)
else:
command_data.check_config(config)
else:
console.print(f":cross_mark:[red]Unknown command: {config.command}[/red]")
sys.exit()
sys.exit(1)

def run(self):
"""
Expand Down
1 change: 0 additions & 1 deletion bittensor/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ def __init__(
params = config.__parse_args__(args=args, parser=parser, strict=strict)

_config = self
_config["__parser"] = parser

# Splits params and add to config
config.__split_params__(params=params, _config=_config)
Expand Down

0 comments on commit 4f3efb0

Please sign in to comment.