| 292 | @classmethod |
| 293 | @typechecked |
| 294 | def get_parser(cls) -> config_argparse.ArgumentParser: |
| 295 | class ArgumentDefaultsRawTextHelpFormatter( |
| 296 | argparse.RawTextHelpFormatter, |
| 297 | argparse.ArgumentDefaultsHelpFormatter, |
| 298 | ): |
| 299 | pass |
| 300 | |
| 301 | parser = config_argparse.ArgumentParser( |
| 302 | description="base parser", |
| 303 | formatter_class=ArgumentDefaultsRawTextHelpFormatter, |
| 304 | ) |
| 305 | |
| 306 | # NOTE(kamo): Use '_' instead of '-' to avoid confusion. |
| 307 | # I think '-' looks really confusing if it's written in yaml. |
| 308 | |
| 309 | # NOTE(kamo): add_arguments(..., required=True) can't be used |
| 310 | # to provide --print_config mode. Instead of it, do as |
| 311 | parser.set_defaults(required=["output_dir"]) |
| 312 | |
| 313 | group = parser.add_argument_group("Common configuration") |
| 314 | |
| 315 | group.add_argument( |
| 316 | "--print_config", |
| 317 | action="store_true", |
| 318 | help="Print the config file and exit", |
| 319 | ) |
| 320 | group.add_argument( |
| 321 | "--log_level", |
| 322 | type=lambda x: x.upper(), |
| 323 | default="INFO", |
| 324 | choices=("ERROR", "WARNING", "INFO", "DEBUG", "NOTSET"), |
| 325 | help="The verbose level of logging", |
| 326 | ) |
| 327 | group.add_argument( |
| 328 | "--drop_last_iter", |
| 329 | type=str2bool, |
| 330 | default=False, |
| 331 | help="Exclude the minibatch with leftovers.", |
| 332 | ) |
| 333 | group.add_argument( |
| 334 | "--dry_run", |
| 335 | type=str2bool, |
| 336 | default=False, |
| 337 | help="Perform process without training", |
| 338 | ) |
| 339 | group.add_argument( |
| 340 | "--iterator_type", |
| 341 | type=str, |
| 342 | choices=["sequence", "category", "chunk", "task", "none"], |
| 343 | default="sequence", |
| 344 | help="Specify iterator type", |
| 345 | ) |
| 346 | group.add_argument( |
| 347 | "--valid_iterator_type", |
| 348 | type=str, |
| 349 | choices=["sequence", "category", "chunk", "task", "none"], |
| 350 | default=None, |
| 351 | help="Specify iterator type", |