Skip to content

Support sub-commands (sub-parsers) for PyTorch training scripts #2734

@jraman

Description

@jraman

Describe the feature you'd like
Support the use of sub-commands (sub-parsers) -- for example, sub-parsers in argparse. Sub-parsers do not have a "--" prefix, nor is a value specified for them.

For further motivation on using sub-commands, please see: https://docs.python.org/3/library/argparse.html#sub-commands

How would this feature be used? Please describe.

As an example, I would like to use it the following ways:

$ python pytorch-train.py dataset1 <argments for dataset1>
$ python pytorch-train.py dataset2 <argments for dataset2>

The argument types for the datasets are different -- for example, dataset1 requires file locations and its associated parameters (irrelevant to dataset2), and dataset2 requires urls and network related parameters (irrelevant to datset1).

Describe alternatives you've considered

I could use --datasettype dataset1 and --datasettype dataset2, but then all of the unnecessary arguments are passed to both types. Further, I want certain parameters to be required for dataset1, but not dataset2, and vice versa.

Additional context

See: https://docs.python.org/3/library/argparse.html#sub-commands for a description of sub-commands (sub-parsers).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions