Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Nepherhotep committed Nov 8, 2024
1 parent 76c4024 commit 8baddce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docker-xgboost-scikit-learn/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ ADD docker-xgboost-scikit-learn/logging.conf .

RUN poetry install --with inference

ENTRYPOINT ["poetry", "run", "python3", "run_inference_server.py"]
ENTRYPOINT ["poetry", "run", "python3", "run_inference_server.py"]
16 changes: 13 additions & 3 deletions docker-xgboost-scikit-learn/run_inference_server.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import json
import logging
import os

Expand Down Expand Up @@ -29,15 +30,24 @@ def load(self):
return self

def predict(self, inputs, *args, **kwargs):
logging.error(f"INPUTS: {inputs}")
logging.info(f"Predicting {len(inputs)} items")
logging.info("Executing prediction")
decoded_input = self.decode_input(inputs)

input_df = pd.DataFrame(inputs)
input_df = pd.DataFrame(decoded_input["instances"])

predictions = self.model.predict(input_df)
response = {"predictions": predictions.tolist()}
return response

def decode_input(self, input_data):
logging.info(f"ShiftAssignmentFFRModelPayloadType: {type(input_data)}")
if isinstance(input_data, (bytes, str)):
return json.loads(input_data)
elif isinstance(input_data, dict):
return input_data
else:
raise Exception(f"Unsupported payload type {type(input_data)}")


if __name__ == "__main__":
logging.config.fileConfig("logging.conf")
Expand Down

0 comments on commit 8baddce

Please sign in to comment.