Hie, I have an created API in Django
class testAPI(APIView):
class InputSerializer(serializers.Serializer):
name = serializers.CharField(required=True)
serializer_class = InputSerializer
def post(self, request):
serializer = self.InputSerializer(data=request.data)
try:
serializer.is_valid(raise_exception=True)
except serializers.ValidationError as e:
return format_response(HTTP_400_BAD_REQUEST, errors=e.detail)
data = serializer.validated_data
return callingmyfunc(data["name"])
def callingmyfunc(name):
out = session.run(
f"""
MATCH (p:Label1)<--(o:Label2)
<--(i:Label3s)-[v]->(s:Label4s)-[q]->(a:Label5s)
MATCH (p:Label1)<--(o:Label2)<--
(i:Label3s)-[t]->(r:Label6s)
WHERE p.name = "{name}"
WITH o,p,q,r,s,t,a,i,v
ORDER BY t.order, v.order, q.order
WITH
{{Label5: a.name, Label5Id: a.Id,
docId: a.docId , Type: a.type,
Label5Order: q.order}} AS arts,
o,p,s,v,i,t,r
WITH
{{Label3: i.name,
Label3Id: i.Id}} AS Label3,
{{TemplateName: o.name,
TemplateId: o.Id}} AS template,
{{Label6: r.name, Label6Id: r.Id}} AS Label6,
{{Label4: s.name,
Label4Id: s.Id,
Label5s:collect(arts)}} AS delta
WITH
Label3, template,
apoc.coll.toSet(collect(Label6)) AS Label6s,
apoc.coll.toSet(collect(delta)) AS alpha
RETURN {{Label3:Label3,
Label2: template,
Label6s: Label6s,
Label4s: alpha}} AS _"""
).data()
output = [x["_"] for x in out]
session.close()
return Response({"Output": output}, status=200)
When I load test it, I get multiple errors like "Generator already executing", "Buffer Error", and weirdly sometime "AttributeError". Sorry for the weird names in the code. Would be glad if someone can help me find the problem in the code, Thanks in advance.