Peter van Heck
02/13/2024, 8:35 AMKedroSession.create() the global variables are loaded correctly, but on a second run, the global variables are not loaded. the whole settings.py is not executed.
If i'm not mistaken, the global variables are seen as 'Project Settings' and are loaded once in the lifetime of a project. When creating a new session, these are not reloaded.
Is there a way to reset/reload the global variables when creating a second session?FlorianGD
02/13/2024, 8:39 AMruntime_params (from the OmegaConfigLoader) instead of global variablesYolan Honoré-Rougé
02/13/2024, 8:39 AMFlorianGD
02/13/2024, 8:40 AMKedroSession.create as extra_paramsPeter van Heck
02/13/2024, 8:43 AMFlorianGD
02/13/2024, 8:45 AMPeter van Heck
02/13/2024, 8:47 AMSELECT * FROM Table WHERE col = ${variable} using parameters and not globals?FlorianGD
02/13/2024, 8:52 AMOmegaConfigLoader and the built-in resolver `runtime_params`https://docs.kedro.org/en/stable/configuration/advanced_configuration.html#how-to-override-configuration-with-[…]rameters-with-the-omegaconfigloader
So the query would look like
SELECT * FROM Table WHERE col = ${runtime_params:variable}
And then kedro run --params variable:my_colPeter van Heck
02/13/2024, 8:59 AM@app.get("...")
async def run_project(var: str):
params = GetFeatures(var)
with KedroSession.create(
package_name=bootstrap_project(Path.cwd()).package_name,
env=env,
extra_params=params,
) as session:
session.run(pipeline_name=pipeline)
So we pass parameters to the project, no issue. but the globals are picked from there and added to the project only once. the second time this runs, that part of the Kedro-code is not executed.FlorianGD
02/13/2024, 9:01 AMextra_params : params = {**params, "variable": "my_col"}Peter van Heck
02/13/2024, 9:51 AMValueError: Failed to format pattern '${variable}': no config value found, no default providedFlorianGD
02/13/2024, 9:52 AM${runtime_params:variable} , otherwise, it would look for an entry named variable in the yaml fileFlorianGD
02/13/2024, 9:54 AMsettings.py to use OmegaConfigLoader if you use kedro pre 0.19Nok Lam Chan
02/13/2024, 1:33 PMKedroSession.create() twice resulting in different ${globals} ?Nok Lam Chan
02/13/2024, 1:35 PMsettings are indeed loaded once when started, and bootstrap_project will reload this. However I don't think this is related to the problem that you are describing which seems to related to the config loader?
https://docs.kedro.org/en/latest/kedro_project_setup/session.html#bootstrap-project-and-configure-projectPeter van Heck
02/15/2024, 12:23 PMfrom kedro.framework.startup import bootstrap_project , after creating and before running a session, calling session.load_context() , and implement a after_context_created(self) hook that actually takes the variables and adds these to the project settings (from kedro.framework.project import settings )