Hugo Evers
01/11/2024, 12:53 PMkedro run --env=aws_batch
but on other envs?
I am looking at implementing a mechanism for this in the settings.py, but i dont know how to modify the active hooks in the config loader class, the registered hooks dont seem to be accessible there.datajoely
01/11/2024, 12:54 PMKEDRO_ENV
environment variable way of setting envs and pick that up in the hook?Hugo Evers
01/11/2024, 12:55 PMHugo Evers
01/11/2024, 12:56 PMHugo Evers
01/11/2024, 12:57 PMHugo Evers
01/11/2024, 12:58 PMdatajoely
01/11/2024, 12:58 PMdatajoely
01/11/2024, 12:58 PMHugo Evers
01/11/2024, 12:59 PMHugo Evers
01/11/2024, 1:00 PMdatajoely
01/11/2024, 1:00 PMdatajoely
01/11/2024, 1:00 PMkedro-telemetry
works as a super simple plugin which can be disabled that wayHugo Evers
01/11/2024, 1:01 PMHugo Evers
01/11/2024, 1:01 PMdatajoely
01/11/2024, 1:03 PMHugo Evers
01/11/2024, 3:26 PMdef run(
tag,
env,
runner,
is_async,
node_names,
to_nodes,
from_nodes,
from_inputs,
to_outputs,
load_version,
pipeline,
config,
conf_source,
params,
):
....
with KedroSession.create(env=env, extra_params=params) as session:
context = session.load_context()
runner_instance = _instantiate_runner(runner, is_async, context)
session._hook_manager.unregister() #<--------- Here we can unregister
session.run(
tags=tag,
runner=runner_instance,
node_names=node_names,
from_nodes=from_nodes,
to_nodes=to_nodes,
from_inputs=from_inputs,
to_outputs=to_outputs,
load_versions=load_version,
pipeline_name=PIPELINE_NAME,
)
Hugo Evers
01/11/2024, 3:29 PMunregister
which hooks in the settings.py file, and have a very minimal function in the CLI.py that executes this.Hugo Evers
01/11/2024, 3:31 PMrun
method of the CLI, that would be the most kedro-nic implementation right?datajoely
01/11/2024, 3:54 PMHugo Evers
01/11/2024, 3:56 PMdatajoely
01/11/2024, 3:58 PMdatajoely
01/11/2024, 3:58 PMHugo Evers
01/11/2024, 3:59 PMNok Lam Chan
01/11/2024, 5:20 PMHugo Evers
01/11/2024, 5:28 PMrun_args = extract_function_params(run, locals())
for hook in context.config_loader.disable_hooks(run_args):
session._hook_manager.unregister(name=hook._name_)
where
def extract_function_params(func, local_vars):
"""
Extracts the parameters of a given function based on its signature.
Returns a copy of these parameters to ensure immutability.
"""
param_names = func.callback.__code__.co_varnames[
: func.callback.__code__.co_argcount
]
return {
param: copy.deepcopy(local_vars[param])
for param in param_names
if param in local_vars
}
and in settings.py
class OmegaConfigLoader(OmegaConfigLoader):
def __init__(self, *args, **kwargs):
kwargs["runtime_params"] = kwargs.get("runtime_params")
super().__init__(*args, **kwargs)
def disable_hooks(self, run_params: dict) -> list:
"""run_params are:
tag,
env,
runner,
is_async,
node_names,
to_nodes,
from_nodes,
from_inputs,
to_outputs,
load_version,
pipeline,
config,
conf_source,
params
"""
disabled_hooks = []
if run_params["env"] != "aws_batch":
disabled_hooks.append(ErrorAnalysisHook)
return disabled_hooks
Hugo Evers
01/15/2024, 5:08 PMdatajoely
01/15/2024, 6:06 PMdatajoely
01/15/2024, 6:07 PMdatajoely
01/15/2024, 6:07 PM