Skip to content

Fix a logic for invalidating the cache in CachedStorage#4670

Merged
not522 merged 1 commit intooptuna:masterfrom
c-bata:fix-cached-storage-bug
May 22, 2023
Merged

Fix a logic for invalidating the cache in CachedStorage#4670
not522 merged 1 commit intooptuna:masterfrom
c-bata:fix-cached-storage-bug

Conversation

@c-bata
Copy link
Copy Markdown
Member

@c-bata c-bata commented May 12, 2023

Motivation

While reviewing #4631, I found a bug in CachedStorage's delete_study method.
I will make this PR ready for review after #4631 is merged.

Description of the changes

Added a test case and fixed a logic for invalidating the cache. See 5680898 for details.

@c-bata c-bata added the bug Issue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself. label May 12, 2023
@github-actions github-actions bot added optuna.storages Related to the `optuna.storages` submodule. This is automatically labeled by github-actions. optuna.trial Related to the `optuna.trial` submodule. This is automatically labeled by github-actions. labels May 12, 2023
@c-bata c-bata changed the title Fix bug of CachedStorage's delete_study() Fix bug of delete_study method in CachedStorage May 12, 2023
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 12, 2023

Codecov Report

Merging #4670 (04471b2) into master (466cddf) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master    #4670      +/-   ##
==========================================
+ Coverage   90.62%   90.63%   +0.01%     
==========================================
  Files         187      187              
  Lines       14297    14299       +2     
==========================================
+ Hits        12956    12960       +4     
+ Misses       1341     1339       -2     
Impacted Files Coverage Δ
optuna/storages/_cached_storage.py 99.42% <100.00%> (+1.16%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@c-bata c-bata changed the title Fix bug of delete_study method in CachedStorage Fix a logic for invalidating the cache in CachedStorage May 12, 2023
@c-bata c-bata added enhancement Change that does not break compatibility and not affect public interfaces, but improves performance. and removed bug Issue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself. labels May 12, 2023
@c-bata c-bata force-pushed the fix-cached-storage-bug branch from 5680898 to 04471b2 Compare May 12, 2023 07:32
@c-bata c-bata marked this pull request as ready for review May 12, 2023 07:32
def delete_study(self, study_id: int) -> None:
with self._lock:
if study_id in self._studies:
for trial_id in self._studies[study_id].trials:
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The key of self._studies is not a trial_id. It's a trial number.

Copy link
Copy Markdown
Member

@not522 not522 left a comment

Choose a reason for hiding this comment

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

LGTM!

@HideakiImamura
Copy link
Copy Markdown
Member

@gen740 Could you review this PR?

Copy link
Copy Markdown
Member

@gen740 gen740 left a comment

Choose a reason for hiding this comment

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

LGTM!

@not522 not522 merged commit e403f7c into optuna:master May 22, 2023
@not522 not522 added this to the v3.2.0 milestone May 22, 2023
@not522 not522 added bug Issue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself. and removed enhancement Change that does not break compatibility and not affect public interfaces, but improves performance. labels May 22, 2023
@c-bata c-bata deleted the fix-cached-storage-bug branch May 22, 2023 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue/PR about behavior that is broken. Not for typos/examples/CI/test but for Optuna itself. optuna.storages Related to the `optuna.storages` submodule. This is automatically labeled by github-actions. optuna.trial Related to the `optuna.trial` submodule. This is automatically labeled by github-actions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants