SeldonIO / seldon-core

An MLOps framework to package, deploy, monitor and manage thousands of production machine learning models
https://www.seldon.io/tech/products/core/
Other
4.39k stars 833 forks source link

How to deploy local MLflow model to Minikube? #5750

Open arodindev opened 4 months ago

arodindev commented 4 months ago

For testing purposes I am using my local file storage for storing MLflow artifact folder and not a remote storage such as S3 or GS. For that im creating a PVC and reference it to the modelUri parameter.

My yaml looks as follows:

apiVersion: v1
kind: PersistentVolume
metadata:
  name: iris-model-pv
  namespace: seldon-system
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteMany
  hostPath:
    path: "/home/USER/mlflow/backend/artifacts/2/f64b3afb30a148acadc3f301310ce673/artifacts/iris-model"
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: iris-model-pvc
  namespace: seldon-system
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi
---
apiVersion: machinelearning.seldon.io/v1alpha2
kind: SeldonDeployment
metadata:
  name: iris-model-deployment
  namespace: seldon-system
spec:
  name: iris-model
  predictors:
  - graph:
      children: []
      implementation: MLFLOW_SERVER
      modelUri: pvc://iris-model-pvc/
      name: iris-model
    name: default
    replicas: 1

The hostPath is pointing to the MLflow folder which contains the artifacts MLmodel, model.pkl, etc. However, the container iris-model is throwing the following error:

Executing before-run script
---> Creating environment with Conda...
INFO:root:Copying contents of /mnt/models to local
INFO:root:Reading MLmodel file
Traceback (most recent call last):
  File "./conda_env_create.py", line 153, in <module>
    main(args)
  File "./conda_env_create.py", line 148, in main
    setup_env(model_folder)
  File "./conda_env_create.py", line 46, in setup_env
    mlmodel = read_mlmodel(model_folder)
  File "./conda_env_create.py", line 75, in read_mlmodel
    return _read_yaml(mlmodel_path)
  File "./conda_env_create.py", line 91, in _read_yaml
    with open(file_path, "r") as file:
FileNotFoundError: [Errno 2] No such file or directory: '/mnt/models/MLmodel'

The iris-model-model-initializer container completes, but did not transfer anything:

NOTICE: Config file "/.rclone.conf" not found - using defaults
INFO  : There was nothing to transfer
INFO  :
Transferred:                 0 B / 0 B, -, 0 B/s, ETA -
Elapsed time:         0.0s

I would appreciate support to get this to work.

vidya4499 commented 1 month ago

@arodindev i can help on this. Is the issue still exists ?

arodindev commented 1 month ago

@vidya4499 not really, but feel free to post any solution.