-
Notifications
You must be signed in to change notification settings - Fork 2
Remove repository config caching logic #410
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
Draft
alecbcs
wants to merge
4
commits into
llnl:main
Choose a base branch
from
alecbcs:remove/repository-config-cache
base: main
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.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| aiohttp==3.14.3 | ||
| build==1.5.0 | ||
| cachetools==7.1.7 | ||
| coverage==7.15.4 | ||
| gidgethub==5.4.0 | ||
| gidgetlab==2.1.2 | ||
|
|
||
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ | |
| from typing import Any | ||
|
|
||
| import yaml | ||
| from cachetools import TTLCache | ||
|
|
||
| from hubcast.clients.github import GitHubClient | ||
| from hubcast.exceptions import HubcastError, RepoConfigError | ||
|
|
@@ -14,9 +13,6 @@ | |
|
|
||
| log = logging.getLogger(__name__) | ||
|
|
||
| # Shared cache for repository configs with 30-minute TTL | ||
| config_cache: TTLCache[str, RepoConfig | None] = TTLCache(maxsize=1000, ttl=1800) | ||
|
|
||
|
|
||
| def changed_files_from_push(payload: dict[str, Any]) -> set[str]: | ||
| """Collect all file paths touched by the commits in a push payload.""" | ||
|
|
@@ -28,15 +24,15 @@ def changed_files_from_push(payload: dict[str, Any]) -> set[str]: | |
| } | ||
|
|
||
|
|
||
| async def get_repo_config( | ||
| gh: GitHubClient, fullname: str, refresh: bool = False | ||
| ) -> RepoConfig: | ||
| """Get repository configuration from cache or fetch from GitHub. | ||
| async def get_repo_config(gh: GitHubClient) -> RepoConfig: | ||
| """Fetch and validate the repository configuration from GitHub. | ||
|
|
||
| Fetched fresh on every event so all replicas always see the current | ||
| destination repo; a single contents-API call is well within App | ||
| installation rate limits. | ||
|
|
||
| Args: | ||
| gh: GitHub client instance | ||
| fullname: Full repository name (e.g., "owner/repo") | ||
| refresh: Whether to force refresh from GitHub | ||
|
|
||
| Returns: | ||
| RepoConfig instance | ||
|
|
@@ -45,24 +41,12 @@ async def get_repo_config( | |
| HubcastError: If config file contains invalid YAML, is missing required keys, | ||
| or has validation errors | ||
| """ | ||
| # check cache first unless refresh is requested | ||
| if fullname in config_cache and not refresh: | ||
| config = config_cache[fullname] | ||
| log.info("Repo config retrieved from cache") | ||
| if config is None: | ||
| # raise so route handlers can't continue | ||
| # we don't want to raise this as a RepoConfigError because telling users | ||
| # about the absence of the config will create noise and confusion | ||
| raise HubcastError("Repo config file not found", log_level="INFO") | ||
| return config | ||
|
|
||
| # cache miss or refresh requested, fetch from GH | ||
| fetched_config = await gh.get_repo_config() | ||
|
|
||
| if fetched_config is None: # 404 | ||
| config_cache[fullname] = None | ||
| log.info("Cached absence of repo config") | ||
| # raise so route handlers can't continue | ||
| # we don't want to raise this as a RepoConfigError because telling users | ||
| # about the absence of the config will create noise and confusion | ||
|
Comment on lines
+48
to
+49
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. -- because they may have installed the app but have not submitted a config file yet |
||
| raise HubcastError("Repo config file not found", log_level="INFO") | ||
|
|
||
| # parse and validate YAML | ||
|
|
@@ -86,6 +70,5 @@ async def get_repo_config( | |
| error=str(e), | ||
| ) | ||
|
|
||
| config_cache[fullname] = config | ||
| log.info("Repo config fetched from source forge") | ||
| return config | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
this can be simplified, not sure if the last clause is needed in the codebase