sending uris as batch throws unexpected mimetype: text/html SOMETIMES*
pasa13142 opened this issue · comments
pasa13142 commented
Hello, first of all thanks for this amazing project!
I download images as base64 and convert them to as:
uris = ['data:image/png;base64,{}'.format(b64) for b64, _ in filtered_list]
when I send uris to server one by one as bad practice, all good. Got no error.
But when I send them to server all together. It generally throws the error below. Not on a specific one, not always, but generally. Not always part is really interesting.
You have any idea?
result = client.encode(uris, prefetch=64, batch_size=64)
Exception in thread Thread-1994:
Traceback (most recent call last):
File "/Users/alihankaradag/opt/anaconda3/lib/python3.9/threading.py", line 973, in _bootstrap_inner
self.run()
File "/Users/alihankaradag/opt/anaconda3/lib/python3.9/site-packages/jina/helper.py", line 1303, in run
self.result = asyncio.run(func(*args, **kwargs))
File "/Users/alihankaradag/opt/anaconda3/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "uvloop/loop.pyx", line 1517, in uvloop.loop.Loop.run_until_complete
File "/Users/alihankaradag/opt/anaconda3/lib/python3.9/site-packages/jina/clients/mixin.py", line 271, in _get_results
async for resp in c._get_results(*args, **kwargs):
File "/Users/alihankaradag/opt/anaconda3/lib/python3.9/site-packages/jina/clients/base/http.py", line 165, in _get_results
r_str = await response.json()
File "/Users/alihankaradag/opt/anaconda3/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1103, in json
raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html', url=URL('http://image-feature-extractor-cpu.kbnt-test.cimri.com:80/post')
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
File ~/opt/anaconda3/lib/python3.9/site-packages/jina/helper.py:1318, in run_async(func, *args, **kwargs)
1317 try:
-> 1318 return thread.result
1319 except AttributeError:
AttributeError: '_RunThread' object has no attribute 'result'
During handling of the above exception, another exception occurred:
BadClient Traceback (most recent call last)
/Users/alihankaradag/Desktop/Cimri-Repos-New/random-space/solr.ipynb Cell 2 in <cell line: 9>()
[15](vscode-notebook-cell:/Users/alihankaradag/Desktop/Cimri-Repos-New/random-space/solr.ipynb#X32sZmlsZQ%3D%3D?line=14) uris = ['data:image/png;base64,{}'.format(b64) for b64, _ in filtered_list]
[16](vscode-notebook-cell:/Users/alihankaradag/Desktop/Cimri-Repos-New/random-space/solr.ipynb#X32sZmlsZQ%3D%3D?line=15) image_id_list = [t[1] for t in filtered_list]
---> [17](vscode-notebook-cell:/Users/alihankaradag/Desktop/Cimri-Repos-New/random-space/solr.ipynb#X32sZmlsZQ%3D%3D?line=16) result = client.encode(uris, prefetch=64, batch_size=64)
[19](vscode-notebook-cell:/Users/alihankaradag/Desktop/Cimri-Repos-New/random-space/solr.ipynb#X32sZmlsZQ%3D%3D?line=18) if len(result) == len(image_id_list):
[20](vscode-notebook-cell:/Users/alihankaradag/Desktop/Cimri-Repos-New/random-space/solr.ipynb#X32sZmlsZQ%3D%3D?line=19) payload = {
[21](vscode-notebook-cell:/Users/alihankaradag/Desktop/Cimri-Repos-New/random-space/solr.ipynb#X32sZmlsZQ%3D%3D?line=20) "image_ids": image_id_list,
[22](vscode-notebook-cell:/Users/alihankaradag/Desktop/Cimri-Repos-New/random-space/solr.ipynb#X32sZmlsZQ%3D%3D?line=21) "encodings": result.tolist()
[23](vscode-notebook-cell:/Users/alihankaradag/Desktop/Cimri-Repos-New/random-space/solr.ipynb#X32sZmlsZQ%3D%3D?line=22) }
File ~/opt/anaconda3/lib/python3.9/site-packages/clip_client/client.py:330, in Client.encode(self, content, **kwargs)
325 parameters['drop_image_content'] = parameters.get(
326 'drop_image_content', True
327 )
328 model_name = parameters.pop('model_name', '') if parameters else ''
--> 330 self._client.post(
331 on=f'/encode/{model_name}'.rstrip('/'),
332 **self._get_post_payload(content, results, **kwargs),
333 on_done=on_done,
334 on_error=on_error,
335 on_always=partial(self._update_pbar, func=on_always),
336 parameters=parameters,
337 )
339 unbox = hasattr(content, '__len__') and isinstance(content[0], str)
340 return self._unboxed_result(results, unbox)
File ~/opt/anaconda3/lib/python3.9/site-packages/jina/clients/mixin.py:281, in PostMixin.post(self, on, inputs, on_done, on_error, on_always, parameters, target_executor, request_size, show_progress, continue_on_error, return_responses, max_attempts, initial_backoff, max_backoff, backoff_multiplier, results_in_order, stream, prefetch, return_type, **kwargs)
278 if return_results:
279 return result
--> 281 return run_async(
282 _get_results,
283 inputs=inputs,
284 on_done=on_done,
285 on_error=on_error,
286 on_always=on_always,
287 exec_endpoint=on,
288 target_executor=target_executor,
289 parameters=parameters,
290 request_size=request_size,
291 max_attempts=max_attempts,
292 initial_backoff=initial_backoff,
293 max_backoff=max_backoff,
294 backoff_multiplier=backoff_multiplier,
295 results_in_order=results_in_order,
296 stream=stream,
297 prefetch=prefetch,
298 **kwargs,
299 )
File ~/opt/anaconda3/lib/python3.9/site-packages/jina/helper.py:1322, in run_async(func, *args, **kwargs)
1319 except AttributeError:
1320 from jina.excepts import BadClient
-> 1322 raise BadClient(
1323 'something wrong when running the eventloop, result can not be retrieved'
1324 )
1325 else:
1327 raise RuntimeError(
1328 'you have an eventloop running but not using Jupyter/ipython, '
1329 'this may mean you are using Jina with other integration? if so, then you '
1330 'may want to use Client/Flow(asyncio=True). If not, then '
1331 'please report this issue here: https://github.com/jina-ai/jina'
1332 )
BadClient: something wrong when running the eventloop, result can not be retrieved
Thanks in advance