Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable Help Text #27

Open
siddk opened this issue May 26, 2023 · 0 comments
Open

Configurable Help Text #27

siddk opened this issue May 26, 2023 · 0 comments

Comments

@siddk
Copy link

siddk commented May 26, 2023

This is an awesome project! One small enhancement - it would be really nice to support "configurable" population orders for help text beyond the default (look for docstring above argument, then below, then inline).

A common pattern for many codebases I'm working with ends up looking like:

@dataclass
class Config:
    # fmt: off
    mode: str = "train"                         # Mode in < train | evaluate | visualize >

    # Data / Preprocessing Parameters
    data: Path = Path("data/")                  # Path to data directory with MNIST images / labels
    download: bool = True                       # Whether to download MNIST data (if doesn't already exist)

    # Model Parameters
    hidden_dim: int = 256                       # Hidden Layer Dimensionality for 2-Layer MLP
    # fmt: on


@pyrallis.wrap()
def main(cfg: Config) -> None:
    print(cfg)

Because of style directives (fmt: off) and "factored" configuration arguments, the help text ends up populated as:

usage: main.py [-h] [--config_path str] [--mode str] [--data str] [--download str] [--hidden_dim str]

optional arguments:
  -h, --help         show this help message and exit
  --config_path str  Path for a config file to parse with pyrallis

Config:

  --mode str         fmt: off
  --data str         Data / Preprocessing Parameters
  --download str     Whether to download MNIST data (if doesn't already exist)
  --hidden_dim str   Model Parameters

Notably the mode and data and hidden_dim parameters are all populated incorrectly, when ideally they'd be populated inline (e.g. `mode --> "Mode in < train | evaluate | visualize >").

Happy to PR with a fix if that would be easy! I think we just need to pass an additional argument to the initializer in dataclass_wrapper.py!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant