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
Issue with Root Args and config file #232
Comments
Thank you very much for reporting. I don't quite understand the description and tried to reproduce the problem but unsuccessfully. Can you please improve the reproduction section, such that:
What I tried to do was to run the code import os
from jsonargparse import ArgumentParser, ActionConfigFile
parser = ArgumentParser(default_config_files=[os.path.join('.config/config.yaml')])
parser.add_argument('-c','--config', action=ActionConfigFile,help="override config file")
parser.add_argument("-o","--output",help="Path to Dir",required=True)
prepare = ArgumentParser(description="Prepare file to be uploaded")
prepare.add_argument('-m','--media',help="Directory to retrive media files",required=True)
subcommands = parser.add_subcommands()
subcommands.add_subcommand('prepare',prepare, help="prepare mediafile for upload")
print(parser.parse_args()) using as command $ python cli.py -o . prepare --media value
Namespace(config=None, output='.', prepare=Namespace(media='value'), subcommand='prepare') It executes without issue printing the namespace. Note that I ran it in a directory that only has the |
Okay yeah here is a better description Code content
configfile content
How to Trigger/Run ErrorRaised
|
As a note changing the code to this does work ======================================== parser = ArgumentParser(default_config_files=['.config/config.yaml']) print(parser.parse_args()) ================================== I just moved the root arguments to be added last |
I created a pull request fixing the issue, see #233. Please review the changes and test the code. You can install directly from that branch by running:
|
Note that the problem is |
🐛 Bug report
An error
jsonargparse.util.ParserError: Problem in default config file "/home/main/Tools/.config/config.yaml" :: Configuration check failed :: No action for destination key "prepare.output" to check its value.
is raised when trying to parse args
To reproduce
root argument must have required=True
root argument must also come before any group arguments.
Also Note: I have been able to fix this by setting root args to be the last argument
It strange because it also can parses correctly if I set required=False
Expected behavior
Parse arguments
Environment
The text was updated successfully, but these errors were encountered: