-
Notifications
You must be signed in to change notification settings - Fork 906
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
provide better error message outside of a kedro project #3680
Conversation
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
…_commands Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
(kedro) Nok_Lam_Chan@ kedro % kedro -V
kedro, version 0.19.3
You are not in a Kedro project! Project specific commands such as 'run' or 'jupyter' are only available within a project directory. The e2e test is catching an error that the error message show up in |
It appears that kedro using |
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
#2682 I am more convinced this is something that we should do. |
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com>
# The constant need to be defined first otherwise it causes circular depdencies | ||
ORANGE = (255, 175, 0) | ||
BRIGHT_BLACK = (128, 128, 128) |
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.
Can these go in kedro.utils
? So you wouldn't have to define them first.
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.
It can, but I think cli
is the correct scope as this only affect CLI color. Alternative is keep it in cli/cli.py
because this is the only file that get used at the moment.
Amazing! |
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.
Signed-off-by: Nok <nok.lam.chan@quantumblack.com>
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.
Tested and looks all good to me 👍
* provide error message outside of kedro project with rich style Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com> * change to add custom click message on error instead of overriding get_commands Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com> * add test Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com> * clean up Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com> * catch the error message from click Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com> * fix unitests Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com> * Update error message Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com> * move color constant to the upper module Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com> * fix imports Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com> * release note Signed-off-by: Nok <nok.lam.chan@quantumblack.com> --------- Signed-off-by: Nok Lam Chan <nok.lam.chan@quantumblack.com> Signed-off-by: Nok <nok.lam.chan@quantumblack.com> Signed-off-by: Merel Theisen <merel.theisen@quantumblack.com>
Description
Close #1829
To detect whether it is out of a kedro project is out of scope, it should be fixed in #1831
Development notes
catch_exception = "click.exceptions.UsageError: No such command"
Note click's app by default convert all ExceptionHandles to error message. It's not possible to intercept the error class unless we implement Consider usingrun(standalone_mode=True)
to fix packaged Kedro project getting asys.exit
#2682. The current workaround is catching the traceback which works reasonable well.sub command:
sub group command:
click propagate subcommand by forwarding the argument. Ideally in the 2nd screenshot, we want to see
No such command 'random command', but this is not possible. This is how click always behave and consistent with existing Kedro CLI. The solution is that the error message will always mention
runor
jupyter` instead of showing the actual command user runs, I think this is clear enough and is an improvement.I've also added a hint in the error message:
Technically Kedro is searching for a
pyproject.toml
which hastool.kedro
(sometimes we see projects with multiple pyproject.toml, some are kedro project some are not). I try to keep the hint simple and thus ignoring the details.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
RELEASE.md
file