Repository navigation
Fix 31889: Extract MLflow 3.x model signatures and paginate the regis… - #32093
Conversation
…try listing (#32024) * fix(mlflow): read model signatures from the MLmodel file on MLflow 3.x MLflow 3.x dropped the `mlflow.log-model.history` run tag in favour of LoggedModel entities, so `data.tags["mlflow.log-model.history"]` raised KeyError on every model. The broad except swallowed it, leaving mlFeatures empty and emitting a spurious warning per model. No metadata API exposes the signature -- not the MLflow logged-model endpoint, nor either Unity Catalog model-version endpoint -- so it can only be read from the model's own MLmodel file. Fetch just that one file. `mlflow.models.get_model_info` is deliberately avoided: it resolves `models:/` URIs through MLflow's global tracking config, which this connector never sets, and it imports pandas, which mlflow-skinny does not ship. Both make it fail on Unity Catalog. Resolving the artifact location through the connector's own client and parsing the YAML with json avoids each. `mlflow.artifacts.load_text` would be tidier but takes no tracking_uri, so it hits the same global-config problem. A missing tag now logs at debug rather than warning, since it is the norm on 3.x, and a tag with no entry for the run falls through to the artifacts instead of returning early. Co-Authored-By: Claude Opus 5 <[email protected]> * fix(mlflow): stop a bad signature or partial listing from losing models Guard the ML-feature build: a malformed signature escaped yield_mlmodel, and the topology runner drops the entity without recording a failure, so the model vanished silently. Also skip deletion reconciliation when the registry listing was truncated, since models beyond the page budget would be wrongly marked deleted. Co-Authored-By: Claude Opus 5 <[email protected]> * fix(mlflow): never reconcile deletions off a listing we cannot trust Track listing completion positively instead of tracking truncation, and reset it per run, so an abandoned, failed or never-started listing fails closed rather than licensing soft-deletes. Also skip reconciliation when the registry listed no models at all -- a wrong `registryUri` or credentials that cannot list are indistinguishable from an emptied registry, and acting on it deletes every model under the service. * test(mlflow): cover an empty registry page that still carries a token The reporter's registry answered the first page with a token and no `registered_models` at all. The old single-call listing read that as an empty registry and reported a fully successful run over zero models. --------- Co-authored-by: Claude Opus 5 <[email protected]>
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
|
The Python checkstyle failed. Please run You can install the pre-commit hooks with |
|
The Java checkstyle failed. Please run You can install the pre-commit hooks with |
`TestCaseResolutionStatusResource` imports `CommonUtil.listOrEmpty` and `CommonUtil.nullOrEmpty` but no longer uses either, so `mvn spotless:check` fails and the `java-checkstyle` job is red for every PR targeting this branch -- #32095 and #32093 fail identically. The usages went away in #32017 while the imports stayed. Import-only change, produced by `mvn spotless:apply`; no logic touched. Needed here only so this backport can be validated. `main` needs no equivalent fix: both symbols are imported and used five times each in that file there. On `1.13` the imports do not exist. This is 2.0-only.
Code Review ✅ Approved 1 resolved / 1 findingsExtracts MLflow 3.x model signatures and adds pagination for registry listing. Consider avoiding global os.environ mutation in the progress-bar toggle to prevent side effects. ✅ 1 resolved✅ Quality: Progress-bar env toggle mutates global os.environ
OptionsDisplay: compact → Showing less information. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
✅ Playwright Results — workflow succeededValidated commit ✅ 110 passed · ❌ 0 failed · 🟡 0 flaky · ⏭️ 0 skipped · 🧰 0 lifecycle flaky PerformanceBlocking targets: ✅ met · Optimization targets: 🟡 in progress Shard-job maxima below are not the full workflow wall time; the linked run includes build, fixture, planning, and reporting. 🕒 Full workflow signal wall (to summary) 45m 50s ⏱️ Max setup 2m 58s · max shard execution 11m 46s · max shard-job elapsed before upload 17m 0s · reporting 4s 🌐 210.95 requests/attempt · 1.79 app boots/UI scenario · 0.00% common-shard skew Optimization targets still in progress:
How to debug locally# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip # view trace |
…#32005) + scale the deploy-pipelines deadline (#31976) (#32101) * fix(airflow-apis): stop re-parsing the whole DAG folder on every pipeline deploy (#32005) * fix(airflow-apis): stop re-parsing the whole DAG folder on every deploy `get_dagbag` built a DagBag over the entire DAG folder and called `collect_dags`, so each deploy parsed every DAG in the deployment. That makes a single deploy cost O(total DAGs) and a bulk deploy O(total DAGs^2). On Airflow 2.x the folder was never actually walked: `read_dags_from_db=True` made both `collect_dags` and `collect_dags_from_db` early return, and DAGs came from the serialized-DAG table. The Airflow 3.x support gate dropped that kwarg, which turned an O(1) DB read into an O(N) filesystem walk. The deploy path does not need a populated bag. `refresh_session_dag` calls `process_file` on the DAG file it has just written and then asks for that single `dag_id`, and `process_file` bags the DAG itself. Build the bag with `collect_dags=False` instead. The kwarg exists on DagBag in both Airflow 2.x and 3.x, so the version branching goes away with it. The folder walk was also masking `process_file`: `collect_dags` stamps `file_last_changed` for every file it walks, including the one just written, so the following `process_file` hit its `only_if_updated` early return and returned no dags. The DAG was bagged by the folder walk as a side effect rather than by the call that intends to bag it. The pre-fix test run confirms this - `found_dags` did not contain the deployed dag. Drop the `dagbag size` log line, which would now always report 0. The adjacent `processed dags` line carries the same signal and starts reporting the real dag. The per-deploy `DagFileProcessorManager` fork in `scan_dags_job_background` is left alone deliberately. On Airflow 3 `DAG.sync_to_db` delegates to `bulk_write_to_db`, which writes DagModel and asset rows but does not call `SerializedDagModel.write_dag`, so that scan is what serializes a newly deployed DAG. Removing or skipping it would leave deployed pipelines unrunnable. Tests: `tests/unit/ingestion_pipeline/test_get_dagbag.py` - the bag comes back empty over a populated folder, `collect_dags` is never called, and `process_file` still bags the deployed DAG and only that DAG. All three fail before this change. * fix(airflow-apis): keep the pre-3.0 DagBag path unchanged `collect_dags` was only added to `DagBag.__init__` in Airflow 2.5 (absent in 2.4.0, present in 2.5.3), and the plugin declares `apache-airflow>=2.2.2`, so passing it unconditionally raised `TypeError` on 2.2 through 2.4 and failed every deploy there. Scope the change to Airflow >= 3.0, which is where the regression is. Below 3.0 the bag is still built with `read_dags_from_db=True`, which early returns out of `collect_dags`, so that path never walked the DAG folder and needs no change. Gate the new tests on Airflow 3 for the same reason. * fix(airflow-apis): unblock airflow-apis-tests on Airflow 3.3 `TestAirflowOps.setUpClass` passed `include_examples=False` to `DagBag`. Airflow 3.3 dropped that keyword -- DAG discovery is bundle based there, so example DAGs are no longer a constructor flag -- and Python raises `TypeError` for an unknown keyword. The call is in class setup, so all three tests in the class error before running. This is unrelated to the DagBag change in this branch: the test builds its own DagBag and never calls `get_dagbag`. It broke when the Airflow pin moved from 3.2.2 to 3.3.0 in #31338, and has failed on every branch that reached this job since. Fixed here only because the job has to be green for this branch to be validated; happy to split it out. Detect the keyword instead of assuming it, matching the `sync_to_db` and `bag_dag` compatibility checks already in this setup, so the test keeps working on Airflow 2.x and on 3.x. Not changed: the workflow's `paths` filter still only watches `openmetadata-airflow-apis/**`, so a pin bump in `ingestion/setup.py` cannot trigger the suite it affects -- which is why this went unnoticed. Widening it would run a 24 minute docker-stack job on a file that changed 26 times in the last 90 days against this module's 5, so that tradeoff is left to maintainers. * fix(ops): scale the deploy-pipelines chunk deadline with the chunk size (#31976) * fix(ops): scale the deploy-pipelines chunk deadline with the chunk size deploy-pipelines POSTs chunks of pipeline IDs to the bulk deploy endpoint, which registers each pipeline sequentially, but bounded the request with a fixed 2 minute deadline. At the default chunk size of 20 that budgets 6 seconds per pipeline, which a freshly restarted pipeline service does not meet, so the client abandoned requests whose work was still progressing. A client deadline does not cancel the server, so the abandoned chunk kept deploying while the command marked all 20 pipelines FAILED and exited 1. A Kubernetes restartPolicy of OnFailure then replayed the whole run on top of work still in flight, adding load to an operation that was already succeeding. On a catalog of 92 pipelines this reported failure while 90 were deployed. Budget the deadline per pipeline and multiply by the chunk size, so it no longer silently becomes too short as a catalog grows, and expose the chunk size and the per-pipeline budget as options. The command previously accepted none, so neither value was reachable from a deployment configuration. Extract the deadline calculation and the failure check as static functions so the scaling and the exit code are unit testable without a database. Reporting is left unchanged: an abandoned chunk is still recorded as failed. The persisted deployed flag cannot correct it, because the deploy path only ever sets it to true and never resets it, so it records whether a pipeline was ever deployed rather than what this run did. Reading it to clear a timeout would turn a genuine failure into a silent success on any redeploy. A per-run answer needs the deploy response itself, which is a separate change. * fix(ops): reject a non-positive deploy-pipelines chunk size Exposing --chunk-size made a value that was previously hardcoded to 20 reachable from outside, and chunkList advances its loop with i += chunkSize. A chunk size of 0 never advances, appending empty chunks until the heap is exhausted, and a negative size makes subList throw, which the surrounding handler turns into every pipeline being reported as FAILED. Validate both options before the deploy runs and report each offending value, rather than clamping, so a mistyped flag is not silently replaced by a different deadline. Guard chunkList as well, so a non-positive size fails loudly instead of spinning if another caller ever skips validation. A non-positive --seconds-per-pipeline was already safe, since the deadline floors at the previous fixed 2 minutes, but it is rejected too rather than silently falling back to the deadline this option exists to move away from. Drops the deployChunkTimeout(0, 30) assertion, which implied a chunk size of 0 was supported when it now fails validation. * test(ops): cover picocli binding for the deploy-pipelines options Parsing the command with picocli asserts the new options bind to the values passed on the command line and that the declared defaults still match the 20 and 30 the description documents. Neither was covered: the existing tests call the helpers directly, so a mistyped option name or a default drifting from its description would not have failed anything. Reads the defaults from the command spec rather than the parse result, since matchedOptionValue only reports options actually present on the command line. Needs no database, so it stays a unit test. * style: drop unused static imports flagged by spotless on 2.0 `TestCaseResolutionStatusResource` imports `CommonUtil.listOrEmpty` and `CommonUtil.nullOrEmpty` but no longer uses either, so `mvn spotless:check` fails and the `java-checkstyle` job is red for every PR targeting this branch -- #32095 and #32093 fail identically. The usages went away in #32017 while the imports stayed. Import-only change, produced by `mvn spotless:apply`; no logic touched. Needed here only so this backport can be validated. `main` needs no equivalent fix: both symbols are imported and used five times each in that file there. On `1.13` the imports do not exist. This is 2.0-only.
cherry-picking 9487c78 from main
Summary by Gitar
MLmodelmetadata files when run tags are absentMAX_MODEL_PAGESThis will update automatically on new commits.
Greptile Summary
The PR adds MLflow 3.x signature extraction from
MLmodelartifacts and paginates registry/model-version discovery while attempting to make deletion reconciliation safer.Confidence Score: 4/5
The PR should not merge until deletion reconciliation is suppressed when any listed model fails to enter the live source state.
A complete registry pagination walk can contain models that are skipped because version or run-ID resolution fails; the new guard still runs reconciliation and can soft-delete those models from OpenMetadata even though they remain in MLflow.
Files Needing Attention: ingestion/src/metadata/ingestion/source/mlmodel/mlflow/metadata.py
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Paginate MLflow registry] --> B{Listing complete and nonempty?} B -- No --> C[Skip deletion reconciliation] B -- Yes --> D[Resolve each model version] D --> E{Version and run ID available?} E -- Yes --> F[Yield model and register live state] E -- No --> G[Record model failure] F --> H[Reconcile stale models] G --> H H --> I[Failed listed model may be soft-deleted]Reviews (2): Last reviewed commit: "Merge branch '2.0' into fix/mlflow_featu..." | Re-trigger Greptile
Context used: