kedro icon indicating copy to clipboard operation
kedro copied to clipboard

Kedro new starter CLI : user_input.lower()

Open Ipsedo opened this issue 10 months ago ā€¢ 9 comments

Description

I use kedro starter CLI configured by prompt.yml with regex check and I think I found one issue : the user inputs are systematically transformed to lowercase : https://github.com/kedro-org/kedro/blob/main/kedro/framework/cli/starters.py#L957 The result is that I can't restrict user input to uppercase or lowercase

Context

I want to restrict user input to uppercase

Steps to Reproduce

  1. create a cookiecutter template for kedro (regarding your need)
  2. create your cookiecutter.json with project_name as unique prompt
  3. create your prompt.yml with an entry for project_name
  4. set the regex_validator field to "[A-Z_]+"
  5. start kedro new --starter=./my_starter and answer MY_PROJECT for project_name prompt
  6. It will fail due to the user_input.lower() in kedro/framework/cli/starters.py line 957

Expected Result

The regex and the input must match

Actual Result

The user input is refused

Your Environment

Python : 3.9.13 Kedro : 0.19.3 OS : Linux (distribution and kernel version confidential)

Ipsedo avatar Apr 05 '24 09:04 Ipsedo

I think that is by design that we don't allow upper case. As I understand this is the convention for Python community.

https://gist.github.com/etigui/7600441926e73c3385057718c2fdef8e

However the error may not be clear enough, curious if you are creating your own starters?

noklam avatar Apr 05 '24 09:04 noklam

I know about python naming convention, the point is not here : the regex of prompt for project name in uppercase was just for the example. In reality I use the regex for a variable value in the project which needs to be in uppercase, your code is clear : you apply lower() method on the user input which is not correct.

Ipsedo avatar Apr 05 '24 12:04 Ipsedo

@lpsedo got it, would you like to send a PR to fix this? It should be a relative simple one happy to merge this.

noklam avatar Apr 05 '24 17:04 noklam

Sure, I will potentially make the PR this weekend

Ipsedo avatar Apr 10 '24 13:04 Ipsedo

Hi @Ipsedo are you still interested in creating a PR for this?

merelcht avatar May 20 '24 14:05 merelcht

@merelcht I would like to work on this - do I need to be assigned first or should I submit a PR directly?

parthmshah1302 avatar Jul 10 '24 23:07 parthmshah1302

Hi @parthmshah1302, thanks for helping out! You can just go ahead and create a PR when you're ready šŸ™‚

merelcht avatar Jul 11 '24 08:07 merelcht

Hi, could I please get a status update on this? Iā€™d like to work on it if possible.

AdityaS8804 avatar Sep 24 '24 06:09 AdityaS8804