Created
January 12, 2021 01:02
-
-
Save amogkam/8bc58e98cb34f44c67d63c30e7a59c7d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ray | |
from ray import serve | |
import mlflow.pyfunc | |
class MLflowBackend: | |
def __init__(self, model_uri): | |
self.model = mlflow.pyfunc.load_model(model_uri=model_uri) | |
async def __call__(self, request): | |
return self.model.predict(request.data) | |
ray.init() | |
client = serve.start() | |
# This can be the same checkpoint that was saved by MLflow Tracking | |
model_uri = "/Users/ray_user/my_mlflow_model" | |
# Or you can load a model from the MLflow model registry | |
model_uri = "model:/my_registered_model/Production" | |
client.create_backend("mlflow_backend", MLflowBackend, model_uri) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment