Jeraime Griffith
07/18/2024, 9:14 AMdef simulation(
weighted: bool,
k: int,
num_tries: int,
mapping: Dict[str, str],
*dataframes: pl.DataFrame
) -> pl.DataFrame:
node(
func = simulation,
inputs = [
"params:weighted",
"params:k",
"params:number_of_tries",
"params:mapping",
"*dataframes" <------- how would this be defined?
],
datajoely
07/18/2024, 9:39 AMJeraime Griffith
07/18/2024, 9:42 AMNok Lam Chan
07/18/2024, 12:47 PMNok Lam Chan
07/18/2024, 12:48 PMJeraime Griffith
07/18/2024, 1:10 PMJeraime Griffith
07/18/2024, 1:11 PMNok Lam Chan
07/18/2024, 1:12 PMNok Lam Chan
07/18/2024, 1:15 PMdef foo(*args):
...
Your node can take
node(func=foo, inputs=["data_a","data_b","data_c"],...)
or
node(func=foo, inputs=["data_a"], ...)
Jeraime Griffith
07/18/2024, 4:22 PMNok Lam Chan
07/18/2024, 4:24 PMdef foo(a,b, *args):
...
it's valid to pass in foo(1,2,3,4,5,6), where 3,4,5,6 will passed to *args
Nok Lam Chan
07/18/2024, 4:27 PMreturn self._func(*(inputs[item] for item in node_inputs))
Nok Lam Chan
07/18/2024, 4:38 PMso nodes can accept both positional and arbitrary argumentsIn fact the most common case of
node
is using the positional arguments, https://docs.kedro.org/en/stable/nodes_and_pipelines/nodes.html#syntax-for-input-variables I see that our docs didn't explicit mention *args
, but it has been possible for years.
I am opening a PR to add this now