-
Notifications
You must be signed in to change notification settings - Fork 906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create line magic to debug a node in notebook workflow #3510
create line magic to debug a node in notebook workflow #3510
Conversation
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
…flow' of github.com:kedro-org/kedro into 2009-create-line-magic-to-debug-a-node-in-notebook-workflow
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Left to do:
|
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Tech Design outcome - Actions to get this PR completed:
Other blocking actions:
Including the function definition will mean:
|
I flagged an issue about manipulating |
* Simplify mocking Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com> * Check node func names Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com> * Naive fix for return statements Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com> * Handle nested case Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com> * Change pipelines fixture type Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com> * Remove unnecessary TODO Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com> * Revert "Check node func names" This reverts commit 63ee194. Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com> * Replace commented return statements with a display() statement Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com> * Add warning about node name when node not found Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com> * Add line about debugging inputs in catalog Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com> * Lint Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com> * Change wording Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com> * Revert "Replace commented return statements with a display() statement" This reverts commit ad63afc. Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com> * Revert "Naive fix for return statements" This reverts commit 04c022e. Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com> * Update tests Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com> --------- Signed-off-by: Ahdra Merali <ahdra.merali@quantumblack.com>
5d3b898
to
78ff496
Compare
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
I made a few changes. The original approach would have a nicer UX that allow user to run line by line, however, there are many edge cases that we need to deal with, and this is not the best time to do it. I've taken @marrrcin advice to copy the function definition and make a separate call instead, so it would create 4 cells in a Notebook.
In addition, I notice things like lambda function is not working, it may also run into edge cases with *args, **kwargs. I have decided to tackle this later. Let's release the feature and find it out. Most edge cases are easy to fixed by the user, so I am not too worry about it. On the other hand, the current test setup is quite painful to work with. I created #3585 which I plan to tackled after this is merged. I will freeze any new changes to this PR, any additional comments will be fixed in a new PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried it again and it works great! I think @marrrcin 's suggestion is a real improvement 👍 I'm very excited to see this go in 😄
RELEASE.md
Outdated
@@ -1,6 +1,7 @@ | |||
# Upcoming Release 0.19.3 | |||
|
|||
## Major features and improvements | |||
* Create the debugging line magic `%load_node` for Jupyter Notebook/IPython. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works for ipython
now as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not yet, I've revised
kedro/ipython/__init__.py
Outdated
) | ||
def magic_load_node(node: str) -> None: | ||
"""The line magic %load_node <node_name> | ||
Currently it only support Jupyter Notebook (>7.0) and Jupyter Lab. This line magic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently it only support Jupyter Notebook (>7.0) and Jupyter Lab. This line magic | |
Currently it only supports Jupyter Notebook (>7.0) and Jupyter Lab. This line magic |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excited to see this feature released soon! 💯
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
…flow' of github.com:kedro-org/kedro into 2009-create-line-magic-to-debug-a-node-in-notebook-workflow Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
…flow' of github.com:kedro-org/kedro into 2009-create-line-magic-to-debug-a-node-in-notebook-workflow Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
except ValueError: | ||
continue | ||
# If reached the node was not found in the project | ||
raise ValueError( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we want to support func_name
at some point too? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was briefly discussed in last TD. @AhdraMeraliQB originally have an implementation.
It runs into issue if function is used twice, nodes are unique but functions do not have to. Fundamentally we want to fix this with the default node name but this was decided to be fixed later.
@AhdraMeraliQB I can't find your original PR/commit, feel free to supplement
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really good reasoning, perhaps we could support full classpath
Description
Partly address #2009
You can manually test it by creating a new
spaceflight
project and run%load_node split_data_node
.there are some skipped tests that we aim to improve on separte PR. The current scope of the PR is huge already.
To reviewer
return
statement isn't handled properly yet because I am not sure how should we treat it, should we simply comment it out? It would be a naive solution because it wouldn't work nicely if a function have multiple returns.IMO the code to load catalog is the most needed part, the import statement can be handled with
from xxx import *
which guarantee the code can be run (good enough for debugging). The return statement is also not too important because for a debugging use case the error should happen before that. It's also not too much work for the user to just comment it out or handle edge cases themselves. Ideally it would be nice if user can just copy back the entire block back to the codebase (or even automated)I didn't go with sophisticated solutions such as parsing the abstract syntax tree, there are many small things that we can improve but should be prioritised properly.
I also think some refactor is needed to make tests simpler, it's troublesome to write these tests and easy to miss a newlike character somewhere. I will do this but maybe a bit later.
Demo
Note
kedro ipython
?Development notes
One of the challenge of this feature is that there are no solution that works across platform. It sounds like a simple task, but there are very limited support on creating multiple cells in notebook. The standard
%load
method only support creating ONE cell but not more. I end up choosingipylab
since this is the only option that support create multiple cell which offers a nicer user experience. It works only for notebook >7.0 and JupyterLab.If we want to support VSCode notebook, we may have to settle with a single cell solution, which is still an improvement but not ideal. For the initial MVP, I think it's fine to support Notebook / Lab. If we end up supporting more, it's likely we will need to maintain platform specific code until there are nice solutions that works well everywhere.
Edge Case improvement:
locals()
.Reference List:
%load
source-code https://github.com/ipython/ipython/blob/b14df3808a86bb1c9565816d15be4a52bc694c2a/IPython/core/magics/code.py#L316-L326Developer Certificate of Origin
We need all contributions to comply with the Developer Certificate of Origin (DCO). All commits must be signed off by including a
Signed-off-by
line in the commit message. See our wiki for guidance.If your PR is blocked due to unsigned commits, then you must follow the instructions under "Rebase the branch" on the GitHub Checks page for your PR. This will retroactively add the sign-off to all unsigned commits and allow the DCO check to pass.
Checklist
RELEASE.md
file