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

Use click features for project creation prompts #4387

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

lrcouto
Copy link
Contributor

@lrcouto lrcouto commented Dec 17, 2024

Description

Replaces Cookiecutter prompts with the click.prompt method, without affecting functionality in kedro new.
We are still using some methods that Cookiecutter imports from Rich, mainly for exceptions, so at the moment it'll still not allow us to uninstall rich without downgrading Cookiecutter.

Prompt appearance is now defined used the click.style method, so it can be changed if we so desire.
Example appearance:

image

Development notes

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: Laura Couto <[email protected]>
Signed-off-by: Laura Couto <[email protected]>
Signed-off-by: Laura Couto <[email protected]>
@lrcouto
Copy link
Contributor Author

lrcouto commented Dec 17, 2024

The current problem with this is that when the --starter flag is used, the prompts are supposed to be different. By using the click prompt feature, the default prompts are evaluated before we have the chance to check if a starter is being used or not. I will see if there's any way to get around this issue.

@astrojuanlu
Copy link
Member

I confirm that the current branch works at least!

image

IIUC this now purely uses Click. Is there a plan to try to restore the colors later on, maybe using https://click.palletsprojects.com/en/stable/utils/#ansi-colors ? (not necessarily right now, as it would probably complicate fixing the remaining tests)

@lrcouto
Copy link
Contributor Author

lrcouto commented Jan 14, 2025

IIUC this now purely uses Click. Is there a plan to try to restore the colors later on, maybe using https://click.palletsprojects.com/en/stable/utils/#ansi-colors ? (not necessarily right now, as it would probably complicate fixing the remaining tests)

Definitely! I want to make sure all of the functionality is as we expect first, but it would be nice to have an option for colors (with the added bonus of not relying on Rich)

@lrcouto lrcouto marked this pull request as ready for review January 16, 2025 14:28
@lrcouto lrcouto requested a review from merelcht as a code owner January 16, 2025 14:28
@ElenaKhaustova
Copy link
Contributor

@lrcouto, could you please clarify if colours should work and how we can check everything works as expected?

@lrcouto
Copy link
Contributor Author

lrcouto commented Jan 16, 2025

@lrcouto, could you please clarify if colours should work and how we can check everything works as expected?

They do not work yet, I'm implementing a color scheme at the moment.

It should not affect automated tests, but the visual appearance will also be slightly different, as those prompts from cookiecutter were importing the Prompt class from Rich. I'll post some screenshots with options once I finish implementing it.

@lrcouto
Copy link
Contributor Author

lrcouto commented Jan 16, 2025

Could look somewhat like this, for example:

image

Signed-off-by: Laura Couto <[email protected]>
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.

Use click choice options to simplify validation of project creation workflow
3 participants