[train/tune] Load the latest unflattened metrics with Result.from_path
#40684
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Why are these changes needed?
A trial's
config
gets saved as part of an iteration's reported metric. It gets saved by the defaultJsonLoggerCallback
in each row ofresult.json
as an unflattened dict.The deserialization logic in
Result.from_path
reads thisresult.json
file to reconstruct the config, but it flattens the dict along the way, result in keys like"config/a"
, leading to"config"
not being found.This PR fixes this by loading the metrics from json without doing extra operations on it.
cc: @daturkel
Limitations
progress.csv
is another auto-generated file created by the defaultCSVLoggerCallback
. There is no need for both of these files -- we may want to just only save theresult.json
in the future. One difference is thatprogress.csv
does not contain the config as part of each row. In the case that a user disables the JSON logger callback, or deletes theresult.json
file,Result.from_path
falls back to load info from this csv file, which doesn't include config information.result.config
would returnNone
in this case.Related issue number
Closes #40535
Checks
git commit -s
) in this PR.scripts/format.sh
to lint the changes in this PR.method in Tune, I've added it in
doc/source/tune/api/
under thecorresponding
.rst
file.