jina-ai / serve

☁️ Build multimodal AI applications with cloud-native stack
https://jina.ai/serve
Apache License 2.0
21.13k stars 2.22k forks source link

Docarray ValidationError when monitoring is enabled #5963

Closed NarekA closed 1 year ago

NarekA commented 1 year ago

Describe the bug

When I run a schema'ed executor with custom docarray types as inputs and outputs with monitoring enabled, I get an error. I believe it is trying to cast the return value as the output type.

Environment

jina== 3.19.0

Screenshots

ERROR  @32875 ValidationError(model='Input', errors=[{'loc': ('messages',), 'msg': 'field required', 'type':                          
       'value_error.missing'}, {'loc': ('__root__',), 'msg': 'Only one model config type can be set, found []',                           
       'type': 'value_error'}])                                                                                                           
        add "--quiet-error" to suppress the exception details                                                                             
       Traceback (most recent call last):                                                                                                 
         File                                                                                                                             
       "/Users/user/env/lib/python3.9/site-packages/jina/serve/runtimes/worker/…                    
       line 956, in process_data                                                                                                          
           result = await self.handle(                                                                                                    
         File                                                                                                                             
       "/Users/user/env/lib/python3.9/site-packages/jina/serve/runtimes/worker/…                    
       line 670, in handle                                                                                                                
           self._record_docs_processed_monitoring(requests)                                                                               
         File                                                                                                                             
       "/Users/user/env/lib/python3.9/site-packages/jina/serve/runtimes/worker/…                    
       line 481, in _record_docs_processed_monitoring                                                                                     
           len(requests[0].docs)                                                                                                          
         File                                                                                                                             
       "/Users/user/env/lib/python3.9/site-packages/jina/types/request/data.py",                    
       line 282, in docs                                                                                                                  
           return self.data.docs                                                                                                          
         File                                                                                                                             
       "/Users/user/env/lib/python3.9/site-packages/jina/types/request/data.py",                    
       line 50, in docs                                                                                                                   
           self._loaded_doc_array = self.document_array_cls.from_protobuf(                                                                
         File                                                                                                                             
       "/Users/user/env/lib/python3.9/site-packages/docarray/array/doc_list/doc…                    
       line 296, in from_protobuf                                                                                                         
           return super().from_protobuf(pb_msg)                                                                                           
         File                                                                                                                             
       "/Users/user/env/lib/python3.9/site-packages/docarray/array/doc_list/io.…                    
       line 119, in from_protobuf                                                                                                         
           return cls(cls.doc_type.from_protobuf(doc_proto) for doc_proto in pb_msg.docs)                                                 
         File                                                                                                                             
       "/Users/user/env/lib/python3.9/site-packages/docarray/array/doc_list/doc…                    
       line 128, in __init__                                                                                                              
           super().__init__(docs)                                                                                                         
         File                                                                                                                             
       "/Users/user/env/lib/python3.9/site-packages/docarray/array/doc_list/doc…                    
       line 155, in _validate_docs                                                                                                        
           for doc in docs:                                                                                                               
         File                                                                                                                             
       "/Users/user/env/lib/python3.9/site-packages/docarray/array/doc_list/io.…                    
       line 119, in <genexpr>                                                                                                             
           return cls(cls.doc_type.from_protobuf(doc_proto) for doc_proto in pb_msg.docs)                                                 
         File                                                                                                                             
       "/Users/user/env/lib/python3.9/site-packages/docarray/base_doc/mixins/io…                    
       line 247, in from_protobuf                                                                                                         
           return cls(**fields)                                                                                                           
         File "/Users/user/env/hub/schema.py", line 28, in __init__                        
           super().__init__(**data)                                                                                                       
         File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__                                                           
       pydantic.error_wrappers.ValidationError: 2 validation errors for Input                                                         
       messages                                                                                                                           
         field required (type=value_error.missing)                                                                                        
JoanFM commented 1 year ago

Hey @NarekA, thanks for reporting

what is the difference when monitoring is not enabled?

Can you share a minimal reproducible example with the schemas used?

JoanFM commented 1 year ago

I will try to test this better, but I think that #5965 should fix this issue. If you could try to install this branch and validate, it would be great