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

Other ArgumentParser options are ignored when add_config_path_arg is True #239

Closed
jtbates opened this issue Apr 5, 2023 · 2 comments
Closed

Comments

@jtbates
Copy link

jtbates commented Apr 5, 2023

Describe the bug
Using the add_config_path_arg option in ArgumentParser causes other options to be ignored such as add_option_string_dash_variants, argument_generation_mode, and nested_mode.

To Reproduce

from dataclasses import dataclass, field

from simple_parsing import ArgumentParser, DashVariant
from simple_parsing.wrappers.field_wrapper import ArgumentGenerationMode, NestedMode


@dataclass
class NestedParams:
    num_units: int = 4

@dataclass
class Params:
    num_layers: int = 4
    nested: NestedParams = field(default_factory=lambda: NestedParams())


parser = ArgumentParser(
    add_config_path_arg=True,
    add_option_string_dash_variants=DashVariant.DASH,
    argument_generation_mode=ArgumentGenerationMode.NESTED,
    nested_mode=NestedMode.WITHOUT_ROOT,
)
parser.add_arguments(Params, dest="params")


args = parser.parse_args()

parser.print_help()

Expected behavior
The expected output is

usage: test_add_config_path_dash.py [-h] [--num-layers int] [--nested.num-units int]

optional arguments:
  -h, --help            show this help message and exit
  --config-path Path    Path to a config file containing default values to use. (default: None)

Params ['params']:
  Params(num_layers: int = 4, nested: __main__.NestedParams = <factory>)

  --num-layers int      (default: 4)

NestedParams ['params.nested']:
  NestedParams(num_units: int = 4)

  --nested.num-units int
                        (default: 4)

Actual behavior
The actual output is

usage: test_add_config_path_dash.py [-h] [--config_path Path] [--num_layers int] [--num_units int]

optional arguments:
  -h, --help          show this help message and exit
  --config_path Path  Path to a config file containing default values to use. (default: None)

Params ['params']:
  Params(num_layers: int = 4, nested: __main__.NestedParams = <factory>)

  --num_layers int    (default: 4)

NestedParams ['params.nested']:
  NestedParams(num_units: int = 4)

  --num_units int     (default: 4)

Desktop (please complete the following information):

  • Version: 0.1.1
  • Python version: 3.9.10
@lebrice
Copy link
Owner

lebrice commented Apr 13, 2023

Hello there @jtbates , thanks for posting this!

Wow that's a really nice bug. I'll take a look and get back to you.

@lebrice
Copy link
Owner

lebrice commented Apr 19, 2023

I think this was fixed with #248

@lebrice lebrice closed this as completed Apr 19, 2023
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

2 participants