Skip to content

Fix mlflow gc to remove model artifacts#17282

Merged
B-Step62 merged 14 commits intomlflow:masterfrom
joelrobin18:fix-17240
Nov 24, 2025
Merged

Fix mlflow gc to remove model artifacts#17282
B-Step62 merged 14 commits intomlflow:masterfrom
joelrobin18:fix-17240

Conversation

@joelrobin18
Copy link
Collaborator

@joelrobin18 joelrobin18 commented Aug 19, 2025

🛠 DevTools 🛠

Open in GitHub Codespaces

Install mlflow from this PR

# mlflow
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/17282/merge
# mlflow-skinny
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/17282/merge#subdirectory=libs/skinny

For Databricks, use the following command:

%sh curl -LsSf https://raw.githubusercontent.com/mlflow/mlflow/HEAD/dev/install-skinny.sh | sh -s pull/17282/merge

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?

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests
Screenshot 2025-08-19 at 9 49 45 AM Screenshot 2025-08-19 at 9 57 25 AM

Does this PR require documentation update?

  • No. You can skip the rest of this section.
  • Yes. I've updated:
    • Examples
    • API references
    • Instructions

Release Notes

Is this a user-facing change?

  • No. You can skip the rest of this section.
  • Yes. Give a description of this change to be included in the release notes for MLflow users.

What component(s), interfaces, languages, and integrations does this PR affect?

Components

  • area/tracking: Tracking Service, tracking client APIs, autologging
  • area/models: MLmodel format, model serialization/deserialization, flavors
  • area/model-registry: Model Registry service, APIs, and the fluent client calls for Model Registry
  • area/scoring: MLflow Model server, model deployment tools, Spark UDFs
  • area/evaluation: MLflow model evaluation features, evaluation metrics, and evaluation workflows
  • area/gateway: MLflow AI Gateway client APIs, server, and third-party integrations
  • area/prompts: MLflow prompt engineering features, prompt templates, and prompt management
  • area/tracing: MLflow Tracing features, tracing APIs, and LLM tracing functionality
  • area/projects: MLproject format, project running backends
  • area/uiux: Front-end, user experience, plotting, JavaScript, JavaScript dev server
  • area/build: Build and test infrastructure for MLflow
  • area/docs: MLflow documentation pages

How 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" section
  • rn/breaking-change - The PR will be mentioned in the "Breaking Changes" section
  • rn/feature - A new user-facing feature worth mentioning in the release notes
  • rn/bug-fix - A user-facing bug fix worth mentioning in the release notes
  • rn/documentation - A user-facing documentation change worth mentioning in the release notes

Should this PR be included in the next patch release?

Yes should be selected for bug fixes, documentation updates, and other small changes. No should 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?
  • Minor release: a release that increments the second part of the version number (e.g., 1.2.0 -> 1.3.0).
    Bug fixes, doc updates and new features usually go into minor releases.
  • Patch release: a release that increments the third part of the version number (e.g., 1.2.0 -> 1.2.1).
    Bug fixes and doc updates usually go into patch releases.
  • Yes (this PR will be cherry-picked and included in the next patch release)
  • No (this PR will be included in the next minor release)

Signed-off-by: joelrobin18 <joelrobin1818@gmail.com>
@github-actions github-actions bot added v3.3.0 area/build Build and test infrastructure for MLflow rn/bug-fix Mention under Bug Fixes in Changelogs. labels Aug 19, 2025
Signed-off-by: joelrobin18 <joelrobin1818@gmail.com>
@joelrobin18
Copy link
Collaborator Author

@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>
Signed-off-by: joelrobin18 <joelrobin1818@gmail.com>
@B-Step62 B-Step62 removed the v3.3.0 label Aug 19, 2025
Signed-off-by: joelrobin18 <joelrobin1818@gmail.com>
Signed-off-by: joelrobin18 <joelrobin1818@gmail.com>
@joelrobin18
Copy link
Collaborator Author

@TomeHirata @harupy Could you please review this PR? Thanks!

@TomeHirata TomeHirata requested a review from Copilot September 17, 2025 04:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 gc CLI command
  • Implements _hard_delete_logged_model and _get_deleted_logged_models methods 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.

error_code=INVALID_PARAMETER_VALUE,
)
artifact_repo = get_artifact_repository(run.info.artifact_uri)
def _delete_with_artifacts(artifact_uri, delete_fn, entity_desc):
Copy link
Collaborator

@TomeHirata TomeHirata Sep 17, 2025

Choose a reason for hiding this comment

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

We probably don't need to combine artifact deletion, entity deletion, and description display. Can we simply define a function for artifact deletion only?

Signed-off-by: joelrobin18 <joelrobin1818@gmail.com>
Signed-off-by: joelrobin18 <joelrobin1818@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Sep 29, 2025

Documentation preview for 2165452 is available at:

More info
  • Ignore this comment if this PR does not change the documentation.
  • The preview is updated when a new commit is pushed to this PR.
  • This comment was created by this workflow run.
  • The documentation was built by this workflow run.

The fetched model.
"""
return LoggedModel.from_dictionary(self._get_model_dict(model_id))
if not allow_deleted:
Copy link
Collaborator

@B-Step62 B-Step62 Sep 29, 2025

Choose a reason for hiding this comment

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

@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.

@B-Step62 B-Step62 self-assigned this Nov 19, 2025
Copy link
Collaborator

@B-Step62 B-Step62 left a comment

Choose a reason for hiding this comment

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

LGTM

Signed-off-by: joelrobin18 <joelrobin1818@gmail.com>
@B-Step62 B-Step62 added this pull request to the merge queue Nov 24, 2025
Merged via the queue into mlflow:master with commit 6e1b7a6 Nov 24, 2025
46 checks passed
Tian-Sky-Lan pushed a commit to Tian-Sky-Lan/mlflow that referenced this pull request Nov 24, 2025
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Build and test infrastructure for MLflow rn/bug-fix Mention under Bug Fixes in Changelogs. v3.3.3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] mlflow gc not deleting model artifacts from object storage

4 participants