Fix mlflow gc to remove model artifacts#17282
Conversation
Signed-off-by: joelrobin18 <joelrobin1818@gmail.com>
|
@B-Step62 Could you please TAL this PR? Thanks! |
Signed-off-by: joelrobin18 <joelrobin1818@gmail.com>
Signed-off-by: joelrobin18 <joelrobin1818@gmail.com>
Signed-off-by: joelrobin18 <joelrobin1818@gmail.com>
|
@TomeHirata @harupy Could you please review this PR? Thanks! |
There was a problem hiding this comment.
Pull Request Overview
This PR implements support for garbage collection of logged model artifacts in MLflow, addressing issue #17240. The change extends the mlflow gc command to permanently delete logged models that are in the deleted lifecycle stage, similar to how it handles runs and experiments.
- Adds logged model garbage collection functionality to the
mlflow gcCLI command - Implements
_hard_delete_logged_modeland_get_deleted_logged_modelsmethods in both FileStore and SqlAlchemyStore - Adds comprehensive test coverage for the new logged model garbage collection features
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| mlflow/cli/init.py | Extends the gc command to support logged model deletion with new CLI options and deletion logic |
| mlflow/store/tracking/file_store.py | Implements logged model hard deletion and retrieval methods for file-based storage |
| mlflow/store/tracking/sqlalchemy_store.py | Implements logged model hard deletion and retrieval methods for SQL-based storage |
| tests/test_cli.py | Adds comprehensive test coverage for logged model garbage collection functionality |
| tests/store/tracking/test_file_store.py | Adds unit tests for FileStore logged model deletion methods |
| tests/store/tracking/test_sqlalchemy_store.py | Adds unit tests for SqlAlchemyStore logged model deletion methods |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
mlflow/cli/__init__.py
Outdated
| error_code=INVALID_PARAMETER_VALUE, | ||
| ) | ||
| artifact_repo = get_artifact_repository(run.info.artifact_uri) | ||
| def _delete_with_artifacts(artifact_uri, delete_fn, entity_desc): |
There was a problem hiding this comment.
We probably don't need to combine artifact deletion, entity deletion, and description display. Can we simply define a function for artifact deletion only?
0edf22a to
95ce8a7
Compare
|
Documentation preview for 2165452 is available at: More info
|
| The fetched model. | ||
| """ | ||
| return LoggedModel.from_dictionary(self._get_model_dict(model_id)) | ||
| if not allow_deleted: |
There was a problem hiding this comment.
@harupy @serena-ruan This allow_deleted here is added because get_logged_model raises an exception when the model is deleted. However, it is a bit interesting because other entities like runs/experiments/traces do not have this behavior, namely, does not raise for deleted ones. Do you remember is there any particular reason we have inconsistent behavior for logged models? Same for SQL store.
0f9a9df to
2165452
Compare
Signed-off-by: joelrobin18 <joelrobin1818@gmail.com> Co-authored-by: Yuki Watanabe <31463517+B-Step62@users.noreply.github.com> Signed-off-by: Tian Lan <sky.blue266000@gmail.com>
🛠 DevTools 🛠
Install mlflow from this PR
For Databricks, use the following command:
Related Issues/PRs
Fix #17240
What changes are proposed in this pull request?
Fix mlflow gc to remove model artifacts
How is this PR tested?
Does this PR require documentation update?
Release Notes
Is this a user-facing change?
What component(s), interfaces, languages, and integrations does this PR affect?
Components
area/tracking: Tracking Service, tracking client APIs, autologgingarea/models: MLmodel format, model serialization/deserialization, flavorsarea/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registryarea/scoring: MLflow Model server, model deployment tools, Spark UDFsarea/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflowsarea/gateway: MLflow AI Gateway client APIs, server, and third-party integrationsarea/prompts: MLflow prompt engineering features, prompt templates, and prompt managementarea/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionalityarea/projects: MLproject format, project running backendsarea/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev serverarea/build: Build and test infrastructure for MLflowarea/docs: MLflow documentation pagesHow should the PR be classified in the release notes? Choose one:
rn/none- No description will be included. The PR will be mentioned only by the PR number in the "Small Bugfixes and Documentation Updates" sectionrn/breaking-change- The PR will be mentioned in the "Breaking Changes" sectionrn/feature- A new user-facing feature worth mentioning in the release notesrn/bug-fix- A user-facing bug fix worth mentioning in the release notesrn/documentation- A user-facing documentation change worth mentioning in the release notesShould this PR be included in the next patch release?
Yesshould be selected for bug fixes, documentation updates, and other small changes.Noshould be selected for new features and larger changes. If you're unsure about the release classification of this PR, leave this unchecked to let the maintainers decide.What is a minor/patch release?
Bug fixes, doc updates and new features usually go into minor releases.
Bug fixes and doc updates usually go into patch releases.