Introduce UpdateFinishedTrialError to raise an error when attempting to modify a finished trial#6001
Merged
not522 merged 3 commits intooptuna:masterfrom Mar 7, 2025
Merged
Conversation
Contributor
|
@not522 Could you review this PR? |
Member
|
Thank you for your PR! Could you update the files related to the error? As far as I know, the followings should be updated. And, we also need to update exceptions.rst. |
Collaborator
Author
|
@nabenabe0928 Thank you for pointing that out. I've implemented the changes you suggested and thoroughly reviewed all parts where |
not522
reviewed
Mar 7, 2025
Member
not522
left a comment
There was a problem hiding this comment.
Could you check the document formats?
Co-authored-by: Naoto Mizuno <naotomizuno@preferred.jp>
nabenabe0928
approved these changes
Mar 7, 2025
not522
approved these changes
Mar 7, 2025
Member
not522
left a comment
There was a problem hiding this comment.
LGTM!
Note: UpdateFinishedTrialError inherits from RuntimeError, so it should not affect user code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
In the current implementation, modifying finished trials in Optuna raises a RuntimeError. However, RuntimeError is a generic exception that does not accurately reflect the nature of the issue. This PR introduces a more specific exception
UpdateFinishedTrialErrorto improve clarity and maintainability.Description of the changes
UpdateFinishedTrialError, a new exception that inherits from bothRuntimeErrorandOptunaError.BaseStorageto raise UpdateFinishedTrialError when attempting to modify a finished trial:set_trial_paramset_trial_state_valuesset_trial_user_attrset_trial_system_attrcheck_trial_is_updatable, except in JournalStorage, where trial updatability is checked within_trial_exists_and_updatable.