Afaque Ahmad
05/17/2023, 3:41 AM0.16.6 and using the load_context to get params , "credentials*", "credentials*/**" . We're upgrading Kedro to 0.18.8 and it seems load_context is no more accessible. How can I replicate the same functionality in the Kedro 0.18.8?marrrcin
05/17/2023, 7:12 AMafter_context_createdJuan Luis
05/17/2023, 9:11 AMJuan Luis
05/17/2023, 9:18 AMkedro.context.load_context I believe 👍🏼 which was later moved to kedro.framework.context.load_context and then removed in 0.18.0Juan Luis
05/17/2023, 9:31 AMKedroSession.load_context method @Afaque Ahmad. as @marrrcin says, you can hook into the after_context_created , which gets passed an instance of the KedroContext . for more information on how to use Hooks, see https://docs.kedro.org/en/stable/hooks/introduction.htmlJuan Luis
05/17/2023, 9:31 AMAfaque Ahmad
05/17/2023, 10:25 AMparameters and credentials in a script, so after_context_created may not be what I'm looking for. I'll try to create a KedroSession and access load_context from there to get the parameters and credentials .Juan Luis
05/17/2023, 10:32 AMKedroSession will give you what you need, but I could be wrong. how are you using the script? is it something you call as part of a node?Afaque Ahmad
05/17/2023, 10:41 AMMLFlowClient . This is one example, its being used for many other purposes also. An example below:
project_root = _def_get_parent_dir()
# Load kedro context in order to reuse parameters
context = load_context(project_root)
tracking_uri = context.params.get("mlflow_tracking_uri")
registry_uri = context.params.get("mlflow_registry_uri")
credentials = context.config_loader.get("credentials*", "credentials*/**")
mlflow_creds = credentials.get("mlflow")
client = MlflowClient(tracking_uri=tracking_uri, registry_uri=registry_uri)Juan Luis
05/17/2023, 10:53 AMKedroSessionmarrrcin
05/17/2023, 3:22 PMkedro-mlflow ? It’s a great, production tested plugin @Afaque AhmadYolan Honoré-Rougé
05/17/2023, 8:30 PMkedro-mlflow (which does something very similar to what you are trying to achieve), it is worth checking the code to see how this is handled: The idea is to store what you need through a hook https://github.com/Galileo-Galilei/kedro-mlflow/blob/845ad919c9dbd020e948e8adc2e0f9064de1ef68/kedro_mlflow/framework/hooks/mlflow_hook.py#L38 and then retrieve through session.context attribute. Check this line to see how the context is modified by the hook and theses discussions (1, 2, 3) to understand why and how things were modified along kedro versions updates.
If you have the kedro-mlflow plugin installed, you can access the client through context.mlflow.server._mlflow_client .Afaque Ahmad
05/18/2023, 2:01 AM