INNER CODE UNIT · Python
healthcheck
kiri-art/docker-diffusers-api · api/server.py:27
def healthcheck(request):
# dependency free way to check if GPU is visible
gpu = False
out = subprocess.run("nvidia-smi", shell=True)
if out.returncode == 0: # success state on shell command
gpu = True
return response.json({"state": "healthy", "gpu": gpu})
# Inference POST handler at '/' is called for every http call from Banana
@server.route("/", methods=["POST"])
async def inference(request):
try:
all_inputs = response.json.loads(request.json)
except:
all_inputs = request.json