Pytorch-lightning: Support Trainer.add_argparse_args for ArgumentGroup

Created on 20 Aug 2020  路  5Comments  路  Source: PyTorchLightning/pytorch-lightning

馃殌 Feature

Support Trainer.add_argparse_args for argparse._ArgumentGroup

Motivation

Adding all of the Trainers args to an existing parser clutters its help message with many arguments. Ideally, I would like to have these in a separate argument group.

Pitch


Currently:

parser = argparse.ArgumentParser()
parser.add_argument("--my_arg")
parser = pl.Trainer.add_argparse_args(parser)
parser.print_help()
usage: script.py [-h] [--my_arg MY_ARG] [--logger [LOGGER]] [--checkpoint_callback [CHECKPOINT_CALLBACK]] [--early_stop_callback [EARLY_STOP_CALLBACK]] [--default_root_dir DEFAULT_ROOT_DIR] [--gradient_clip_val GRADIENT_CLIP_VAL] (... and many more)

optional arguments:
  -h, --help            show this help message and exit
  --my_arg MY_ARG
  --logger [LOGGER]     autogenerated by pl.Trainer
  --checkpoint_callback [CHECKPOINT_CALLBACK]
                        autogenerated by pl.Trainer
  --early_stop_callback [EARLY_STOP_CALLBACK]
                        autogenerated by pl.Trainer
  --default_root_dir DEFAULT_ROOT_DIR
                        autogenerated by pl.Trainer
  --gradient_clip_val GRADIENT_CLIP_VAL
                        autogenerated by pl.Trainer
  (... and many more)



md5-624429db3b4fd8a179f6c448049475b4



```bash
usage: script.py [-h] [--my_arg MY_ARG] [--logger [LOGGER]] [--checkpoint_callback [CHECKPOINT_CALLBACK]] [--early_stop_callback [EARLY_STOP_CALLBACK]] [--default_root_dir DEFAULT_ROOT_DIR] [--gradient_clip_val GRADIENT_CLIP_VAL] (... and many more)

optional arguments:
  -h, --help            show this help message and exit
  --my_arg MY_ARG

pytorch-lightning Trainer arguments:
  --logger [LOGGER]     autogenerated by pl.Trainer
  --checkpoint_callback [CHECKPOINT_CALLBACK]
                        autogenerated by pl.Trainer
  --early_stop_callback [EARLY_STOP_CALLBACK]
                        autogenerated by pl.Trainer
  --default_root_dir DEFAULT_ROOT_DIR
                        autogenerated by pl.Trainer
  --gradient_clip_val GRADIENT_CLIP_VAL
                        autogenerated by pl.Trainer
  (... and many more)
discussion enhancement help wanted won't fix

Most helpful comment

@ananyahjha93 this will be encapsulated by it for sure.

@carmocca feature like this is coming! We are rethinking how it all should look. Thanks for the thoughtful feature request 馃槃

All 5 comments

Hi! thanks for your contribution!, great first issue!

@nateraw include this in your thing

@ananyahjha93 this will be encapsulated by it for sure.

@carmocca feature like this is coming! We are rethinking how it all should look. Thanks for the thoughtful feature request 馃槃

@nateraw update on your decision here

Closing this issue. I am using jsonargparse now, given it fits exactly my needs as demonstrated in #4492.

Also, there are several issues on this matter, closing this one so there is one less place to follow.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maxime-louis picture maxime-louis  路  3Comments

iakremnev picture iakremnev  路  3Comments

anthonytec2 picture anthonytec2  路  3Comments

justusschock picture justusschock  路  3Comments

edenlightning picture edenlightning  路  3Comments