ShannonAI / service-streamer

Boosting your Web Services of Deep Learning Applications.
Apache License 2.0
1.22k stars 187 forks source link

Returning dictionary instead of a list in provided callback to ThreadedStreamer #97

Open cgr71ii opened 1 year ago

cgr71ii commented 1 year ago

Hi!

Is it possible for ThreadedStreamer to return a dictionary instead of a list? I'm doing

ThreadedStreamer(batch_prediction, batch_size=args.batch_size, max_latency=0.1)

and I'd like that the function batch_prediction returned a dictionary since my model does multitask training and I have the result of multiple tasks, not just one.

When I try it, I got the following error:

Exception in thread thread_worker:                                                              
Traceback (most recent call last):                                                              
  File "/home/cgarcia/miniconda3/envs/PUC/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()                                                                                  
  File "/home/cgarcia/miniconda3/envs/PUC/lib/python3.8/threading.py", line 870, in run         
    self._target(*self._args, **self._kwargs)                                                   
  File "/home/cgarcia/miniconda3/envs/PUC/lib/python3.8/site-packages/service_streamer/service_streamer.py", line 154, in run_forever
    handled = self._run_once()                                                                  
  File "/home/cgarcia/miniconda3/envs/PUC/lib/python3.8/site-packages/service_streamer/service_streamer.py", line 189, in _run_once
    self._send_response(client_id, task_id, request_id, model_outputs[i])                       
KeyError: 0                                                                                     

Thank you!