https://kedro.org/ logo
#questions
Title
# questions
m

Marc Gris

06/28/2023, 11:13 AM
Hi everyone, Given:
Copy code
node(pre_process, 
     inputs = ['dataset', 'params:pre_process'], 
     outputs = "pre_processed_dataset")
Kedro will pass
'params:pre_process'
as a dict to
pre_process
which results in a bit of an “opaque” function’s signature:
def pre_process(df: pd.DataFrame, params: dict): ...
Is there a “kedro way” of unpacking this dict and therefore have more “transparent” signature, with individual params specified ? Thx M
n

Nok Lam Chan

06/28/2023, 11:15 AM
If your function take multiple arguments, why not pass specific parameters instead of the whole dict?
params:pre_process.key1
,
params:pre_process.key2
m

Marc Gris

06/28/2023, 11:16 AM
I guess I was feeling lazy 😅
The function actually has, per “clean-code” standards, too many params (7)… and I wanted the node definition itself to be as “uncluttered” as possible… More serioulsy: If the function signature change, with unpacking, I only need to modify the params file. While with “explicit” / hardcoded argument passing I’ll also need to refactor the node definition…
n

Nok Lam Chan

06/28/2023, 11:21 AM
I guess what you are looking for is something like
**params:pre_process
, this is not a valid syntax
m

Marc Gris

06/28/2023, 11:37 AM
Exactly… I even “felt lucky” and gave it a shot, just in case 😉 Is the fact that it is non-valid syntax an “opinionated decision” ? Or is it simply because it hasn’t been implemented yet ?
n

Nok Lam Chan

06/28/2023, 11:43 AM
I don’t have the context when this is implemented. My gut feeling is the former. I guess this is not too hard to create a helper in your node function.
Copy code
def node_func(params):
  target_func(**params)
Did I miss a clear solution for this? Cc @Juan Luis @datajoely
👍 1
j

Juan Luis

06/28/2023, 12:03 PM
yeah my guess is that this has never come up 😄 feel free to open an issue @Marc Gris!
👍 1
m

Marc Gris

06/28/2023, 12:04 PM
Thx ! Will do 🙂
i

Iñigo Hidalgo

06/28/2023, 12:35 PM
n

Nok Lam Chan

06/28/2023, 12:36 PM
Goal for this is making it easier to map Python func -> Node when possible while not breaking anything
d

datajoely

06/28/2023, 12:38 PM
The other related version of this you can’t override
**kwargs
in modular pipelines
n

Nok Lam Chan

06/28/2023, 12:39 PM
What do you mean?