-
Notifications
You must be signed in to change notification settings - Fork 6
Python(feat): disk caching #346
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
alexluck-sift
wants to merge
16
commits into
main
Choose a base branch
from
python/feat/disk-caching
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
16 commits
Select commit
Hold shift + click to select a range
b1ef381
wip
alexluck-sift 9c79f57
updating defaults
alexluck-sift d4504e3
add some missing files
alexluck-sift 2c94c66
add async grpc caching
alexluck-sift 9eca9a6
further iteration
alexluck-sift 61a8371
wip
alexluck-sift 7f73b63
fix tests
alexluck-sift 5b9dfde
wip
alexluck-sift c674c82
clean up call_with_cache
alexluck-sift 15c302b
add run for demo
alexluck-sift 99fc42f
move cache testing to ping
alexluck-sift a624797
remove caching from LLW runs
alexluck-sift 143707d
move around cache defaults and cache folder
alexluck-sift e572bc2
linting
alexluck-sift 02f3525
fix dependency
alexluck-sift 8a48a91
fix test
alexluck-sift 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
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 |
|---|---|---|
|
|
@@ -33,18 +33,24 @@ class PingLowLevelClient(LowLevelClientBase, WithGrpcClient): | |
| It handles common concerns like error handling and retries. | ||
| """ | ||
|
|
||
| _cache_results: bool | ||
| """Whether to cache the results of the ping request. Used for testing.""" | ||
|
|
||
| def __init__(self, grpc_client: GrpcClient): | ||
| """Initialize the PingLowLevelClient. | ||
|
|
||
| Args: | ||
| grpc_client: The gRPC client to use for making API calls. | ||
| """ | ||
| super().__init__(grpc_client=grpc_client) | ||
| self._cache_results = False | ||
|
|
||
| async def ping(self) -> str: | ||
| async def ping(self, _force_refresh: bool = False) -> str: | ||
|
Contributor
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. noticing none of this plumbing is exposed at the high level resource layer -- would the expectation be that people call the low level client directly? |
||
| """Send a ping request to the server in the current event loop.""" | ||
| # get stub bound to this loop | ||
| stub = self._grpc_client.get_stub(PingServiceStub) | ||
| request = PingRequest() | ||
| response = await stub.Ping(request) | ||
| response = await self._call_with_cache( | ||
| stub.Ping, request, use_cache=self._cache_results, force_refresh=_force_refresh, ttl=1 | ||
| ) | ||
| return cast("PingResponse", response).response | ||
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.
Uh oh!
There was an error while loading. Please reload this page.
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 these just always be passed and defer the
if use_cache or force_refresh:logic to the grpc interceptor? idk if it could be tagged onto get_stub or something