Reputation: 1
class Model_Wrapper(mlflow.pyfunc.PythonModel):
def __init__(self,):
self.model = None
def load_context(self,context):
self.model=mlflow.pyfunc.load_model(context.artifacts["Original_Model"])
def predict(self, context, model_input):
ss = self.model.sample(int(model_input.get("records")[0]))
return ss.to_json()
input format:
invocations url post method : {"inputs":{"records":[2]}}
Input to the invocation url is as expected and in the format of mlflow keywords. Output expected is dataframe.
Upvotes: 0
Views: 50
Reputation: 1
Use the code as it is... don't do any changes:
def predict(self, context, model_input):
tempPath = f"temp.{model_input.get("records")[0]}.csv"
ss = self.model.sample(int(model_input.get("records")[0]),output_file_path=tempPath)
if os.path.exists(tempPath):
os.remove(tempPath)
return ss.to_json()
Upvotes: 0