I attempted to load the model from model registry but failed. Here is the details.
I create the experiment using mlflow.set_experiment()
experiment = mlflow.create_experiment(
name=exp_name,
artifact_location="artifact_location",
tags={"env":"dev", "version":"1.0.0"}
)
I used artifact_location
as my artifact directory. Which is located outside of /mlruns
.
Then I registered my best model in model registry with
best_run_id = best_run.run_id
model_uri = f"runs:/{best_run_id}/model"
mlflow.register_model(model_uri=model_uri,
name="cat_classifier")
After that I try to load the registered model with
model_name = "cat_classifier"
model_version = 1
model_uri = f"models:/{model_name}/{model_version}"
load_model = mlflow.pyfunc.load_model(model_uri)
but failed with the following error:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
Cell In[366], line 4
2 model_version = 1
3 model_uri = f"models:/{model_name}/{model_version}"
----> 4 load_model = mlflow.pyfunc.load_model(model_uri)
........
OSError: No such file or directory: '/home/User/workplace/cat/artifact_location/0eb40601413841e78f8b7b89fbf82be7/artifacts/models/.'
Then I checked /home/User/workplace/cat/artifact_location/0eb40601413841e78f8b7b89fbf82be7
which I did not found the /artifacts/models/.
, but I found
|-- model
|-- conda.yaml
|-- MLModel
|-- model.pkl
|-- python_env.yaml
|-- requirement.txt
Do I have done wrong by using artifact_location
as the new path, which cause the failure of loading the registered model?
MLFlow UI showed the registered model, which I assumed it existed physically. I even successfully did alias for it, but still failed to load.
How can I solved this path issue?