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

--help defaults values doesn't updated with default config files #47

Closed
stasbel opened this issue Mar 18, 2021 · 5 comments
Closed

--help defaults values doesn't updated with default config files #47

stasbel opened this issue Mar 18, 2021 · 5 comments
Labels
enhancement New feature or request

Comments

@stasbel
Copy link

stasbel commented Mar 18, 2021

Thanks for the full --help command.
Couple of small problems I have spotted so far:

  • Arguments order is sorted alphabetically (not with respect to time added). Probably related to --print_config preserve original order #46.
  • Output contains python objects info, like ... object at 0x7f3670c6dc50.
  • Default values aren't update with having default config files.
@mauvilsa
Copy link
Member

mauvilsa commented Mar 19, 2021

* Arguments order is sorted alphabetically (not with respect to time added). Probably related to #46.

In the help I do normally see them in the correct order. It depends on time added and argument groups. Each ActionParser becomes a group so all its arguments should appear together in time added order plus its argument groups. If you can confirm that the order is incorrect, please create an issue with code to reproduce it.

* Output contains python objects info, like `... object at 0x7f3670c6dc50`.

I guess this is because of the ActionParser not being given a title. If you give a title it will look okay. Later I will fix it so that if it is not given a title then nothing is shown.

* Default values aren't update with having default config files.

From what I see this does work correctly. Note that if no file matches any of the patterns in default_config_files then there is no error or warning. The test I did is the following. First create a file config.yaml with content op: from yaml. Then in the same directory run:

>>> from jsonargparse import ArgumentParser
>>> p=ArgumentParser(default_config_files=['config.yaml'])
>>> p.add_argument('--op', default='from default')
>>> p.parse_args([])
Namespace(__default_config__=Path(config.yaml, cwd=/home/***), op='from yaml')

Observe that the Namespace includes a __default_config__ entry which is a way to know which default config file was loaded.

mauvilsa added a commit that referenced this issue Mar 19, 2021
- yaml/json dump kwargs can now be changed via attributes dump_yaml_kwargs and dump_json_kwargs.
- Add argument with type Enum or type hint giving an action now raises error #45.
- Now by default dump/save/print_config preserve the add arguments and argument groups order (python>=3.6) #46.
- ActionParser group title now defaults to None if not given #47.
@mauvilsa
Copy link
Member

* Output contains python objects info, like `... object at 0x7f3670c6dc50`.

I guess this is because of the ActionParser not being given a title. If you give a title it will look okay. Later I will fix it so that if it is not given a title then nothing is shown.

This is now fixed in the current version in master.

@stasbel
Copy link
Author

stasbel commented Mar 20, 2021

Default values aren't update with having default config files.

Sorry, what I really meant is: "Default values for --help message aren't update with having default config files."

@mauvilsa
Copy link
Member

Default values aren't update with having default config files.

Sorry, what I really meant is: "Default values for --help message aren't update with having default config files."

My bad. It was clear from the issue title. This can be done.

@mauvilsa mauvilsa added the enhancement New feature or request label Mar 21, 2021
mauvilsa added a commit that referenced this issue Mar 22, 2021
… config file was loaded #47.

- get_default method now also considers default_config_files.
- get_defaults now raises ParserError if default config file not valid.
- default_config_files property not removing help group when setting None.
- Improved Path class home prefix '~' support.
@mauvilsa
Copy link
Member

In the new release v3.8.0 in the help the titles are no longer object references and the default values are updated from a default config file if present.

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

No branches or pull requests

2 participants