0

I am doing inference on two strings using celery and django rest framework but I am getting error while using .delay() or apply_async(). I am not getting the predicted response

#views.py
@api_view(['GET'])
def result(request):
    response = {}
    solute = request.GET.get('solute')
    solvent = request.GET.get('solvent')
    results = predictions.apply_async(args=(solute,solvent))
    print(results.get())
    return Response({'result': results.get()}, status=200)
#tasks.py
@shared_task(bind=True)
def predictions(self,solute, solvent):

    mol = Chem.MolFromSmiles(solute)
    mol = Chem.AddHs(mol)
    solute = Chem.MolToSmiles(mol)
    solute_graph = get_graph_from_smile(solute)

    mol = Chem.MolFromSmiles(solvent)
    mol = Chem.AddHs(mol)
    solvent = Chem.MolToSmiles(mol)
    solvent_graph = get_graph_from_smile(solvent)

I am getting problems while adding apply_async or delay() to predictions. I am getting TypeError("predictions() missing 1 required positional argument: 'solvent'") Error

harsh
  • 435
  • 2
  • 6
  • 13

1 Answers1

1

mainly:

apply_async(func: Callable[..., Any],args:Iterable[Any] etc)

read more

Mahamudul Hasan
  • 2,745
  • 2
  • 17
  • 26
  • Is it `requests` or `request`? using `request` I am getting `AttributeError at /predict/ 'Request' object has no attribute 'get'` Error @Mahamudul Hasan – harsh Jan 10 '22 at 05:06
  • using `requests` i am getting `NameError at /predict/ name 'requests' is not defined` Error – harsh Jan 10 '22 at 05:08