-
Notifications
You must be signed in to change notification settings - Fork 901
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
Exit with exit code 1 when there's an exception #4122
Conversation
Was the program not returning an 1 already in the case of failure? It should be failing both unit and e2e tests if it wasn't. |
The kedro-docker tests were failing because of this kedro-org/kedro-plugins#800. I think this branch of logic is executed when the exceptions come from outside like the kedro project itself, which I don't know if we test for. |
kedro/framework/cli/cli.py
Outdated
@@ -210,7 +210,8 @@ def main( | |||
project_metadata=self._metadata, command_args=args, exit_code=1 | |||
) | |||
hook_called = True | |||
raise | |||
traceback.print_exc() | |||
sys.exit(1) |
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.
Now it looks like we don't need hook_called
flag anymore as all the branches that set it to true now have sys.exit()
. So maybe we can just move self._cli_hook_manager.hook.after_command_run
to the try
block and get rid of finally
, so the logic is a bit cleaner?
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.
I don't want to block the PR, so we can pay attention to this in a separate one.
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.
Actually, I think you're right we don't need the finally
block at all. If the the command executes successfully or the command doesn't exist - it goes into the first except
block otherwise if there's an exception it is caught by the next except
. Hook gets called either way.
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.
Check if it doesn't get called twice on a successful case too, it's why that finally
block was introduced.
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 the behaviour is as expected and still solves #4073
Signed-off-by: Ankita Katiyar <ankitakatiyar2401@gmail.com>
Tested the changes, the #4075 is still solved but the traceback view changed: |
Signed-off-by: Ankita Katiyar <ankitakatiyar2401@gmail.com>
Did a little more investigation - the problem just turned out to be the indentation of When there's a CLI error such as was the case with docker e2e test - kedro-org/kedro-plugins#800 it goes into the first Please take another look @ElenaKhaustova @merelcht @lrcouto |
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.
Tried the revised implementation, and looks all good 👍
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.
Thank you, @ankatiyar!
Tested the updates - all works as expected 🚀
Description
Small regression from #4075
Development notes
Reminder to self: Will have to revert kedro-org/kedro-plugins#813 after the next release
Note to reviewers:
Please verify if #4073 is still resolved!
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