-
Notifications
You must be signed in to change notification settings - Fork 122
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
Add env_str resolver built-in resolver #383
Comments
Blocked on #445. Depending on the final decision there this may not be needed. |
Maybe we can discuss here wether or not we want My suggestion: keep them as strings, and add a new default resolver ("eval"? "parse"? "resolve"? "process"? "autoconvert"? ...) that does this step. This way, one could always use |
I like it. With the possible support of consulting the annotations (#506), I think we will probably not need this in most cases anyway. |
Agreed. I'm going to adapt #445 accordingly, and add the new resolver in a different PR. Do you have a preferred name for that one? |
I was thinking to change the behavior to not parse in the existing env resolver. Edit: you are talking about the parsing resolver. Collisions are still unlikely but maybe we should use a common prefix for built in resolvers: |
Ok sounds good, will do that in another PR afterwards. |
I think it would be nice support some more formal separator for namespacing. |
Since we are planning to break compatibility here, I think the best plan is to deprecate the current env resolver while keeping it as is in terms of behavior and switch people to use oc.env which can also have a new behavior. |
Makes sense. Should I do that in #445? (it would be more convenient if I want to close #230 with it) |
let's not add anything else to 445. We can do it in a new PR closing this one (after editing this one to reflect what we are actually doing). |
* Restore and deprecate the old `env` resolver for backward compatibility with OmegaConf 2.0 * The new `oc.env` resolver keeps the string representation of environment variables, and does not use the cache * The new `oc.decode` resolver can be used to parse and evaluate strings according to the OmegaConf grammar Fixes omry#383 Fixes omry#573 Fixes omry#574
* Restore and deprecate the old `env` resolver for backward compatibility with OmegaConf 2.0 * The new `oc.env` resolver keeps the string representation of environment variables, and does not use the cache * The new `oc.decode` resolver can be used to parse and evaluate strings according to the OmegaConf grammar Fixes omry#383 Fixes omry#573 Fixes omry#574
* Restore and deprecate the old `env` resolver for backward compatibility with OmegaConf 2.0 * The new `oc.env` resolver keeps the string representation of environment variables, and does not use the cache * The new `oc.decode` resolver can be used to parse and evaluate strings according to the OmegaConf grammar Fixes omry#383 Fixes omry#573 Fixes omry#574
* Introduce new `oc.env` and `oc.decode` resolvers * Restore and deprecate the old `env` resolver for backward compatibility with OmegaConf 2.0 * The new `oc.env` resolver keeps the string representation of environment variables, does not use the cache, and accepts None as default value * The new `oc.decode` resolver can be used to parse and evaluate strings according to the OmegaConf grammar Fixes #383 Fixes #573 Fixes #574 * Allow `oc.decode` to evaluate interpolations * Improve documentation of `oc.decode` In particular it explains that dictionaries and lists are automatically converted to transient config nodes. * Update docs/source/usage.rst Co-authored-by: Omry Yadan <[email protected]> * Update news/573.api_change Co-authored-by: Omry Yadan <[email protected]> * Update omegaconf/_utils.py Co-authored-by: Omry Yadan <[email protected]> * Update omegaconf/_utils.py Co-authored-by: Omry Yadan <[email protected]> * Remove the USERID example * Show example of quoted string as default value for `oc.env` * Remove duplicated comments (# #) * Validate default value of `oc.env` even when not used * Simplify tests with recwarn * Use convenience `show()` function in doc to show type and value * Update doc on string interpolations * More readable test formatting * Improve comment formatting * Restore interpolation examples * Update docs/notebook/Tutorial.ipynb Co-authored-by: Omry Yadan <[email protected]> * Update docs/source/usage.rst Co-authored-by: Omry Yadan <[email protected]> * Update docs/source/usage.rst Co-authored-by: Omry Yadan <[email protected]> * Rephrasing in doc * Use `show()` function in doc * Raise a KeyError instead of ValidationError for missing env variables * Remove handling of "null" as default in legacy env resolver * Update news * Explicit typing for the default value of the `oc.env` resolver * Use a more appropriate exception type * Update tests/test_interpolation.py Co-authored-by: Omry Yadan <[email protected]> * Safer markers for default values * Fix coverage * Use more appropriate TypeError * Refactor: consistent use of _DEFAULT_MARKER_ Co-authored-by: Omry Yadan <[email protected]>
In some cases the automatic conversion of environment variable does not work well or is not what the user wants.
A simple fix is to add another resolver named "env_str" that would return the env string as is.
The text was updated successfully, but these errors were encountered: