-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
exception cleanup #6347
exception cleanup #6347
Conversation
Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide. |
1 similar comment
Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide. |
e5b8c76
to
a25bfb9
Compare
9d19015
to
358746a
Compare
@@ -22,13 +22,20 @@ | |||
import pytz | |||
|
|||
from dbt.exceptions import ( |
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.
Maybe we've hit the tipping point here where we should just import the dbt.exceptions module?
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.
Is there a reason to do that other than not importing them individually?
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 think some Python codebases have policies around that but we don't. I guess if the import list gets really long it might be easier to just import the package. If we did import dbt..exceptions as exc we could specify every one as exc.SomeException. I think some people prefer the specific imports because it makes it clearer which ones are used in this file. I'm kind of agnostic on the whole thing.
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.
some people prefer the specific imports because it makes it clearer which ones are used in this file
I'm in this camp for sure.
bd34660
to
e85fb67
Compare
@@ -400,7 +400,7 @@ def safe_run_hooks( | |||
thread_id="main", | |||
timing=[], | |||
message=f"{hook_type.value} failed, error:\n {exc.msg}", | |||
adapter_response=exc.msg, |
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.
The BaseResult
was added here recently as part of #6059. My understanding is that the adapter response isn't important. Because i added types, this was failing since exc.msg
is a string but adapter_response
is a Dict[str, Any]
.
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 think there was some conversation recently about the adapter_response, but I'm pretty vague on what was discussed. I think it often doesn't actually have any content, but maybe should? But in any case assigning a string to it is clearly wrong.
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.
This is a huge huge improvement over what we had before. It's so much easier to see all of the different exceptions that got hidden behind the generic functions.
I do confess to preferring the use of keyword arguments for constructing them, but wouldn't ask for that at this point.
Also ... Do you think it would be better to use dataclasses? The exceptions would then looks a lot more like the logging events, and we could do a standard "build the message" thing in a base class, kind of like we do for logs.
core/dbt/adapters/base/impl.py
Outdated
method_name="get_missing_columns", | ||
arg_name="from_relation", | ||
got_value=from_relation, | ||
expected_type=self.Relation, | ||
version="0.13.0", |
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 we get rid of the "version" piece entirely, including in the message? We haven't supported version 0.13.0 in forever, so just a "this isn't supported" should be fine.
@@ -400,7 +400,7 @@ def safe_run_hooks( | |||
thread_id="main", | |||
timing=[], | |||
message=f"{hook_type.value} failed, error:\n {exc.msg}", | |||
adapter_response=exc.msg, |
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 think there was some conversation recently about the adapter_response, but I'm pretty vague on what was discussed. I think it often doesn't actually have any content, but maybe should? But in any case assigning a string to it is clearly wrong.
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.
Looks great, but should we rename every exception to end in Error
similar to Python's built-in exceptions?
At the very least, we should standardize on using either Error
or Exception
uniformly everywhere?
resolves #6339
Description
Decorator to be added in #6413
This PR
core/context
This PR does not
ParsingException
,CompilationException
, etc) into a unique exceptionChecklist
changie new
to create a changelog entry