1717class Status (str , Enum ):
1818 """Runtime outcome per checker."""
1919
20- SUCCESS = "SUCCESS "
21- FAILURE = "FAILURE "
20+ PASSED = "PASSED "
21+ FAILED = "FAILED "
2222 SKIPPED = "SKIPPED"
2323
2424
@@ -46,23 +46,23 @@ class Report:
4646 reasons : list [Reason ] | None = field (default = None )
4747
4848 def __attrs_post_init__ (self ) -> None :
49- if self .status == Status .SUCCESS :
50- assert self .reasons is None , "Success report cannot have reasons"
49+ if self .status == Status .PASSED :
50+ assert self .reasons is None , "Passed report cannot have reasons"
5151 else :
52- assert self .reasons is not None , "Non-success report must have reasons"
52+ assert self .reasons is not None , "Non-passed report must have reasons"
5353
54- def is_success (self , * , strict : bool = False ) -> bool :
55- """Check if the status is success ."""
54+ def is_passed (self , * , strict : bool = False ) -> bool :
55+ """Check if the status is passed ."""
5656 return (
57- self .status == Status .SUCCESS
57+ self .status == Status .PASSED
5858 or self .is_skipped ()
5959 or (not strict and self .severity .is_warning ())
6060 )
6161
62- def is_failure (self , * , strict : bool = False ) -> bool :
63- """Check if the status is failure ."""
64- return (self .status == Status .FAILURE and self .severity .is_error ()) or not (
65- self .is_success (strict = strict ) or self .is_skipped ()
62+ def is_failed (self , * , strict : bool = False ) -> bool :
63+ """Check if the status is failed ."""
64+ return (self .status == Status .FAILED and self .severity .is_error ()) or not (
65+ self .is_passed (strict = strict ) or self .is_skipped ()
6666 )
6767
6868 def is_skipped (self ) -> bool :
@@ -79,9 +79,9 @@ def make_report(
7979) -> Report :
8080 """Make a report for the given rule."""
8181 if reasons :
82- return Report (id , name , severity , description , Status .FAILURE , reasons )
82+ return Report (id , name , severity , description , Status .FAILED , reasons )
8383 else :
84- return Report (id , name , severity , description , Status .SUCCESS )
84+ return Report (id , name , severity , description , Status .PASSED )
8585
8686
8787def make_skipped (
@@ -122,16 +122,16 @@ def from_context(cls, context: SanityContext, reports: list[Report]) -> Self:
122122 reports = reports ,
123123 )
124124
125- def is_success (self , * , strict : bool = False ) -> bool :
126- """Return True if all reports are successful , False otherwise.
125+ def is_passed (self , * , strict : bool = False ) -> bool :
126+ """Return True if all reports are passed , False otherwise.
127127
128128 Args:
129129 strict (bool): Whether to consider warnings as failures.
130130
131131 Returns:
132- True if all reports are successful , False otherwise.
132+ True if all reports are passed , False otherwise.
133133 """
134- return all (report .is_success (strict = strict ) for report in self .reports )
134+ return all (report .is_passed (strict = strict ) for report in self .reports )
135135
136136 def to_str (self , * , strict : bool = False ) -> str :
137137 """Return a string representation of the result.
@@ -144,7 +144,7 @@ def to_str(self, *, strict: bool = False) -> str:
144144 """
145145 string = f"=== DatasetID: { self .dataset_id } ===\n "
146146 for report in self .reports :
147- if not report .is_success (strict = strict ):
147+ if not report .is_passed (strict = strict ):
148148 string += f"\033 [31m { report .id } :\033 [0m\n "
149149 for reason in report .reasons or []:
150150 string += f"\033 [31m - { reason } \033 [0m\n "
@@ -171,41 +171,19 @@ def print_sanity_result(result: SanityResult, *, strict: bool = False) -> None:
171171 print (result .to_str (strict = strict ))
172172
173173 # print summary result
174- success = sum (1 for rp in result .reports if rp .is_success (strict = strict ))
175- failures = sum (1 for rp in result .reports if not rp .is_success (strict = strict ))
176- skips = sum (1 for rp in result .reports if rp .is_skipped ())
174+ passed = sum (1 for rp in result .reports if rp .is_passed (strict = strict ))
175+ failed = sum (1 for rp in result .reports if not rp .is_passed (strict = strict ))
176+ skipped = sum (1 for rp in result .reports if rp .is_skipped ())
177177
178178 # just count the number of warnings
179179 warnings = sum (1 for rp in result .reports if rp .severity .is_warning () and rp .reasons )
180180
181- summary_rows = [
182- [
183- result .dataset_id ,
184- result .version ,
185- "\033 [32mSUCCESS\033 [0m"
186- if result .is_success (strict = strict )
187- else "\033 [31mFAILURE\033 [0m" ,
188- len (result .reports ),
189- success ,
190- failures ,
191- skips ,
192- warnings ,
193- ]
194- ]
181+ summary_rows = [[result .dataset_id , result .version , passed , failed , skipped , warnings ]]
195182
196183 print (
197184 tabulate (
198185 summary_rows ,
199- headers = [
200- "DatasetID" ,
201- "Version" ,
202- "Status" ,
203- "Rules" ,
204- "Success" ,
205- "Failures" ,
206- "Skips" ,
207- "Warnings" ,
208- ],
186+ headers = ["DatasetID" , "Version" , "Passed" , "Failed" , "Skipped" , "Warnings" ],
209187 tablefmt = "pretty" ,
210188 ),
211189 )
0 commit comments