Skip to content

[Docs] Document nested-metric keys in ResultGrid.get_best_result (#30463)#63445

Open
dstrodtman wants to merge 3 commits into
ray-project:masterfrom
dstrodtman:doc-987-result-grid-nested-keys
Open

[Docs] Document nested-metric keys in ResultGrid.get_best_result (#30463)#63445
dstrodtman wants to merge 3 commits into
ray-project:masterfrom
dstrodtman:doc-987-result-grid-nested-keys

Conversation

@dstrodtman
Copy link
Copy Markdown
Contributor

Description

Adds an example to ResultGrid.get_best_result showing how to refer to metrics that are reported in a nested result dict. Tune flattens reported result dicts with / as the delimiter before storing them in metric_analysis, so a nested entry like {"eval": {"metrics": {"loss": 0.1}}} is queried with metric="eval/metrics/loss". The docstring previously gave no guidance on this form, which is what the linked issue asked for.

Related issues

Closes #30463

[DOC-987]

Additional information

Target: python/ray/tune/result_grid.py. The slash-separated flat-key form is the only form supported by get_best_resultmetric is used directly as a key into the flattened metric_analysis dict in ExperimentAnalysis.get_best_trial (see python/ray/tune/experiment/trial.py update_last_result, which calls flatten_dict with the default / delimiter before updating per-metric stats).

Generated with Claude Code

…-project#30463)

Add an example to `ResultGrid.get_best_result` showing how to refer to
metrics reported in a nested result dict. Tune flattens result dicts with
`/` as the delimiter before storing them in `metric_analysis`, so the
correct form is a slash-separated flat key like `"eval/metrics/loss"`.

Target: python/ray/tune/result_grid.py.

Closes ray-project#30463

[DOC-987]

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Douglas Strodtman <douglas@anyscale.com>
@dstrodtman dstrodtman requested a review from a team as a code owner May 18, 2026 16:00
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the documentation for the get_best_result method in ResultGrid to explain how to reference nested metrics using slash-separated keys. The feedback suggests clarifying that the forward slash is the default delimiter, as this behavior can be configured via environment variables.

Comment thread python/ray/tune/result_grid.py Outdated
@ray-gardener ray-gardener Bot added tune Tune-related issues docs An issue or change related to documentation labels May 18, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Jun 2, 2026
dstrodtman and others added 2 commits June 2, 2026 10:31
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Signed-off-by: Douglas Strodtman <douglas@anyscale.com>
@dstrodtman dstrodtman added go add ONLY when ready to merge, run all tests and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs An issue or change related to documentation go add ONLY when ready to merge, run all tests tune Tune-related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Tune] How should I specify nested metric keys for obtaining best results from ResultGrid

2 participants