-
Notifications
You must be signed in to change notification settings - Fork 905
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
OmegaConfigLoader does not follow ConfigLoader get() spec. #3092
Comments
Hi @antheas , thank you for flagging this! Have you tried the solution using |
Hi, @merelcht It also doesn't solve for loading custom files. I'll be staying on |
@antheas great point. However get is never an API of the Abstract config loader. OmegaConfigLoader follow the spec of the Abstract class but not subclassing ConfigLoader https://github.com/kedro-org/kedro/blob/main/kedro/config/abstract_config.py The config pattern is in the OmegaConfigLoader signature, you can set defaults if you need to distribute it in library. It may be benefit to still have a similar get API and PRs and discussion are welcomed! |
@noklam My issue is more to the fact that As for the points you raise, I looked at the So there is a conflict there. Either
Unfortunately that's not true, The new spec I suggested follows the pythonic way of calling
I think it's preferable for the users of a library to be able to choose their own config loader. Nevertheless that's true. Of course, a discussion is welcome. |
Thanks @antheas, all solid comments and many useful insight.
Checking with my understanding, the former you are referring to
I am not sure if I understand this, can you show me an example how are you doing it currently and why do you need this? On the other hand, I am quite interested the use of these library component outside of the framework. How are you using it is it mainly in a notebook for interactive use case? Thank you🙏🏼.
Agree, probably an oversight that we should update. kedro/kedro/framework/context/context.py Lines 244 to 253 in 319a8e7
|
Would you be able to expand on that a bit more @antheas ? How is To be fully transparent, we have put a lot of work in making |
Sure. So for context the library I'm developing is this: https://github.com/pasteur-dev/pasteur Which is an early research prototype Early on in development I had a dependency on kedro-mlflow, but as the project developed I dropped it because I developed custom behavior for mlflow. I still depend on the mlflow configs from the previous project though, so in my code I have the following line: conf_mlflow_yml = context.config_loader.get("mlflow*", "mlflow*/**") It can be found here. I agree that this line is not ideal, as the user can not override the paths. However, with the new The solution I came up is this, which is not pretty: if 'Omega' in str(type(context.config_loader)):
if 'mlflow' not in context.config_loader.config_patterns:
context.config_loader.config_patterns['mlflow'] = ["mlflow*", "mlflow*/**"]
conf_mlflow_yml = context.config_loader.get("mlflow")
else:
conf_mlflow_yml = context.config_loader.get("mlflow*", "mlflow*/**") My library allows users to package their datasets and dataset permutations (as Views) and distribute them with other users. An example of this is found in the directories pasteur.extras.datasets and pasteur.extras.views. The datasets package yml catalogs with them and the views parameter ymls with hyperparameters. Since catalog yml files use a simpler format without the However, for the parameters I'm relying on the kedro config loader, which requires me to be able to load a file from disk through it by specifying the direct path of the file. I will admit that due to the way the code is written in the previous config loaders (ie a hack), when calling It would be nice to have omega loader to be able to load files from file paths, so I won't have to move to a custom solution and maybe integrate some |
Right I see what you mean. I've had a look at
I guess the main difference is that all config loaders are treated the same there, so no special check for |
Oh, I did not notice that patterns = getattr(context.config_loader, "config_patterns", {})
if 'mlflow' not in patterns:
patterns['mlflow'] = ["mlflow*", "mlflow*/**"]
conf_mlflow_yml = context.config_loader.get("mlflow")
Using a stable parameters parser instead of the ConfigLoader could be a solution to my other issue as well. So for now I will go with those two. I will leave the issue open for discussion. You may close it in the future. |
Closing this as there hasn't been any more activity recently. |
Description
The new OmegaConfigLoader does not follow the get() spec of the ConfigLoader and TemplatedConfigLoader and does not provide an alternative for loading custom config files or extending the file paths easily.
The spec is the following.
The format of this get() function allows passing in file locations to load specific files from disk using the config loader of the project as well as custom patterns.
This forces hacks like the following for using custom patterns that can be overridden by the user:
And loading custom files is impossible, since the OmegaConfigLoader is hardcoded to load from directory + pattern combinations. Ex. a variation of
config_loader.get("/home/user/abc.yml")
is impossible currently.I package config files (catalog.yml and parameter.yml) as parts of modules so that they can be distributed to other projects and load them using paths. As it currently stands, when a Kedro project uses an OmegaConfigLoader I can not load them.
Not being able to use globals was another issue but I see that it has been fixed in the latest version.
Possible Solution
Restore the old get syntax with a deprecation warning when get() is called with multiple strings. Add a new format for loading patterns with a fallback and one for loading files. Example:
The above spec should be supported by all config loaders, which should be easy enough as it's a variation of the existing get spec.
It will make the following possible while not being ambiguous and remaining extendable.
pip show kedro
orkedro -V
): 0.18.13The text was updated successfully, but these errors were encountered: