Skip to content

[FIX] MLflow 3.x connector fails to extract features due to removed tag - #31920

Closed
zhang-arvin wants to merge 1 commit into
open-metadata:mainfrom
zhang-arvin:fix/mlflow-3x-feature-extraction
Closed

zhang-arvin wants to merge 1 commit into
open-metadata:mainfrom
zhang-arvin:fix/mlflow-3x-feature-extraction

Conversation

@zhang-arvin

@zhang-arvin zhang-arvin commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes

Fix MLflow connector failing to extract model features (mlFeatures) on MLflow 3.x due to the removed mlflow.log-model.history tag.

Changes

  • Backward compatible: Use data.tags.get("mlflow.log-model.history") instead of direct key access to avoid KeyError on MLflow 3.x
  • MLflow 3.x fallback: When the tag is absent, fall back to mlflow.models.get_model_info() to read the model signature directly from the MLmodel file
  • Extract features from ColSpec objects in the model's input schema

Related issue

Closes #31889

Type of change

  • Bug fix

Greptile Summary

The PR adds an MLflow 3.x feature-extraction fallback that reads model signatures from model info when the legacy history tag is unavailable.

  • Passes the selected model version source into feature extraction.
  • Converts signature ColSpec inputs into OpenMetadata ML features.
  • Moves the fallback outside the outer tags guard, although one legacy-history branch still bypasses it.

Confidence Score: 4/5

The PR is not yet safe to merge because a present legacy history tag without the selected run ID still prevents the new fallback from extracting features.

The empty-tags path now reaches model info, but the retained early return for an unmatched history entry leaves the previously reported missing-feature failure reachable.

Files Needing Attention: ingestion/src/metadata/ingestion/source/mlmodel/mlflow/metadata.py

Important Files Changed

Filename Overview
ingestion/src/metadata/ingestion/source/mlmodel/mlflow/metadata.py Adds the MLflow 3.x model-info fallback, but a history tag without the selected run ID still exits before that fallback.

Reviews (3): Last reviewed commit: "Merge branch 'main' into fix/mlflow-3x-f..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

@zhang-arvin
zhang-arvin requested a review from a team as a code owner August 23, 2026 06:27
@github-actions

github-actions Bot commented Aug 23, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR checks passed

The linked issue has a description and all required Shipping project fields set. Thanks!

@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@zhang-arvin

Copy link
Copy Markdown
Contributor Author

Thanks for the review @gitar-bot! Fixed both issues:

  1. col.type comparison: Changed col.type == "string" → col.type == DataType.string (with proper import)
  2. Fallback reachability: Moved the _get_ml_features_from_model_info call outside the if data.tags: block so it runs even when tags are empty

Force-pushed the fix.

@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@gitar-bot

gitar-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown
Code Review ✅ Approved 2 resolved / 2 findings

Adds an MLflow 3.x feature extraction fallback using model-info signatures, addressing the unreachable fallback and column type comparison findings. Changes are approved.

✅ 2 resolved
✅ Bug: col.type == "string" never matches; all features numerical

📄 ingestion/src/metadata/ingestion/source/mlmodel/mlflow/metadata.py:318
ColSpec.type is a mlflow.types.schema.DataType enum member, not a string (DataType does not inherit from str), so col.type == "string" always evaluates to False. Since ingestion pins mlflow-skinny>=3.13.0,<3.15 this new MLflow 3.x fallback path always classifies every feature as FeatureType.numerical, and string columns are never detected as categorical. Compare against the enum instead, e.g. col.type == DataType.string or col.type.name == "string".

✅ Bug: MLflow 3.x fallback unreachable when run has no tags

📄 ingestion/src/metadata/ingestion/source/mlmodel/mlflow/metadata.py:262 📄 ingestion/src/metadata/ingestion/source/mlmodel/mlflow/metadata.py:285-287
The MLflow 3.x fallback to _get_ml_features_from_model_info is nested inside if data.tags:, so it only runs when the run has at least one tag. If a MLflow 3.x run has empty/absent data.tags, the method returns None and never reads the model signature — defeating the fix's purpose. Move the fallback so it is invoked whenever the mlflow.log-model.history tag is missing regardless of whether data.tags is populated.

Options

Display: compact → Showing less information.

Comment with these commands to change the behavior for this request:

Compact
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source

@zhang-arvin

Copy link
Copy Markdown
Contributor Author

@open-metadata/developers Could you please add the safe to test label to trigger CI? The gitar-bot findings have been addressed in the latest commit. Thanks!

@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@harshsoni2024 harshsoni2024 added Ingestion safe to test Add this label to run secure Github workflows on PRs labels Aug 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

The Python checkstyle failed.

Please run make py_format and py_format_check in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Python code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

Comment on lines +268 to +272
if not latest_props:
reason = f"Cannot find the run ID properties for {run_id}"
logger.warning(reason)
self.status.warning(model_name, reason)
return None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 History miss bypasses fallback

When the legacy history tag contains no entry for the selected run ID, this branch returns before _get_ml_features_from_model_info runs, causing mlFeatures to remain unset despite an available model source and MLmodel signature.

Suggested change
if not latest_props:
reason = f"Cannot find the run ID properties for {run_id}"
logger.warning(reason)
self.status.warning(model_name, reason)
return None
if not latest_props:
reason = f"Cannot find the run ID properties for {run_id}"
logger.warning(reason)
self.status.warning(model_name, reason)

@zhang-arvin
zhang-arvin force-pushed the fix/mlflow-3x-feature-extraction branch from fe46ef9 to 4d497f4 Compare August 27, 2026 01:51
@github-actions github-actions Bot removed the safe to test Add this label to run secure Github workflows on PRs label Aug 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@zhang-arvin

Copy link
Copy Markdown
Contributor Author

Fixed the Python checkstyle issue — replaced the for loop with a list comprehension (PERF401) and ran ruff format. CI should pass now.

@greptile-apps

greptile-apps Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Too many files changed for review (3000 files, 100 file limit).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MLflow connector fails to extract features on MLflow 3.x due to removed mlflow.log-model.history tag

2 participants