diff --git a/core/detection/pipeline.py b/core/detection/pipeline.py index ba9ac9a..78001da 100644 --- a/core/detection/pipeline.py +++ b/core/detection/pipeline.py @@ -199,6 +199,8 @@ class DetectionPipeline: Dictionary with extracted field values (e.g., {"car_brand": "Honda", "body_type": "Sedan"}) """ extracted = {} + missing_fields = [] + available_fields = [] try: for db_field_name, template in self.field_mappings.items(): @@ -215,12 +217,21 @@ class DetectionPipeline: result_data = branch_data['result'] if isinstance(result_data, dict) and field_name in result_data: extracted[field_name] = result_data[field_name] + available_fields.append(f"{field_name}={result_data[field_name]}") logger.debug(f"[DYNAMIC EXTRACT] {field_name}={result_data[field_name]} from branch {branch_id}") else: + missing_fields.append(f"{field_name} (field not in branch {branch_id})") logger.debug(f"[DYNAMIC EXTRACT] Field '{field_name}' not found in branch {branch_id}") else: + missing_fields.append(f"{field_name} (branch {branch_id} missing)") logger.debug(f"[DYNAMIC EXTRACT] Branch '{branch_id}' not in results") + # Log summary of extraction + if available_fields: + logger.info(f"[FIELD EXTRACTION] Available fields: {', '.join(available_fields)}") + if missing_fields: + logger.warning(f"[FIELD EXTRACTION] Missing fields (will be null): {', '.join(missing_fields)}") + except Exception as e: logger.error(f"Error extracting fields from branches: {e}", exc_info=True) @@ -338,7 +349,17 @@ class DetectionPipeline: car_brand = extracted_fields.get('brand') body_type = extracted_fields.get('body_type') - logger.info(f"[LICENSE PLATE] Extracted fields: brand={car_brand}, body_type={body_type}") + # Log extraction results + fields_status = [] + if car_brand is not None: + fields_status.append(f"brand={car_brand}") + else: + fields_status.append("brand=null") + if body_type is not None: + fields_status.append(f"bodyType={body_type}") + else: + fields_status.append("bodyType=null") + logger.info(f"[LICENSE PLATE] Extracted fields: {', '.join(fields_status)}") # Clean up stored results after use del self.session_processing_results[session_id_for_lookup] @@ -367,7 +388,18 @@ class DetectionPipeline: # Send message await self.message_sender(detection_message) - logger.info(f"[COMBINED MESSAGE] Sent imageDetection with brand='{car_brand}', bodyType='{body_type}', license='{license_text}' to '{subscription_id}'") + + # Log with indication of partial results + null_fields = [] + if car_brand is None: + null_fields.append('brand') + if body_type is None: + null_fields.append('bodyType') + + if null_fields: + logger.info(f"[COMBINED MESSAGE] Sent imageDetection with PARTIAL results (null: {', '.join(null_fields)}) - brand='{car_brand}', bodyType='{body_type}', license='{license_text}' to '{subscription_id}'") + else: + logger.info(f"[COMBINED MESSAGE] Sent imageDetection with brand='{car_brand}', bodyType='{body_type}', license='{license_text}' to '{subscription_id}'") except Exception as e: logger.error(f"Error sending license plate imageDetection message: {e}", exc_info=True) @@ -1033,11 +1065,13 @@ class DetectionPipeline: wait_for_branches = action.params.get('waitForBranches', []) branch_results = context.get('branch_results', {}) - # Check if all required branches have completed - for branch_id in wait_for_branches: - if branch_id not in branch_results: - logger.warning(f"Branch {branch_id} result not available for database update") - return {'status': 'error', 'message': f'Missing branch result: {branch_id}'} + # Log missing branches but don't block the update (allow partial results) + missing_branches = [b for b in wait_for_branches if b not in branch_results] + if missing_branches: + logger.warning(f"Some branches missing from results (will use null): {missing_branches}") + available_branches = [b for b in wait_for_branches if b in branch_results] + if available_branches: + logger.info(f"Available branches for database update: {available_branches}") # Prepare fields for database update table = action.params.get('table', 'car_frontal_info')