-
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
Fix plural of "partial success" #11002
base: main
Are you sure you want to change the base?
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. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #11002 +/- ##
==========================================
- Coverage 89.12% 89.07% -0.06%
==========================================
Files 183 183
Lines 23626 23635 +9
==========================================
- Hits 21057 21052 -5
- Misses 2569 2583 +14
Flags with carried forward coverage won't be shown. Click here to find out more.
|
373bfcb
to
cbe747b
Compare
@@ -1927,9 +1927,17 @@ def code(self) -> str: | |||
return "Z030" | |||
|
|||
def message(self) -> str: | |||
|
|||
class PartialSuccess: |
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 likely overdoing it. Alternative ideas:
- implement
NodeStatus.pluralize()
, and import/use the actualNodeStatus
enum here - just reimplement the logic of
pluralize
(if count != 1
) for this particular string, instead of callingpluralize
to createpartial_success_plural
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 agree. I feel like creating a PartialSuccess
class here feels out of place 🤔 Out of the alternatives you've listed, I think the first would be preferable
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 started down this path, but two things are giving me pause:
- I would need to make this a nested
import
, to avoid a circular import (sincedbt.artifacts.schemas.results
imports the event system) NodeStatus.Warn
has its string type set to `"warn", and here we have "warning(s)"
class NodeStatus(StrEnum):
Success = "success"
Error = "error"
Fail = "fail"
Warn = "warn"
Skipped = "skipped"
PartialSuccess = "partial success"
Pass = "pass"
RuntimeErr = "runtime error"
def pluralize(self) -> str:
if self is self.Success or self is self.PartialSuccess or self is self.Pass:
return f"{self}es"
elif self is self.Warn:
return f"warnings" # feels inconsistent
elif self is self.Skipped:
return "skipped"
return f"{self}s"
from dbt.artifacts.schemas.results import NodeStatus
error_plural = pluralize(self.num_errors, NodeStatus.Error)
warn_plural = pluralize(self.num_warnings, NodeStatus.Warn)
partial_success_plural = pluralize(self.num_partial_success, NodeStatus.PartialSuccess)
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 would need to make this a nested import, to avoid a circular import (since dbt.artifacts.schemas.results imports the event system)
🫠 Right, we haven't finished the decoupling. Woof okay. I'll look in a bit and see if we can break the circular import on the artifacts side.
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.
Are we sure that this doesn't involve the definition of pluralize
from dbt-common
?
dbt-core/core/dbt/events/types.py
Lines 12 to 14 in a86e2b4
from dbt_common.events.format import ( | |
format_fancy_output_line, | |
pluralize, |
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.
@dbeatty10 It does! That's the pluralize
method in the code right now
That method says:
- If there's exactly 1 of me, return me (unchanged)
- If there's != 1 of me, and I'm being passed a
string
argument that is actually a class which implements a method namedpluralize
, then use that method to pluralize me; otherwise, just adds
So the question here is:
- Should we implement a one-off class for
PartialSuccess
withinEndOfRunSummary
that implementspluralize
? - Do I use the actual
NodeStatus
class here, and implementpluralize
? (problems described above) - Do I just ignore
dbt_common.events.format.pluralize
, and reimplement that ifcount !=1
logic withinEndOfRunSummary
, for "partial success" only?
error_plural = pluralize(self.num_errors, NodeStatus.Error)
warn_plural = pluralize(self.num_warnings, NodeStatus.Warn)
partial_success_plural = f"""{self.num_partial_success} {"partial success" if self.num_partial_success == 1 else "partial successes"}"""
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.
partial_success_plural = f"""{self.num_partial_success} {"partial success" if self.num_partial_success == 1 else "partial successes"}"""
is ugly, but seems like the fastest and easiest way to solve this in a targeted manner.
If we choose that option, it would solve the problem now, then we could create a tech debt issue to come back and convert it back to pluralize
once the decoupling part is done.
Obviously totally up to @QMalcolm -- just throwing out some ideass.
error_result = RunResult( | ||
status=RunStatus.Error, | ||
timing=[], | ||
thread_id="", | ||
execution_time=0.0, | ||
node=None, | ||
node=MockNode(), |
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.
print_run_end_messages()
expects this result to have an actual node
object, with a unique_id
value and a node_info
key
Resolves #10999
Problem
The plural of
partial success
Solution
Implement
PartialSuccess.pluralize()
(sort of)Checklist