graphsignal/graphsignal-python

Errors when running model async

Closed this issue · 0 comments

Currently running a openai model in a manner very similar to below:

async def predict(inputs):
    for input in inputs:
        result = await model(document=input)

for chunk in chunk_list(inputs, chunk_size=chunk_size):
    program_futures = asyncio.gather(*[predict(x) for x in chunk])
    await program_futures
    results.extend(program_futures.result())

When running this i get the following errors

2023-08-26 11:45:51,847 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,847 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,848 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,848 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,849 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,849 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,850 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,850 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,850 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,851 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,851 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,851 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,851 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,852 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,852 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,852 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,853 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,853 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,853 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,854 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,854 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,854 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,855 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,855 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,855 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,856 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,856 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,856 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:45:51,857 - 140321485053952 - spans.py-spans:466 - ERROR: add_exception: exc must be instance of Exception

I add a print statement like so to the span class:

    def add_exception(self, exc: Optional[Exception] = None, exc_info: Optional[bool] = None) -> None:
       print(exc)
       print(exc_info)
       if exc is not None and not isinstance(exc, Exception):
           logger.error('add_exception: exc must be instance of Exception')
           return

       if exc_info is not None and not isinstance(exc_info, bool):
           logger.error('add_exception: exc_info must be bool')
           return

       if self._exc_infos is None:
           self._exc_infos = []

       if exc:
           self._exc_infos.append((exc.__class__, str(exc), exc.__traceback__))
       elif exc_info == True:
           self._exc_infos.append(sys.exc_info())

And i get the following output:


None
2023-08-26 11:56:06,068 - 139659591200768 - spans.py-spans:468 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:56:06,068 - 139659591200768 - spans.py-spans:251 - DEBUG: Stopping span openai.ChatCompletion.acreate

None
2023-08-26 11:56:06,069 - 139659591200768 - spans.py-spans:468 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:56:06,069 - 139659591200768 - spans.py-spans:251 - DEBUG: Stopping span openai.ChatCompletion.acreate

None
2023-08-26 11:56:06,069 - 139659591200768 - spans.py-spans:468 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:56:06,069 - 139659591200768 - spans.py-spans:251 - DEBUG: Stopping span openai.ChatCompletion.acreate

None
2023-08-26 11:56:06,069 - 139659591200768 - spans.py-spans:468 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:56:06,070 - 139659591200768 - spans.py-spans:251 - DEBUG: Stopping span openai.ChatCompletion.acreate

None
2023-08-26 11:56:06,070 - 139659591200768 - spans.py-spans:468 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:56:06,070 - 139659591200768 - spans.py-spans:251 - DEBUG: Stopping span openai.ChatCompletion.acreate

None
2023-08-26 11:56:06,070 - 139659591200768 - spans.py-spans:468 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:56:06,070 - 139659591200768 - spans.py-spans:251 - DEBUG: Stopping span openai.ChatCompletion.acreate

None
2023-08-26 11:56:06,071 - 139659591200768 - spans.py-spans:468 - ERROR: add_exception: exc must be instance of Exception
2023-08-26 11:56:06,071 - 139659591200768 - spans.py-spans:251 - DEBUG: Stopping span openai.ChatCompletion.acreate

Not a massive issue, it still seems like most of my prompts are finding their way to promptsignal.