Skip to content

Add --max-results option to mlflow experiments search#19359

Merged
BenWilson2 merged 5 commits intomlflow:masterfrom
alkispoly-db:mlflow-experiment-search-max-results
Dec 15, 2025
Merged

Add --max-results option to mlflow experiments search#19359
BenWilson2 merged 5 commits intomlflow:masterfrom
alkispoly-db:mlflow-experiment-search-max-results

Conversation

@alkispoly-db
Copy link
Collaborator

@alkispoly-db alkispoly-db commented Dec 12, 2025

🛠 DevTools 🛠

Open in GitHub Codespaces

Install mlflow from this PR

# mlflow
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/19359/merge
# mlflow-skinny
pip install git+https://github.com/mlflow/mlflow.git@refs/pull/19359/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/19359/merge

Related Issues/PRs

N/A

What changes are proposed in this pull request?

This PR adds a --max-results option to the mlflow experiments search CLI command, allowing users to limit the number of experiments returned. The backend API already supports this parameter; this change exposes it through the CLI.

Key features:

  • New --max-results CLI option with integer validation
  • Validates non-negative values with clear error messages
  • Default behavior unchanged (returns all experiments when not specified)
  • Fully backward compatible

How is this PR tested?

  • Existing unit/integration tests
  • New unit/integration tests
  • Manual tests

New tests added:

  • Parametrized tests for default, explicit values, and combined flags
  • Edge case test for zero value
  • Validation test for negative values
  • Parameter introspection test

Manual testing:

# Test with Databricks backend
export MLFLOW_TRACKING_URI="..."

# Returns exactly 5 experiments
mlflow experiments search --max-results 5

# Returns exactly 3 experiments  
mlflow experiments search --max-results 3

# Validates negative values
mlflow experiments search --max-results -5
# Error: Invalid value for '--max-results': max-results must be a non-negative integer

Does this PR require documentation update?

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

The CLI option is self-documenting through --help text.

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.

Added --max-results option to mlflow experiments search command to limit the number of experiments returned, improving performance and helping avoid rate limits when querying backends with many experiments.

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 (this PR will be cherry-picked and included in the next patch release)
  • No (this PR will be included in the next minor release)

Allows users to limit the number of experiments returned, improving performance
and helping avoid rate limits when querying backends with many experiments.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alkis Polyzotis <alkis.polyzotis@databricks.com>
@github-actions github-actions bot added area/tracking Tracking service, tracking client APIs, autologging rn/feature Mention under Features in Changelogs. labels Dec 12, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 12, 2025

Documentation preview for 957a058 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.



def test_experiments_search_command_params():
from mlflow.experiments import commands
Copy link
Member

Choose a reason for hiding this comment

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

do we need to import this here?

Copy link
Member

@harupy harupy Dec 13, 2025

Choose a reason for hiding this comment

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

btw do we need this test? Seems useless

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed that it's not high value. I will remove.

)
def search_experiments(view):
@click.option(
"--max-results",
Copy link
Member

Choose a reason for hiding this comment

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

does the output have a token to fetch the next page?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not at this point -- let's introduce this later as needed.

Copy link
Member

Choose a reason for hiding this comment

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

sounds good

alkispoly-db and others added 2 commits December 14, 2025 02:23
Format imports and long lines according to ruff standards.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Signed-off-by: Alkis Polyzotis <alkis.polyzotis@databricks.com>
@harupy harupy changed the title Add --max-results option to mlflow experiments search Add --max-results option to mlflow experiments search Dec 15, 2025
@BenWilson2 BenWilson2 merged commit f63107e into mlflow:master Dec 15, 2025
73 of 77 checks passed
WeichenXu123 pushed a commit to WeichenXu123/mlflow that referenced this pull request Dec 19, 2025
Signed-off-by: Alkis Polyzotis <alkis.polyzotis@databricks.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
WeichenXu123 pushed a commit that referenced this pull request Dec 19, 2025
Signed-off-by: Alkis Polyzotis <alkis.polyzotis@databricks.com>
Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/tracking Tracking service, tracking client APIs, autologging rn/feature Mention under Features in Changelogs. v3.8.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants