mlflow/mlflow · error · MlflowException
Unable to load model metadata. Ensure the source path of the
Error message
Unable to load model metadata. Ensure the source path of the model being registered points to a valid MLflow model directory (see https://mlflow.org/docs/latest/models.html#storage-format) containing a model signature (https://mlflow.org/docs/latest/models.html#model-signature) specifying both input and output type specifications.
What it means
Before creating or validating a model version in Unity Catalog, MLflow loads the MLmodel metadata from the model's source directory and re-raises any failure as this MlflowException. The source must be a valid MLflow model directory whose MLmodel file is loadable and carries a signature with both input and output specs. The original exception is chained ('from e').
Source
Thrown at mlflow/store/_unity_catalog/registry/rest_store.py:244
def _raise_unsupported_method(method, message=None):
messages = [
f"Method '{method}' is unsupported for models in the Unity Catalog.",
]
if message is not None:
messages.append(message)
raise MlflowException(" ".join(messages))
def _load_model(local_model_dir):
# Import Model here instead of in the top level, to avoid circular import; the
# mlflow.models.model module imports from MLflow tracking, which triggers an import of
# this file during store registry initialization
from mlflow.models.model import Model
try:
return Model.load(local_model_dir)
except Exception as e:
raise MlflowException(
"Unable to load model metadata. Ensure the source path of the model "
"being registered points to a valid MLflow model directory "
"(see https://mlflow.org/docs/latest/models.html#storage-format) containing a "
"model signature (https://mlflow.org/docs/latest/models.html#model-signature) "
"specifying both input and output type specifications."
) from e
def get_feature_dependencies(model_dir):
"""
Gets the features which a model depends on. This functionality is only implemented on
Databricks. In OSS mlflow, the dependencies are always empty ("").
"""
model = _load_model(model_dir)
if (
model.flavors.get("python_function", {}).get("loader_module")
== mlflow.models.model._DATABRICKS_FS_LOADER_MODULE
):View on GitHub (pinned to 6a27f2decc)
Solutions
- Log the model with a flavor API (e.g. mlflow.sklearn.log_model) including infer_signature(input, output) so MLmodel and signature exist
- Verify the source path points to a directory containing a valid MLmodel file (inspect it locally after downloading artifacts)
- If registering from run artifacts, pass the correct runs:/<run_id>/<artifact_path> source rather than a custom path
Example fix
// before
with mlflow.start_run():
mlflow.log_artifact("model.pkl", "model")
client.create_model_version("m", "runs:/<run>/model")
// after
with mlflow.start_run():
mlflow.sklearn.log_model(sk_model, "model", signature=infer_signature(X, preds))
client.create_model_version("m", f"runs:/{run.info.run_id}/model") Defensive patterns
Strategy: validation
Validate before calling
import os
from mlflow.models import Model
def validate_model_source(model_dir):
mlmodel = os.path.join(model_dir, "MLmodel")
assert os.path.isfile(mlmodel), f"No MLmodel at {model_dir}"
m = Model.load(model_dir)
assert m.signature and m.signature.inputs and m.signature.outputs, "Model must have input and output signature" Try / catch
try:
client.create_model_version(name, source)
except MlflowException as e:
if "Unable to load model metadata" in str(e):
raise RuntimeError(f"Re-log the model with a flavor API and infer_signature; bad source: {source}") from e
raise Prevention
- Always log via flavor APIs (mlflow.*.log_model), never raw artifact copies
- Include infer_signature(input, output) at logging time
- Inspect MLmodel locally before registering to UC
When it happens
Trigger: Registering a model (or querying feature/model-version dependencies) in UC where the artifact source is not a valid MLflow model directory, the MLmodel file is missing/corrupt, or the signature is absent/incomplete.
Common situations: Registering raw artifacts (e.g. a bare pickle or checkpoint dir) instead of an mlflow.*.log_model output; manually edited or truncated MLmodel files; logging models without an explicit or inferred signature.
Related errors
- UC Model Versions gathered through search_model_versions do
- UC Model Versions gathered through search_model_versions do
- UC Registered Models gathered through search_registered_mode
- UC Registered Models gathered through search_registered_mode
- Argument '{arg_name}' is unsupported for models in the Unity
AI-assisted analysis of mlflow/mlflow@6a27f2decc (2026-08-29).
Data as JSON: /api/errors/ddcece9fcb2b4e2d.
Report an issue: GitHub.