mlflow: [BUG]load_model not found error

Issues Policy acknowledgement

  • I have read and agree to submit bug reports in accordance with the issues policy

Willingness to contribute

Yes. I can contribute a fix for this bug independently.

MLflow version

  • Client: 2.0.1
  • Tracking server: 1.23.1

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10 Enterprise 21H2
  • **Python version **: 3.10
  • yarn version, if running the dev UI:

Describe the problem

I have registered a model to mlflow model registry.

When I call ‘load_model’ function to try to fetch the model from model registry and try to make prediction, mlflow cannot find the model from the model name and version number I provided:

model_name = "sample-ann-1"
version = 1
loaded_model = mlflow.pyfunc.load_model("models:/{}/{}".format(model_name, version))

And return the following error:

"mlflow.exceptions.MlflowException: The following failures occurred while downloading one or more artifacts from s3://{bucket}/5/8429aef5d8304990ae035c638db093e7/artifacts/../saved-model/model20/: {'': "ClientError('An error occurred (404) when calling the HeadObject operation: Not Found')"}"

However, if I provide the artifact path(s3://{bucket}/5/8429aef5d8304990ae035c638db093e7/artifacts/…/saved-model/model20/) to “load_model” API, it will find and fetch the model

When I open s3 browser to check the file in artifact path (s3://{bucket}/5/8429aef5d8304990ae035c638db093e7/artifacts/…/saved-model/model20/), I found the model is in the path, not sure why mlflow return 404 not found error if I only provide model name and version. image

Tracking information

REPLACE_ME

Code to reproduce issue

import mlflow

tracking_url = “{tracking url}” mlflow.set_tracking_uri(tracking_url)

mlflow.set_experiment(‘test_mlflow’) loaded_model = mlflow.pyfunc.load_model(“models:/sample-ann-1/1”)

Stack trace

Traceback (most recent call last):
  File "C:\PycharmProjects\ml-flow-project-example2\model\load-registered-model.py", line 23, in <module>
    loaded_model = mlflow.pyfunc.load_model("models:/{}/{}".format(model_name, version))
  File "C:\PycharmProjects\ml-flow-project-example2\venv\lib\site-packages\mlflow\pyfunc\__init__.py", line 509, in load_model
    local_path = _download_artifact_from_uri(artifact_uri=model_uri, output_path=dst_path)
  File "C:\PycharmProjects\ml-flow-project-example2\venv\lib\site-packages\mlflow\tracking\artifact_utils.py", line 100, in _download_artifact_from_uri
    return get_artifact_repository(artifact_uri=root_uri).download_artifacts(
  File "C:\PycharmProjects\ml-flow-project-example2\venv\lib\site-packages\mlflow\store\artifact\models_artifact_repo.py", line 126, in download_artifacts
    return self.repo.download_artifacts(artifact_path, dst_path)
  File "C:\PycharmProjects\ml-flow-project-example2\venv\lib\site-packages\mlflow\store\artifact\artifact_repo.py", line 263, in download_artifacts
    raise MlflowException(
mlflow.exceptions.MlflowException: The following failures occurred while downloading one or more artifacts from s3://{bucket}/5/8429aef5d8304990ae035c638db093e7/artifacts/../saved-model/model20/: {'': "ClientError('An error occurred (404) when calling the HeadObject operation: Not Found')"}

Other info / logs

REPLACE_ME

What component(s) does this bug affect?

  • area/artifacts: Artifact stores and artifact logging
  • area/build: Build and test infrastructure for MLflow
  • area/docs: MLflow documentation pages
  • area/examples: Example code
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/recipes: Recipes, Recipe APIs, Recipe configs, Recipe Templates
  • area/projects: MLproject format, project running backends
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/server-infra: MLflow Tracking server backend
  • area/tracking: Tracking Service, tracking client APIs, autologging

What interface(s) does this bug affect?

  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/docker: Docker use across MLflow’s components, such as MLflow Projects and MLflow Models
  • area/sqlalchemy: Use of SQLAlchemy in the Tracking Service or Model Registry
  • area/windows: Windows support

What language(s) does this bug affect?

  • language/r: R APIs and clients
  • language/java: Java APIs and clients
  • language/new: Proposals for new client languages

What integration(s) does this bug affect?

  • integrations/azure: Azure and Azure ML integrations
  • integrations/sagemaker: SageMaker integrations
  • integrations/databricks: Databricks integrations

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 18 (6 by maintainers)

Most upvoted comments

Issue verified fixed! Thanks to both @xinglong700000 and @labradovy for reporting this issue and @bali0019 for the great set of PRs that fixed it! 😄

@labradovy we aim for approximately monthly releases (give or take a few weeks) and we’re gearing up for another release soon. No firm exact date as of yet, but it’s coming soon!

@labradovy it’s coming in the next 2 weeks.