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
Docs: add notes on command line quoting #1844
Conversation
I suspect |
$ python my_app.py +foo="{a: 10}" # the string `+foo={a: 10}` is passed to Hydra by bash | ||
foo: | ||
a: 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be confusing. since we recommend quote key=value pare in single quote, maybe update this to
python my_app.py '+foo={a: 10}'
if we update the example like above, we can probably skip the comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated in d300016.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Jasha10 for updating the doc!
This is one of the most common questions we get - here is a list of tips from Omry (copy pasted from discussions before), could you also include them in the doc?
- quote the whole key=value pair with a single quote (this quote is for the benefit of the shell).
- do not quote keys.
- only quote values if they contain a space (it will work if you always quote values, but it will turn numbers into strings)
- when you are quoting values, use double quotes to avoid collision with the outer single quoted consumed by the shell.
Rebased to incorporate recent CI fixes on the |
Updated in df625f8. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you've squashed the 1.1 update into this also.
In general it's probably best to cherry-pick a separate commit to the 1.1 branch
example above). | ||
- When you are quoting values, use double quotes to avoid collision with the | ||
outer single quoted consumed by the shell. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are good basic rules that should cater for almost all cases.
BTW double quoting in the shell is more general than single quoting, as you can specify any character through the use of escapes (you can't have literal single quotes within single quoted args for example). But I wouldn't bother mentioning that in the doc as it's shell specific
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lg! thanks @Jasha10 !
This PR adds two notes to the documentation on command-line overrides.
Related to #1843.