Skip to content
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

Check if starter is used before printing tools message #3484

Merged
merged 20 commits into from
Jan 11, 2024

Conversation

AhdraMeraliQB
Copy link
Contributor

@AhdraMeraliQB AhdraMeraliQB commented Jan 4, 2024

Description

As pointed out by @DimedS: xref

We don't allow users to select tools when using starters, so the message "you have selected no project tools" should not be displayed if a starter is used. This check was previously implicit, relying on the different values of tools to differentiate (previously '[]' and ['None']). These have since been unified, and as such, an explicit condition is required to ensure the message isn't printed when a starter is used.

Development notes

There are several alternatives for implementing this:

  1. Move up the tool and example selection messages from L865 to L301, to access starter_alias <- current approach
  2. Pass starter_alias through to _create_project as an argument
  3. Pass starter_alias through as part of the extra_config to be accessed in _create_project <- original approach
  4. Overhaul and refactor starters.py

Developer 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

  • Read the contributing guidelines
  • Signed off each commit with a Developer Certificate of Origin (DCO)
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added a description of this change in the RELEASE.md file
  • Added tests to cover my changes
  • Checked if this change will affect Kedro-Viz, and if so, communicated that with the Viz team

Signed-off-by: Ahdra Merali <[email protected]>
kedro/framework/cli/starters.py Show resolved Hide resolved
kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
@AhdraMeraliQB AhdraMeraliQB marked this pull request as draft January 4, 2024 15:44
Ahdra Merali added 4 commits January 4, 2024 16:09
Signed-off-by: Ahdra Merali <[email protected]>
Signed-off-by: Ahdra Merali <[email protected]>
@AhdraMeraliQB AhdraMeraliQB marked this pull request as ready for review January 4, 2024 17:08
Ahdra Merali added 2 commits January 8, 2024 04:37
Signed-off-by: Ahdra Merali <[email protected]>
Ahdra Merali and others added 2 commits January 8, 2024 05:26
@merelcht
Copy link
Member

merelcht commented Jan 9, 2024

The new function has become quite long. Maybe we can refactor this a bit. For example, extract lines 250-261

if checkout and not starter_alias:
raise KedroCliError("Cannot use the --checkout flag without a --starter value.")
if directory and not starter_alias:
raise KedroCliError(
"Cannot use the --directory flag without a --starter value."
)
if (selected_tools or example_pipeline) and starter_alias:
raise KedroCliError(
"Cannot use the --starter flag with the --example and/or --tools flag."
)

into a separate function that validates the chosen arguments.

Copy link
Member

@merelcht merelcht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach looks good to me 👍 I left some comments to tidy the code some more.

kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
Copy link
Member

@merelcht merelcht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor comments from my side, but in general this is looking good!

kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
kedro/framework/cli/starters.py Outdated Show resolved Hide resolved
"Cannot use the --starter flag with the --example and/or --tools flag."
)

flag_inputs = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why create a dict and not just directly pass the arguments to _validate_flag_inputs?

Copy link
Contributor

@DimedS DimedS Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's in general a good idea - to put all CLI inputs to one dictionary, because currently there are a lot of them, but it should be done not only for one _validate_flag_inputs() function, but to the whole subsequent code. Better to do it little bit later - it will be a huge change, otherwise I cannot merge my current PR #3499 )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, the initial reason was due to how many inputs there are, and for future implementation/refactor as there is no guarantee that we won't need to pass these through later. I couldn't find any strong support for either convention, however, so I am mostly ambivalent. Though whatever we do choose, we should be sure to implement consistently.

Copy link
Contributor

@DimedS DimedS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @AhdraMeraliQB , awesome job! 👍

Copy link
Member

@merelcht merelcht left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@AhdraMeraliQB AhdraMeraliQB merged commit ce27c2d into main Jan 11, 2024
30 checks passed
@AhdraMeraliQB AhdraMeraliQB deleted the fix/clean-up-starters-logic branch January 11, 2024 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants