Skip to content

Commit

Permalink
Added logging of scored instances for batch-transform. (awslabs#1010)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jasper authored and kashif committed Oct 10, 2020
1 parent 307f70b commit a143eda
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/gluonts/shell/serve/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ def batch_inference_invocations(
) -> Callable[[], Response]:
predictor = predictor_factory({"configuration": configuration.dict()})

scored_instances = []
last_scored = [time.time()]

def invocations() -> Response:
request_data = request.data.decode("utf8").strip()

Expand Down Expand Up @@ -209,6 +212,17 @@ def invocations() -> Response:
else:
predictions = make_predictions(predictor, dataset, configuration)

scored_instances.append(len(predictions))
N = 60
diff = time.time() - last_scored[0]
if diff > N:
logger.info(
f"Worker {os.getpid()} Scored {sum(scored_instances)} in last "
f"{int(diff)} seconds."
)
scored_instances.clear()
last_scored[0] = time.time()

lines = list(map(json.dumps, map(jsonify_floats, predictions)))
return Response("\n".join(lines), mimetype="application/jsonlines")

Expand Down

0 comments on commit a143eda

Please sign in to comment.