I am using Django rest framework to do prediction on two strings and using celery to run inference. But I was unable to make use of celery workers even though I have done everything perfectly. I am getting predictions from drf only
I am using redis as a broker.
My 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)
delta_g, interaction_map = model([solute_graph.to(device), solvent_graph.to(device)])
return delta_g, torch.trunc(interaction_map)
My views.py
@api_view(['GET'])
def result(request):
response = {}
solute = request.GET.get('solute')
solvent = request.GET.get('solvent')
results = predictions(solute,solvent)
response["interaction_map"] = (results[1].detach().numpy()).tolist()
response["predictions"] = results[0].item()
return Response({'result': response}, status=200)
I guess the problem is not adding .delay() to results = predictions(solute,solvent) but if I add results = predictions(solute,solvent).delay() I am getting error.
Even though I am getting my prediction perfectly without any error their is no celery task is running please help me where I am doing wrong

results = predictions(solute,solvent).delay()i am getting errorpredictions() missing 2 required positional arguments: 'solute' and 'solvent'but i am passing solute and solvent @BrianDesturadelay, it should be:predictions.delay(solute,solvent)'AsyncResult' object is not subscriptableerrorresults.get()to get the result