test(ingestion): cover newest-version selection in the Mlflow source#30198
test(ingestion): cover newest-version selection in the Mlflow source#30198IceS2 wants to merge 4 commits into
Conversation
Fixes #30189 Select the newest registered model version by version number. Matching the parent's last_updated_timestamp only held while the version creation was the last write to the registered model; any later edit to its description, tags or aliases desynced the two and silently dropped the model. Point the Playwright Mlflow connection at sqlite backends. The placeholder strings resolved to MLflow's file store, which 3.13+ rejects, so the AutoPilot agent failed to connect and the run-completed banner never rendered.
search_registered_models returns a list of RegisteredModel, but the cast claimed the collection itself was one. Iterating a RegisteredModel yields its property pairs, so basedpyright inferred the loop variable as tuple[str, Any] and rejected every attribute access on it. The cast was a no-op at runtime. Modernize the annotations to PEP 585/604 while here, which retires the UP006, UP035 and UP045 suppressions rather than moving them.
Register a second model version with distinct hyperparameters and assert the ingested entity carries the newest version's run, not the older one's. Without this the fixture created a single version, so a matcher that selected a stale version would still pass. Extract the log-model retry into a helper shared by both versions.
| raise | ||
| log_registered_model(lr, signature) | ||
|
|
||
| # Describing the model bumps RegisteredModel.last_updated_timestamp past the |
There was a problem hiding this comment.
💡 Quality: Duplicated update_registered_model call and comment
Lines 179-181 are a verbatim copy of the block at 175-177 (same comment, same update_registered_model call). The second call is redundant — it re-applies the identical description and adds no coverage. Remove the duplicated block to keep the fixture clean.
Remove the duplicated update_registered_model block (lines 179-181).:
# Describing the model bumps RegisteredModel.last_updated_timestamp past the
# version's, which must not hide the version from the registry listing.
mlflow.MlflowClient().update_registered_model(MODEL_NAME, description=MODEL_DESCRIPTION)
- Apply fix
Check the box to apply the fix or reply for a change | Was this helpful? React with 👍 / 👎
Code Review 👍 Approved with suggestions 0 resolved / 1 findingsStrengthens MLflow ingestion tests by asserting the latest model version's run parameters. Consolidate the duplicated 💡 Quality: Duplicated update_registered_model call and comment📄 ingestion/tests/integration/sources/mlmodels/mlflow/test_mlflow.py:175-181 Lines 179-181 are a verbatim copy of the block at 175-177 (same comment, same Remove the duplicated update_registered_model block (lines 179-181).🤖 Prompt for agentsOptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
Follow-up to #30191, addressing a Greptile review comment: the Mlflow integration test created a single model version, so
max(..., key=version)was never exercised — a matcher that selected a stale version would still pass.What
Register a second model version with distinct hyperparameters (
alpha=0.2, l1_ratio=0.3), then assert the ingested entity carries the newest version's run (alpha=0.5, l1_ratio=1.0) and that the older version's values are absent. The log-model retry loop is extracted into a shared helper so both versions register through the same path.Key finding
RegisteredModel.latest_versionsreturns a single element — the newest version — even with many versions registered (verified against MLflow 3.10 and 3.14: three versions still yield a one-element list). Stages were the only thing that produced multiple entries, and they are deprecated. So the connector'smax()cannot be discriminated bymin-vs-maxno matter how many versions exist. What the second version does change is which run the connector reads (get_run(latest_version.run_id)), so asserting the ingested hyperparameters match the newest run is the meaningful coverage — it catches a regression that walked all versions and grabbed the oldest.Verified locally against the testcontainers stack: the strengthened test fails with the pre-fix connector (
Version not found) and passes with #30191's fix.Note
This branch is stacked on #30191 and currently contains its commits too; the diff narrows to just the test once #30191 merges. Draft until then.