-
Notifications
You must be signed in to change notification settings - Fork 910
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
Allow users to pass credentials through environment variables #2178
Conversation
Signed-off-by: Jannic Holzer <jannic.holzer@quantumblack.com>
Signed-off-by: Jannic Holzer <jannic.holzer@quantumblack.com>
Signed-off-by: Jannic Holzer <jannic.holzer@quantumblack.com>
Signed-off-by: Jannic Holzer <jannic.holzer@quantumblack.com>
Signed-off-by: Jannic Holzer <jannic.holzer@quantumblack.com>
…er if it was not registered Signed-off-by: Jannic Holzer <jannic.holzer@quantumblack.com>
Signed-off-by: Jannic Holzer <jannic.holzer@quantumblack.com>
Signed-off-by: Jannic Holzer <jannic.holzer@quantumblack.com>
8a1bd5f
to
fc7f81e
Compare
Signed-off-by: Jannic Holzer <jannic.holzer@quantumblack.com>
…entials' Signed-off-by: Jannic Holzer <jannic.holzer@quantumblack.com>
…:kedro-org/kedro into feat/allow-credentials-via-env-variables Signed-off-by: Jannic Holzer <jannic.holzer@quantumblack.com>
Signed-off-by: Jannic Holzer <jannic.holzer@quantumblack.com>
…ontrol flow variable Signed-off-by: Jannic Holzer <jannic.holzer@quantumblack.com>
Signed-off-by: Jannic Holzer <jannic.holzer@quantumblack.com>
Stupid question... why can't we just leave Just a quick comment on naming also: I think @idanov previously suggested that we might drop the |
Exactly, ideally we'd only load credentials in this way.
Thanks for passing it on, I'll have a chat with him as I would personally be for keeping it. |
Signed-off-by: Jannic Holzer <jannic.holzer@quantumblack.com>
so happy this is coming! |
config {Dict[str, Any]} -- The configuration dictionary to resolve. | ||
""" | ||
if not OmegaConf.has_resolver("oc.env"): | ||
OmegaConf.register_new_resolver("oc.env", oc.env) |
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.
Maybe we can drop the oc.
or simply support both env
and oc.env
?
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.
Do you mean drop the "oc." in:
- name of the resolver (first argument to
register_new_resolver
)
or in: - the name assigned to
omegaconf.resolvers.oc.env
(second argument toregister_new_resolver
)?
I personally wouldn't drop the oc.
from 1., since this is the name assigned to the resolver by OmegaConf
when it is instantiated. For 2. I would be ok with losing the namespace from the import: from omegaconf.resolvers.oc import env
.
if not OmegaConf.has_resolver("oc.env"): | ||
OmegaConf.register_new_resolver("oc.env", oc.env) | ||
OmegaConf.resolve(config) | ||
OmegaConf.clear_resolver("oc.env") |
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.
It would have been nice if OmegaConf
did not rely on global state...
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.
This looks great! I'm so excited for this functionality to be added 🤩
ab9784a
to
7e6727f
Compare
Description
Resolves #1909.
Development notes
OmegaConf
resolvesDictConfig
objects on read. In the following example (where credentials.yml contains environment variable grammar such as"key": "${oc.env:TEST_KEY}"
), theoc.env
resolver would have to be registered, or line 3 will raise anUnsupportedInterpolationType
exception.However, the scope of the issue is to keep the
oc.env
resolver switched off. The way around this is to useOmegaConf.resolve
, which resolvesDictConfig
objects in-place when these objects are created, using theoc.env
resolver. This is done in the_resolve_environment_variables
method.Includes four automated tests:
credentials
is used as a key.credentials
is not used as a key.oc.env
resolver is not registered after environment variables are read if it was not registered beforehand.oc.env
resolver remains registered after environment variables are read if it was registered beforehand.Checklist
RELEASE.md
file