restore master
This commit is contained in:
parent
fd0e4dc3cf
commit
b8b84548ef
@ -3,7 +3,6 @@ import traceback
|
|||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
from flask import Flask, request, jsonify
|
from flask import Flask, request, jsonify
|
||||||
from prometheus_client import generate_latest, CollectorRegistry, Summary
|
|
||||||
|
|
||||||
from image_prediction.utils import get_logger
|
from image_prediction.utils import get_logger
|
||||||
|
|
||||||
@ -35,10 +34,6 @@ def wrap_in_process(func_to_wrap):
|
|||||||
|
|
||||||
def make_prediction_server(predict_fn: Callable):
|
def make_prediction_server(predict_fn: Callable):
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
registry = CollectorRegistry(auto_describe=True)
|
|
||||||
metric = Summary(
|
|
||||||
f"redactmanager_imageClassification_seconds", f"Time spent on image-service classification.", registry=registry
|
|
||||||
)
|
|
||||||
|
|
||||||
@app.route("/ready", methods=["GET"])
|
@app.route("/ready", methods=["GET"])
|
||||||
def ready():
|
def ready():
|
||||||
@ -59,7 +54,6 @@ def make_prediction_server(predict_fn: Callable):
|
|||||||
|
|
||||||
@app.route("/predict", methods=["POST"])
|
@app.route("/predict", methods=["POST"])
|
||||||
@app.route("/", methods=["POST"])
|
@app.route("/", methods=["POST"])
|
||||||
@metric.time()
|
|
||||||
def predict():
|
def predict():
|
||||||
|
|
||||||
# Tensorflow does not free RAM. Workaround: Run prediction function (which instantiates a model) in sub-process.
|
# Tensorflow does not free RAM. Workaround: Run prediction function (which instantiates a model) in sub-process.
|
||||||
@ -77,8 +71,4 @@ def make_prediction_server(predict_fn: Callable):
|
|||||||
logger.error("Analysis failed.")
|
logger.error("Analysis failed.")
|
||||||
return __failure()
|
return __failure()
|
||||||
|
|
||||||
@app.route("/prometheus", methods=["GET"])
|
|
||||||
def prometheus():
|
|
||||||
return generate_latest(registry=registry)
|
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|||||||
@ -21,4 +21,3 @@ Pillow==9.1.0
|
|||||||
PDFNetPython3==9.1.0
|
PDFNetPython3==9.1.0
|
||||||
pdf2image==1.16.0
|
pdf2image==1.16.0
|
||||||
frozendict==2.3.0
|
frozendict==2.3.0
|
||||||
prometheus-client==0.13.1
|
|
||||||
Loading…
x
Reference in New Issue
Block a user