-
Notifications
You must be signed in to change notification settings - Fork 175
Add option to cache unknown bucket type #844
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
Open
Yonghui-Lee
wants to merge
1
commit into
fsspec:main
Choose a base branch
from
Yonghui-Lee:cache-unknown-buckets-pure
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.
Open
Changes from all commits
Commits
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 |
|---|---|---|
|
|
@@ -96,6 +96,9 @@ def __init__(self, *args, finalize_on_close=False, **kwargs): | |
| finalize_on_close : bool, default False | ||
| By default, files in zonal buckets are left unfinalized to allow appends. | ||
| **kwargs : dict | ||
| - cache_unknown_buckets : bool, default False | ||
| Whether to cache UNKNOWN bucket types. Useful when users lack permissions | ||
| for the Storage Control API to avoid repeated slow failing lookups. | ||
| Additional arguments passed to GCSFileSystem. | ||
| Supports retry configuration overrides for Storage Control API: | ||
| - retry_timeout: Total time to spend retrying (seconds). | ||
|
|
@@ -104,6 +107,7 @@ def __init__(self, *args, finalize_on_close=False, **kwargs): | |
| - retry_multiplier: Multiplier for delay between retries. | ||
| These map to `google.api_core.retry.AsyncRetry` arguments (without 'retry_' prefix). | ||
| """ | ||
| self._cache_unknown_buckets = kwargs.pop("cache_unknown_buckets", False) | ||
|
Collaborator
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. If a user sets |
||
| valid_keys = DEFAULT_RETRY_CONFIG.keys() | ||
| self.retry_config = { | ||
| k[6:]: v | ||
|
|
@@ -194,8 +198,7 @@ async def _lookup_bucket_type(self, bucket): | |
| if bucket in self._storage_layout_cache: | ||
| return self._storage_layout_cache[bucket] | ||
| bucket_type = await self._get_bucket_type(bucket) | ||
| # Dont cache UNKNOWN type | ||
| if bucket_type == BucketType.UNKNOWN: | ||
| if bucket_type == BucketType.UNKNOWN and not self._cache_unknown_buckets: | ||
| return bucket_type | ||
| self._storage_layout_cache[bucket] = bucket_type | ||
| return self._storage_layout_cache[bucket] | ||
|
|
||
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.
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 use case is very rare. storage layout api needs minimal object permissions
https://docs.cloud.google.com/storage/docs/getting-storage-layout#expandable-1
Adding this flag might not be useful as in most cases UNKNOWN might come due to transient api call failure which should not be cached