Hi all! I was wondering if it is possible to get ...
# questions
t
Hi all! I was wondering if it is possible to get the name of a node while running inside a node. Use case I want to use it for writing a decorator around nodes that stores statistics on data processing, and I want to pass the name of the node to that as well, such that I can create a nice dataset 🙂 Cheers, Thomas
v
Hi Thomas Did you explore kedro Hooks. They might help you to prepare statistics for each node.
t
Good point thanks! Will explore this 🙂 still curious if I can get the name of a node within a node context though
m
No and it's a bad pattern
thankyou 1
Use hooks for such things as @Vishal Pandey suggested
j
yeah node functions don't know they're being called from Kedro, they're Kedro-agnostic (it's a design decision so that they can be reused) these questions come in very often though. the answer is using hooks but @Thomas d'Hooghe let us know if that fulfills your use case
👍 1
thankyou 1
v
@Thomas d'Hooghe I can feel your curiosity. You must be feeling more powerful within nodes 🙂 . But believe me explore kedro properly and you will enjoy it . I am still trying to learn why kedro introduced each feature.
💯 1
thankyou 1
t
thanks a lot all! makes sense, thank you for the push to hooks and to good patterns 🙂
🥳 1
n
@Vishal Pandey I attempted to answer this question from a presentation before. Apologies that I never finish my half-written blog post. But I have the materials here: https://github.com/noklam/miniKedro The idea is that I try to "derive" individual feature steps by steps.
🫡 1
🙌 1
🥳 2
v
@Nok Lam Chan Thanks for sharing this beautiful piece of work. I have been looking for something like this . project like this will help someone like me who wants to start understanding kedro for open source contributions. For a better developer experience the documentation is good enough to understand any tool and start using it. But when it comes to making some contributions it is really important to understand the underlying concepts on which a tool is created. Again thanks for sharing a beautiful repo. I will find some time and go through this 😊
❤️ 2
f
Before and after node run hook have access to Node class, which holds the
func
and
name
paramter. I think that should suffice to write a logic that treats nodes differently.
🙌 3
🙌🏼 1
K 1