Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 173
feat: update generation for MRD#1730
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
38 changes: 27 additions & 11 deletions
38 google/cloud/storage/asyncio/async_multi_range_downloader.py
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 |
|---|---|---|
| @@ -128,10 +128,11 @@ async def create_mrd( | ||
| client: AsyncGrpcClient, | ||
| bucket_name: str, | ||
| object_name: str, | ||
| generation_number: Optional[int] = None, | ||
| generation: Optional[int] = None, | ||
| read_handle: Optional[_storage_v2.BidiReadHandle] = None, | ||
| retry_policy: Optional[AsyncRetry] = None, | ||
| metadata: Optional[List[Tuple[str, str]]] = None, | ||
| **kwargs, | ||
| ) -> AsyncMultiRangeDownloader: | ||
| """Initializes a MultiRangeDownloader and opens the underlying bidi-gRPC | ||
| object for reading. | ||
| @@ -145,8 +146,8 @@ async def create_mrd( | ||
| :type object_name: str | ||
| :param object_name: The name of the object to be read. | ||
| :type generation_number: int | ||
| :param generation_number: (Optional) If present, selects a specific | ||
| :type generation: int | ||
| :param generation: (Optional) If present, selects a specific | ||
| revision of this object. | ||
| :type read_handle: _storage_v2.BidiReadHandle | ||
| @@ -162,7 +163,14 @@ async def create_mrd( | ||
| :rtype: :class:`~google.cloud.storage.asyncio.async_multi_range_downloader.AsyncMultiRangeDownloader` | ||
| :returns: An initialized AsyncMultiRangeDownloader instance for reading. | ||
| """ | ||
| mrd = cls(client, bucket_name, object_name, generation_number, read_handle) | ||
| mrd = cls( | ||
| client, | ||
| bucket_name, | ||
| object_name, | ||
| generation=generation, | ||
| read_handle=read_handle, | ||
| **kwargs, | ||
| ) | ||
| await mrd.open(retry_policy=retry_policy, metadata=metadata) | ||
| return mrd | ||
| @@ -171,8 +179,9 @@ def __init__( | ||
| client: AsyncGrpcClient, | ||
| bucket_name: str, | ||
| object_name: str, | ||
| generation_number: Optional[int] = None, | ||
| generation: Optional[int] = None, | ||
| read_handle: Optional[_storage_v2.BidiReadHandle] = None, | ||
| **kwargs, | ||
| ) -> None: | ||
| """Constructor for AsyncMultiRangeDownloader, clients are not adviced to | ||
| use it directly. Instead it's adviced to use the classmethod `create_mrd`. | ||
| @@ -186,20 +195,27 @@ def __init__( | ||
| :type object_name: str | ||
| :param object_name: The name of the object to be read. | ||
| :type generation_number: int | ||
| :param generation_number: (Optional) If present, selects a specific revision of | ||
| :type generation: int | ||
| :param generation: (Optional) If present, selects a specific revision of | ||
| this object. | ||
| :type read_handle: _storage_v2.BidiReadHandle | ||
| :param read_handle: (Optional) An existing read handle. | ||
| """ | ||
| if "generation_number" in kwargs: | ||
| if generation is not None: | ||
Pulkit0110 marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| raise TypeError( | ||
| "Cannot set both 'generation' and 'generation_number'. " | ||
| "Use 'generation' for new code." | ||
| ) | ||
| generation = kwargs.pop("generation_number") | ||
| raise_if_no_fast_crc32c() | ||
| self.client = client | ||
| self.bucket_name = bucket_name | ||
| self.object_name = object_name | ||
| self.generation_number = generation_number | ||
| self.generation = generation | ||
| self.read_handle: Optional[_storage_v2.BidiReadHandle] = read_handle | ||
| self.read_obj_str: Optional[_AsyncReadObjectStream] = None | ||
| self._is_stream_open: bool = False | ||
| @@ -276,7 +292,7 @@ async def _do_open(): | ||
| client=self.client.grpc_client, | ||
| bucket_name=self.bucket_name, | ||
| object_name=self.object_name, | ||
| generation_number=self.generation_number, | ||
| generation_number=self.generation, | ||
| read_handle=self.read_handle, | ||
| ) | ||
| @@ -291,7 +307,7 @@ async def _do_open(): | ||
| ) | ||
| if self.read_obj_str.generation_number: | ||
| self.generation_number = self.read_obj_str.generation_number | ||
| self.generation = self.read_obj_str.generation_number | ||
| if self.read_obj_str.read_handle: | ||
| self.read_handle = self.read_obj_str.read_handle | ||
| if self.read_obj_str.persisted_size is not None: | ||
| @@ -435,7 +451,7 @@ async def generator(): | ||
| client=self.client.grpc_client, | ||
| bucket_name=self.bucket_name, | ||
| object_name=self.object_name, | ||
| generation_number=self.generation_number, | ||
| generation_number=self.generation, | ||
| read_handle=current_handle, | ||
| ) | ||
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
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.