Skip to content

Add mlflow experiments get command#19097

Merged
serena-ruan merged 2 commits intomlflow:masterfrom
alkispoly-db:mlflow-cli-experiments-get
Dec 1, 2025
Merged

Add mlflow experiments get command#19097
serena-ruan merged 2 commits intomlflow:masterfrom
alkispoly-db:mlflow-cli-experiments-get

Conversation

@alkispoly-db
Copy link
Collaborator

@alkispoly-db alkispoly-db commented Nov 28, 2025

Related Issues/PRs

N/A

What changes are proposed in this pull request?

This PR adds a new CLI command mlflow experiments get that retrieves and displays experiment details by ID. The command supports both table and JSON output formats.

Key features:

  • Required --experiment-id / -x flag to specify the experiment
  • Optional --output flag supporting table (default) and json formats
  • Table format (default): Vertical layout showing all experiment fields in human-readable format
  • JSON format: Complete experiment data in JSON structure for programmatic use
  • Displays all experiment fields: experiment_id, name, artifact_location, lifecycle_stage, tags, creation_time, last_update_time

Output examples:

Table format (default):

$ mlflow experiments get --experiment-id 0
Experiment ID      : 0
Name               : Default
Artifact Location  : /path/to/mlruns/0
Lifecycle Stage    : active
Creation Time      : 1764288610669
Last Update Time   : 1764288610669
Tags               :

JSON format:

$ mlflow experiments get --experiment-id 0 --output json
{
  "experiment_id": "0",
  "name": "Default",
  "artifact_location": "/path/to/mlruns/0",
  "lifecycle_stage": "active",
  "tags": {},
  "creation_time": 1764288610669,
  "last_update_time": 1764288610669
}

Implementation details:

  • Follows existing MLflow CLI patterns (consistent with runs describe command)
  • Uses Click's click.Choice for output format validation
  • Table format uses vertical layout (field: value) for better single-entity readability
  • Uses dict(experiment) for serialization via _MlflowObject.__iter__

How is this PR tested?

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

New tests added (7 total):

  1. test_get_experiment_default - Default table output
  2. test_get_experiment_json - Complete JSON validation with expected output comparison
  3. test_get_experiment_table - Table format with tags
  4. test_get_experiment_table_no_tags - Table format without tags
  5. test_get_experiment_missing_id - Missing required parameter
  6. test_get_experiment_invalid_id - Invalid experiment ID
  7. test_get_experiment_deleted - Deleted experiments (lifecycle stage)

Test coverage:

  • ✅ Default behavior (table format)
  • ✅ Both output formats (table and JSON)
  • ✅ Short option (-x)
  • ✅ Experiments with and without tags
  • ✅ Complete JSON structure validation
  • ✅ Error cases (missing/invalid ID)
  • ✅ All lifecycle stages (active and deleted)

Manual testing:

# Default table format
$ mlflow experiments get --experiment-id 0

# JSON format
$ mlflow experiments get --experiment-id 0 --output json

# Short option
$ mlflow experiments get -x 0

# Help command
$ mlflow experiments get --help

Quality checks:

  • ✅ All 7 tests pass
  • ✅ Ruff linting passes
  • ✅ Ruff formatting passes
  • ✅ Clint custom linter passes
  • ✅ All pre-commit hooks pass

Does this PR require documentation update?

  • No. You can skip the rest of this section.

The command is self-documenting through its docstring and --help output. No additional documentation is needed at this time.

Release Notes

Is this a user-facing change?

  • Yes. Give a description of this change to be included in the release notes for MLflow users.

Added new CLI command mlflow experiments get --experiment-id <ID> to retrieve and display experiment details. The command supports two output formats:

  • Table format (default): Human-readable vertical layout showing all experiment fields
  • JSON format (via --output json): Complete experiment data in JSON structure for programmatic use

The command provides easy access to experiment metadata including name, artifact location, lifecycle stage, tags, and timestamps.

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

Components

  • area/tracking: Tracking Service, tracking client APIs, autologging

How should the PR be classified in the release notes? Choose one:

  • rn/feature - A new user-facing feature 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)

Commits:

  1. 2469e5115 - Initial implementation with JSON output only
  2. 4d14803ed - Add table output format and set as default

🤖 Generated with Claude Code

Add new CLI command to retrieve experiment details by ID.
The command supports JSON output format with an extensible
design for future table format support.

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

Co-Authored-By: Claude <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 Nov 28, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 28, 2025

Documentation preview for 4d14803 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.

Address ALKIS comments to implement table output format:
- Add both "json" and "table" to click.Choice
- Set "table" as the default output format
- Implement vertical table formatting for single experiment display
- Update tests: combine JSON structure test with explicit JSON test
- Add comprehensive tests for table format (with/without tags)
- Update existing tests to specify output format explicitly

Changes:
- Default output is now table format (user-friendly)
- JSON format available with --output json flag
- Table format shows all fields in vertical layout
- Tests verify both output formats work correctly

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

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Alkis Polyzotis <alkis.polyzotis@databricks.com>
Copy link
Collaborator

@serena-ruan serena-ruan left a comment

Choose a reason for hiding this comment

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

LGTM!

@serena-ruan serena-ruan added this pull request to the merge queue Dec 1, 2025
Merged via the queue into mlflow:master with commit 80c2ae3 Dec 1, 2025
51 of 54 checks passed
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants