-
Notifications
You must be signed in to change notification settings - Fork 934
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
Update documentation to show how to use KedroSession
outside of CLI mode
#1713
Conversation
Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>
@@ -58,7 +58,6 @@ def reload_kedro( | |||
|
|||
_remove_cached_modules(metadata.package_name) | |||
|
|||
configure_project(metadata.package_name) |
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.
The bootstrap_project
method already included the configure_project
, so I don't think it is needed
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 been meaning to do this for ages. I didn't do it before because at a glance I wasn't 100% sure whether it was intentional to have both bootstrap_project
and configure_project
here. Note there's a call to _remote_cached_modules
in between - does that mean that actually we need to repeat the call to configure_project
?
I'm very much in favour of removing this if we can, but please do double check to see that all still works correctly after removing it! Possibly there's a good reason it's there.
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.
Sounds like you are confident we can remove this, so please go ahead as you were before 👍
Dev notes:
|
Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>
Mostly base on @datajoely's magic, I added some more so it will attempt to find the project. If it finds a kedro project then it will print the suggested path. The last commit could be done at a separate commit, but I find this is kinda related anyway since it's dealing with things break in "out of project" mode. |
Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>
…into fix/docs_session_create Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>
Really nice work @noklam - would you mind providing some screenshots? I'll defer any points on implementation to the rest of the group, but would love to see the user journey here. |
If users are in the project directory: If users are not in the project directory:
Typing this on my phone so sorry for badly formoatted. What even better maybe it should just be a copyable message cd is_this_your_project |
I didn't realise that was a new screenshot, I thought it was mine from ages ago. Nice work! |
@@ -58,7 +58,6 @@ def reload_kedro( | |||
|
|||
_remove_cached_modules(metadata.package_name) | |||
|
|||
configure_project(metadata.package_name) |
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 been meaning to do this for ages. I didn't do it before because at a glance I wasn't 100% sure whether it was intentional to have both bootstrap_project
and configure_project
here. Note there's a call to _remote_cached_modules
in between - does that mean that actually we need to repeat the call to configure_project
?
I'm very much in favour of removing this if we can, but please do double check to see that all still works correctly after removing it! Possibly there's a good reason it's there.
kedro/framework/cli/cli.py
Outdated
self._cli_hook_manager = get_cli_hook_manager() | ||
|
||
super().__init__( | ||
("Global commands", self.global_groups), | ||
("Project specific commands", self.project_groups), | ||
) | ||
|
||
def get_command(self, ctx: Context, cmd_name: str) -> Optional[Command]: |
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'm a huge fan of this change in principle, thank you for adding it! However, please could you split it off into a separate PR? There's a few things I think need discussing:
- not at all sure about using
black
forfind_project_root
. Note we have something similar_find_kedro_project
in the ipython extension; if that seems suitable to reuse, let's move it to some common utils file and use it here - more importantly, if we are inside a kedro project, just not at the top level, is there actually any reason these project commands shouldn't work? 🤔 Instead of an error message telling the user to
cd
can we actually just somehow make kedro work inside a project subfolder (likekedro ipython
does)? But withoutcd
ing to the kedro project top-level - if we're totally outside a kedro project, a helpful error message is great but:
- is there some better way to check if the command is a project one without overriding
get_command
, e.g. check if it's inself.project_groups
? - I don't think this formatting is "on brand" yet since we haven't moved the rest of the CLI to rich yet. Let's just do it as
click.secho
for now. Doing rich styling for CLI messages is a separate issue for another time (e.g. we might move to https://github.com/ewels/rich-click)
- is there some better way to check if the command is a project one without overriding
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.
#1720 Separate PR created here, I put it in the inbox so we can discuss it a bit more.
Co-authored-by: Antony Milne <49395058+AntonyMilneQB@users.noreply.github.com>
This reverts commit edda3f1. Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>
Co-authored-by: Antony Milne <49395058+AntonyMilneQB@users.noreply.github.com>
Co-authored-by: Antony Milne <49395058+AntonyMilneQB@users.noreply.github.com>
Signed-off-by: Nok Chan <nok.lam.chan@quantumblack.com>
PACKAGE_NAME = "fake_page_name" | ||
PROJECT_NAME = "fake_project_name" | ||
PROJECT_VERSION = "0.1" | ||
|
||
|
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.
just minor refactoring since these values appears a few time.
mocker.patch("kedro.framework.project.settings.configure") | ||
mocker.patch("kedro.framework.session.session.validate_settings") | ||
mocker.patch("kedro.framework.session.KedroSession._setup_logging") |
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.
@AntonyMilneQB Are these actually needed? I found that they are not in the test_load_kedro_objects_extra_args
test and removing them seems to have no effect, I am not sure why it is needed.
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.
Probably not needed 👍
@@ -67,16 +70,21 @@ def my_register_pipeline(): | |||
mock_register_line_magic = mocker.patch( | |||
"kedro.extras.extensions.ipython.register_line_magic" | |||
) | |||
mock_context = mocker.patch("kedro.framework.session.KedroSession.load_context") |
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.
We should use session instead
@@ -58,7 +58,6 @@ def reload_kedro( | |||
|
|||
_remove_cached_modules(metadata.package_name) | |||
|
|||
configure_project(metadata.package_name) |
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.
Sounds like you are confident we can remove this, so please go ahead as you were before 👍
mocker.patch("kedro.framework.project.settings.configure") | ||
mocker.patch("kedro.framework.session.session.validate_settings") | ||
mocker.patch("kedro.framework.session.KedroSession._setup_logging") |
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.
Probably not needed 👍
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.
Great work! Good catch on the test refactoring too!
Signed-off-by: Nok Chan nok.lam.chan@quantumblack.com
Description
#1583 introduce a behavioral change that was introduced in
0.18.0
, this PR updated the documentation to better reflect this.Development notes
bootstrap_project
bonus:
ipython
extensionChecklist
RELEASE.md
file