-
Notifications
You must be signed in to change notification settings - Fork 113
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
Refactor CLI with lazy subcommands and deferring imports #1920
Conversation
Signed-off-by: Ankita Katiyar <ankitakatiyar2401@gmail.com>
I did something similar 1.5 years ago: #1196 |
Closing this for now as Ankita can no longer work on this. This issue is tracked here - #1952 |
Extension : Future possible improvementsNote This PR will not improve the To improve Some of the observations made while working on improving performance for Kedro-Viz -
Thank you |
@ankatiyar I am not able to add you as reviewer, could you please review the PR when free. Thank you |
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 can't approve my own PR but it looks good to me!
If I understand correctly, before #794 goes in, only the defer import will help but not so much with lazy subcommand? What should I focus on review or what do you want me to review? The PR is huge in terms of code change, would be great if you can comment on this. |
Yes, the refactor and deferred imports help both kedro commands and kedro viz commands.
The code change looks big but if you can check the development notes, most of this is -
As a code reviewer, I am expecting you to -
Thank you |
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.
Thanks! i have test it with the main
and lazy-subcommands
branch. It's definitely faster when I do kedro run
and a couple of other commands.
Big change but I think the new structure is much better, we could have break down the cli into smaller pieces earlier. We found out similar opportunities when I am working on the extension, some module could be made smaller.
Nice work!
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.
Thanks @ravi-kumar-pilla and @ankatiyar. 🎉
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.
LGTM. thanks @ravi-kumar-pilla , and @ankatiyar
Description
Related to kedro-org/kedro#3883 and resolves a follow up action mentioned here
Thanks to @ankatiyar for suggesting the changes and making the POC
Development notes
package/kedro_viz/launchers/cli.py
file which handles all Kedro-Viz CLI commandsTip
Read on the docs for lazy-loading-subcommands and learn more about the initial proposal here
QA notes
kedro viz -h
,kedro viz
,kedro viz run
,kedro viz build
,kedro viz deploy
) with and without optionsThe lazy subcommand loading and refactoring of viz CLI helped in
kedro
init time as viz cli had some expensive imports all in one filecli.py
.Few observations on demo-project with my system running on
macOS Sonoma (2.4 GHz 8-Core Intel i9, 64GB)
-( Comparing after system warmup (initial run) as I am not sure how to clear cache or make this a cold start in the CLI. Please let me know if there is a way to make a cold start again )
Before -
Time taken for
kedro -h
- 4secTime taken for
kedro registry list
- 8secTime taken for
kedro viz run
to reach the actualrun
method - 6secTo run this, you need pyinstrument and speedscope
# Commands used for profiling pyinstrument -r speedscope -o profile.speedscope.json -m kedro viz run speedscope profile.speedscope.json
After -
Time taken for
kedro -h
- 2secTime taken for
kedro registry list
- 6secTime taken for
kedro viz run
to reach the actualrun
method - 2.5secTo run this, you need pyinstrument and speedscope
# Commands used for profiling pyinstrument -r speedscope -o profile.speedscope.json -m kedro viz run speedscope profile.speedscope.json
Checklist
RELEASE.md
file