Skip to content

Add caching layer for vocabulary fetching during API startup#535

Open
SarthakJagota wants to merge 1 commit intoneurobagel:mainfrom
SarthakJagota:feature/vocab-cache-startup
Open

Add caching layer for vocabulary fetching during API startup#535
SarthakJagota wants to merge 1 commit intoneurobagel:mainfrom
SarthakJagota:feature/vocab-cache-startup

Conversation

@SarthakJagota
Copy link

@SarthakJagota SarthakJagota commented Feb 26, 2026

Summary

This PR introduces a lightweight caching mechanism for vocabulary fetching during API startup.

Currently, vocabularies are fetched from GitHub on every startup, which can slow initialization and create a dependency on network availability.

Changes

  • Added cache.py helper to store and load vocabularies locally
  • Load vocabularies from cache when available
  • Fetch and persist vocabularies when cache is missing
  • Added fallback to cached vocabularies if fetching fails
  • Added logging to clarify when cache vs remote fetch is used

Impact

  • Faster startup for local development
  • Improved reliability when external services are unavailable
  • No change to existing API behavior

Notes

Cached vocabularies can be refreshed by removing the .cache directory.

Summary by Sourcery

Introduce a local caching mechanism for vocabulary data during API startup to reduce reliance on remote fetching and improve startup performance.

New Features:

  • Add a cache helper module to persist and load vocabularies from a local .cache directory.
  • Load vocabularies from the local cache on startup when available instead of always fetching from GitHub.

Enhancements:

  • Add a fallback to use cached vocabularies when remote fetching fails to improve startup robustness.
  • Add logging to indicate whether vocabularies are loaded from cache or fetched remotely.

#534

@sourcery-ai
Copy link

sourcery-ai bot commented Feb 26, 2026

🧙 Sourcery has finished reviewing your pull request!


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@github-actions github-actions bot added the _community [BOT ONLY] PR label for community contributions. Used for tracking label Feb 26, 2026
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

We've reviewed this pull request using the Sourcery rules engine

@alyssadai alyssadai added flag:check Issue needs attention before further action and removed flag:check Issue needs attention before further action labels Feb 26, 2026
@neurobagel-bot neurobagel-bot bot moved this to Community in Neurobagel Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

_community [BOT ONLY] PR label for community contributions. Used for tracking

Projects

Status: Community

Development

Successfully merging this pull request may close these issues.

2 participants