-
Notifications
You must be signed in to change notification settings - Fork 903
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
Improve TemplatedConfigLoader
- Default ${KEDRO_ENV}
global & expose anyconfig.load
kwargs
#1438
Conversation
Signed-off-by: datajoely <joel.schwarzmann@quantumblack.com>
Signed-off-by: datajoely <joel.schwarzmann@quantumblack.com>
Signed-off-by: datajoely <joel.schwarzmann@quantumblack.com>
…ated-config-loader Signed-off-by: datajoely <joel.schwarzmann@quantumblack.com>
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.
Just some minor comments on the code, let me comment on the higher level idea here separately...
I have mixed thoughts on this. I totally understand the need for both these features and think both your solutions are improvements on our current state. The question in my mind is whether they would fit in well with the ultimate solution to #891 and what a realistic timeframe for that ultimate solution would be. e.g. I wouldn't want everyone to start using 1. Automatically the config environment as a ${KEDRO_ENV}Isn't this the github issue that tracks it? #1411. I suggested two current workarounds, but building this into the 2. Allowing the user to define arbitrary arguments to anyconfig.loadThis is basically what I suggested in #1011 and so obviously I like it 😀 Looking at it again I'm not sure it's right to expose
This is a bit more effort for users than being able to specify |
I'll save these for the next backlog grooming - but regarding the exposed |
Yeah, that makes sense, but I think it's still possible without altering the signature of
I like the idea of generalising to |
Okay I'm sold - will update to match shortly |
Signed-off-by: datajoely <joel.schwarzmann@quantumblack.com>
…ated-config-loader Signed-off-by: datajoely <joel.schwarzmann@quantumblack.com>
Signed-off-by: datajoely <joel.schwarzmann@quantumblack.com>
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.
Hmm, on second thoughts this won't work quite right following my suggestion, sorry... Because self._anyconfig_args
is already used in L127 of TemplatedConfigLoader.__init__
, if you do this:
class MyTemplatedConfigLoader(TemplatedConfigLoader):
def __init__(*args, **kwargs):
super().__init__(*args, **kwargs)
self._anyconfig_args = {"Loader": yaml.UnsafeLoader}
then self._anyconfig_args
only gets overwritten after it's used on L127.
I don't know if this really matters since, as I understand it, this is not the main important call to _get_config_from_patterns
(that is in conf_paths
). But if it does matter we might need to do something with properties to make this work properly.
Either way, these are implementation details, and my general comments still stand (general approval of at least idea 2). Would be good to hear what other people think about it before we spend longer figuring out the right implementation.
Co-authored-by: Antony Milne <49395058+AntonyMilneQB@users.noreply.github.com>
Signed-off-by: datajoely <joel.schwarzmann@quantumblack.com>
TemplatedConfigLoader
to include environment & accept arbitrary anyconfig.load
arguments TemplatedConfigLoader
- Default ${KEDRO_ENV}
global & expose anyconfig.load
kwargs
Signed-off-by: datajoely <joel.schwarzmann@quantumblack.com>
I've also added a fix to an regression raised by @sheldontsen-qb where the self._config_mapping = (
_get_config_from_patterns(
conf_paths=self.conf_paths,
patterns=list(globals_pattern), # <---------
ac_template=False,
)
if globals_pattern
else {}
) This gets exploded into in this: |
Noticing the jinja2 and passing any extra
Notice we just dump everything in
Not sure how this would change in Notice we're catching warnings and raising them as errors - because Regarding the comment of including Note it is possible to build it in a way that you can support both, but you'd need to properly document which comes first (jinja2 first resolves then globals) but I think it would be messy to see both kinds of syntax. Hence the preference to keep them separate. However, it is possible to build this in a backwards compatible way so one can slowly transition away from Just sharing my two cents! |
@sheldontsen-qb great spot with the bug report 😬 I'll add this to #1437. @datajoely I'm not sure that's the right fix. In 0.17.7 (and I guess always before that) we had |
Signed-off-by: datajoely <joel.schwarzmann@quantumblack.com>
…hub.com/quantumblacklabs/kedro into feature/improve-templated-config-loader Signed-off-by: datajoely <joel.schwarzmann@quantumblack.com>
Signed-off-by: datajoely <joel.schwarzmann@quantumblack.com>
Signed-off-by: datajoely <joel.schwarzmann@quantumblack.com>
…hub.com/quantumblacklabs/kedro into feature/improve-templated-config-loader Signed-off-by: datajoely <joel.schwarzmann@quantumblack.com>
@AntonyMilneQB good point - I've tweaked it so the signature is maintained. @sheldontsen-qb 100% agree on the Jinja / templated syntax workflow distinction. I'm in favour of introducing this tweak purely because enough open source users keep asking for this and it makes sense as a stop-gap solution until we introduce the complete config overhaul via #891 . |
After discussion with core team - will close this PR and raise a couple of issues |
FOR DISCUSSION
Description
This is a culmination of several things I've seen users struggle with, both related to
TemplatedConfigLoader
.1. Automatically scope the config environment as a
${KEDRO_ENV}
Since 0.18.x it is no longer possible to neatly pass the current configuration environment to the
TemplatedConfigLoader
. This used to be possible via theregister_config_loader
hook that had theenv
argument in scope and was thus easy to pass into scope. @pascalwhoop has raised this internally, but we have no GH issue associated with it yet.2. Allowing the user to define arbitrary arguments to
anyconfig.load
We currently leverage
anyconfig.load
to open our configuration files, theac_template
argument was exposed in 0.17.0, but there are other arguments available as per the anyconfig API docs. I see no reason not to expose this in a generic way allowing the user to alter the behaviour to their choosing.Development notes
To make this possible I've changed:
ac_template
parameter that's passed down in several places to a dictionary that contains this (and in theory any other arguments) to be passed toanyconfig.load
.env
argument is added automatically toself._config_mapping
within the constructor.Checklist
RELEASE.md
file