File tree Expand file tree Collapse file tree 2 files changed +17
-16
lines changed Expand file tree Collapse file tree 2 files changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -103,34 +103,32 @@ def check_explainability_count(self):
103103 'error_message' : None
104104 }
105105
106- def check_top_k_config (self ):
107- """Check if top_k configuration is valid"""
108- top_k = self .assessment_config .get ("top_k" )
109-
110- if top_k is not None :
111- if not isinstance (top_k , (int , float )) or top_k > 100 :
112- raise ValueError ("top_k must be a number and not greater than 100" )
113- # return {
114- # 'is_valid': False,
115- # 'failed_attributes': ['top_k'],
116- # 'error_message': 'top_k must be a number and not greater than 100'
117- # }
118-
106+ def check_explainability_exists (self ):
107+ """Check if explainability_info has at least one element when expected attributes exist"""
108+ expected_attributes = set (self .inference_result .keys ())
109+
110+ if expected_attributes and (not self .explainability_info or not self .explainability_info [0 ]):
111+ return {
112+ 'is_valid' : False ,
113+ 'failed_attributes' : list (expected_attributes ),
114+ 'error_message' : 'No assessment information found for the extracted attributes.'
115+ }
116+
119117 return {
120118 'is_valid' : True ,
121119 'failed_attributes' : [],
122120 'error_message' : None
123121 }
124-
122+
125123 def validate_all (self ):
126124 """Run all validations and return comprehensive results"""
127125 validation_results = {
128126 'is_valid' : True ,
129127 'failed_attributes' : [],
130128 'validation_errors' : []
131129 }
132-
133- # Check missing explainability (only if enabled)
130+
131+ # Check missing explainability if enabled
134132 if self .enable_missing_check :
135133 missing_result = self .check_missing_explainability ()
136134 if not missing_result ['is_valid' ]:
Original file line number Diff line number Diff line change @@ -512,6 +512,9 @@ def handler(event, context):
512512
513513 logger .info (f"Response: { json .dumps (response , default = str )} " )
514514
515+ if document .errors :
516+ validation_errors .extend (document .errors )
517+
515518 # Raise exception if there were validation errors
516519 if validation_errors :
517520 document .status = Status .FAILED
You can’t perform that action at this time.
0 commit comments