Skip to content
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

Add a utility function to minimize caching #1617

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- Speed up getting plottable data from adjacent items; plot more data ([#1613](../../pull/1613), [#1614](../../pull/1614))
- Better handle mixed dtype sources in the multi source ([#1616](../../pull/1616))
- Add a utility function to minimize caching ([#1617](../../pull/1617))

### Bug Fixes

Expand Down
14 changes: 14 additions & 0 deletions large_image/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,17 @@
if mem:
return mem
return 8 * 1024 ** 3


def minimizeCaching(mode=None):
"""
Set python cache sizes to very low values.

:param mode: None for all caching, 'tile' for the tile cache, 'source' for
the source cache.
"""
if not mode or str(mode).lower().startswith('source'):
setConfig('cache_tilesource_maximum', 1)

Check warning on line 198 in large_image/config.py

View check run for this annotation

Codecov / codecov/patch

large_image/config.py#L198

Added line #L198 was not covered by tests
if not mode or str(mode).lower().startswith('tile'):
setConfig('cache_backend', 'python')
setConfig('cache_python_memory_portion', 256)

Check warning on line 201 in large_image/config.py

View check run for this annotation

Codecov / codecov/patch

large_image/config.py#L200-L201

Added lines #L200 - L201 were not covered by tests