Skip to content

feat: add image download cache#70

Draft
hollandjg wants to merge 2 commits intofix--duplicated-labelsfrom
feat(load)--add-cache
Draft

feat: add image download cache#70
hollandjg wants to merge 2 commits intofix--duplicated-labelsfrom
feat(load)--add-cache

Conversation

@hollandjg
Copy link
Copy Markdown
Member

@hollandjg hollandjg commented Mar 24, 2025

This will create an sqlite database cache of all the requests made when downloading images, and allow downloads to be reused across different sessions.

  • Add test cases.

@hollandjg hollandjg changed the title add cache directory settings feat: add image download cache Mar 24, 2025
@hollandjg hollandjg marked this pull request as ready for review March 26, 2025 15:09
@hollandjg hollandjg marked this pull request as draft March 26, 2025 15:10
@cpaniaguam cpaniaguam requested a review from Copilot March 26, 2025 17:29
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces an image download caching mechanism using an SQLite database to cache requests, enabling image downloads to be reused across sessions.

  • Added the "requests-cache" dependency in pyproject.toml.
  • Extended the load function to optionally use a cached session when a cache directory is provided.
  • Updated the CLI in app.py to accept and forward the cache directory parameter.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

File Description
pyproject.toml Added requests-cache dependency to manage caching.
src/ebfloeseg/load.py Added cache_directory parameter and caching session support.
src/ebfloeseg/app.py Propagated cache_directory parameter to the load function.
Comments suppressed due to low confidence (2)

src/ebfloeseg/load.py:207

  • Ensure that requests_cache.CachedSession is being used correctly; it may expect a cache name string rather than a Path object. Consider reviewing the requests-cache documentation to validate the correct parameter type and usage.
        session = requests_cache.CachedSession(cache_directory)

src/ebfloeseg/load.py:166

  • Add unit tests to verify the caching functionality when cache_directory is provided and when it is omitted.
    cache_directory: Optional[pathlib.Path] = None,

@cpaniaguam
Copy link
Copy Markdown
Member

I triggered the Copilot review out of curiosity. The changes look good to me but I concur that some tests should be added before merging this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants