Skip to content

Commit

Permalink
Improve error message for invalid example pipeline value (#3543)
Browse files Browse the repository at this point in the history
Signed-off-by: Merel Theisen <merel.theisen@quantumblack.com>
  • Loading branch information
merelcht authored Jan 24, 2024
1 parent 67c7471 commit 7384abd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions kedro/framework/cli/starters.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ def _validate_input_with_regex_pattern(pattern_name: str, input: str) -> None:
VALIDATION_PATTERNS = {
"yes_no": {
"regex": r"(?i)^\s*(y|yes|n|no)\s*$",
"error_message": "|It must contain only y, n, YES, NO, case insensitive.",
"error_message": f"'{input}' is an invalid value for example pipeline. It must contain only y, n, YES, or NO (case insensitive).",
},
"project_name": {
"regex": r"^[\w -]{2,}$",
"error_message": f"{input}' is an invalid value for project name. It must contain only alphanumeric symbols, spaces, underscores and hyphens and be at least 2 characters long",
"error_message": f"'{input}' is an invalid value for project name. It must contain only alphanumeric symbols, spaces, underscores and hyphens and be at least 2 characters long",
},
"tools": {
"regex": r"""^(
Expand Down
2 changes: 1 addition & 1 deletion kedro/templates/project/prompts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ example_pipeline:
Would you like to include an example pipeline? [y/N]:
regex_validator: "(?i)^(y|yes|n|no)$"
error_message: |
It must contain only y, n, YES, NO, case insensitive.
It must contain only y, n, YES, or NO (case insensitive).
13 changes: 10 additions & 3 deletions tests/framework/cli/test_starters.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,9 +1133,12 @@ def test_invalid_example(self, fake_kedro_cli, bad_input):
)

assert result.exit_code != 0
assert "is an invalid value for example pipeline." in result.output
assert (
"It must contain only y, n, YES, NO, case insensitive.\n" in result.output
f"'{bad_input}' is an invalid value for example pipeline." in result.output
)
assert (
"It must contain only y, n, YES, or NO (case insensitive).\n"
in result.output
)


Expand Down Expand Up @@ -1311,7 +1314,11 @@ def test_invalid_example(self, fake_kedro_cli, bad_input):

assert result.exit_code != 0
assert (
"It must contain only y, n, YES, NO, case insensitive.\n" in result.output
f"'{bad_input}' is an invalid value for example pipeline." in result.output
)
assert (
"It must contain only y, n, YES, or NO (case insensitive).\n"
in result.output
)


Expand Down

0 comments on commit 7384abd

Please sign in to comment.