-
Notifications
You must be signed in to change notification settings - Fork 554
Add clear_cache and clear_task_cache methods to BaseDataset #770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Eshaan-byte
wants to merge
3
commits into
sunlabuiuc:master
Choose a base branch
from
Eshaan-byte:add-cache-clearing-methods
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Add clear_cache and clear_task_cache methods to BaseDataset #770
Eshaan-byte
wants to merge
3
commits into
sunlabuiuc:master
from
Eshaan-byte:add-cache-clearing-methods
+191
−7
Conversation
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
Implements sunlabuiuc#765 by adding two new methods to manage cache cleanup: - clear_cache(): Clears entire dataset cache including global event dataframe and all task caches - clear_task_cache(task=None): Clears only the specified task's cache while preserving global event cache and other task caches Both methods handle non-existent caches gracefully and provide comprehensive logging.
EricSchrock
requested changes
Jan 4, 2026
Collaborator
EricSchrock
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add tests for these new methods to tests/core/test_caching.py, both to prove it works as expected and to act as example code?
Logiquo
reviewed
Jan 4, 2026
Logiquo
reviewed
Jan 4, 2026
11 tasks
- Extract task cache directory path generation into _get_task_cache_dir() helper method for consistency between set_task() and clear_task_cache() - Update clear_task_cache() to use the helper method - Clarify in docstring that clear_task_cache() only clears default cache location, not custom cache_dir paths - Add 5 comprehensive tests to tests/core/test_caching.py: * test_clear_cache_removes_all_caches * test_clear_cache_handles_nonexistent_cache * test_clear_task_cache_removes_only_specified_task * test_clear_task_cache_handles_nonexistent_cache * test_get_task_cache_dir_consistency Addresses review feedback from @Logiquo and @EricSchrock on PR sunlabuiuc#770
Collaborator
|
CI has failed. |
Store cache paths as strings before calling clear methods to prevent the cache_dir property from recreating directories when accessed after clearing. This ensures the tests correctly verify that caches are removed. Fixes CI test failures in test_clear_cache_removes_all_caches and test_clear_task_cache_removes_only_specified_task.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
component: dataset
Contribute a new dataset to PyHealth
core
Core functionality (Patient API, BaseDataset, event stream format, etc.)
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.
Implements #765 by adding two new methods to manage cache cleanup:
Both methods handle non-existent caches gracefully and provide comprehensive logging.