A tip I wanted to share: You can name a node using...
# resources
c
A tip I wanted to share: You can name a node using the dunder method
__name__
instead of typing out a
str
.
Copy code
node(
func=explode_missing_values,
...
name=explode_missing_values.__name__,
)

# is equivalent to

node(
func=explode_missing_values,
...
name="explode_missing_values",
)
If you're setting the node name to be the function name, this makes it so renaming the function and the node is just one step.
K 4
๐Ÿ™๐Ÿผ 1
๐Ÿ™ 1
d
out of interest, would you like this if it was default behaviour? i.e. if not provided we do this
c
Just tried commenting out where I named the nodes and am wondering if this is default behavior already? I think it would be a good default behavior, if it's not already.
j
I think the default is
name=None
, I'm 100 % supportive of making
func.__name__
the default if not given
thanks for sharing @Chris Schopp!
d
Would this count as a breaking change?
I think itโ€™s
None
python side, but Viz may do some guesswork
j
yeah, better to proceed with care
d
my point is we canโ€™t squeeze it into 0.19.x right?
c
From what I can tell there is no difference in Kedro Viz between
name=None
and
name=func.__name__
but the logger shows a minor difference: None:
Running node: explode_missing_values([input]) -> [output]
___name___:
Running node: explode_missing_values: explode_missing_values([input]) -> [output]
d
Yeah I think the point is Viz is inferring this rather than it really being true in the Python node
๐Ÿ‘ 1
j
my point is we canโ€™t squeeze it into 0.19.x right?
I think it's safe to say we're in "feature freeze" mode atm, the release will come in a few days and we're squashing the last blockers
๐Ÿ‘ 1
d
shame - but we should put it in the next version
m
Thx @Chris Schopp Very handy indeed. And (for what my opinion is worth ๐Ÿ˜… )I will second @Juan Luis in saying that too am โ€œ_100 % supportive of making
func.__name__
the default if not given_โ€
๐Ÿ‘ 2
j
from the 0.19.0 release notes:
Anonymous nodes are given default names of the form
<function_name>([in1;in2;...]) -> [out1;out2;...]
, with the names of inputs and outputs separated by semicolons.