Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class AsyncAppendableObjectWriter:

def __init__(
self,
client: AsyncGrpcClient.grpc_client,
client: AsyncGrpcClient,
bucket_name: str,
object_name: str,
generation: Optional[int] = None,
Expand Down Expand Up @@ -155,7 +155,7 @@ def __init__(
await writer.close()
```

:type client: :class:`~google.cloud.storage._experimental.asyncio.async_grpc_client.AsyncGrpcClient.grpc_client`
:type client: :class:`~google.cloud.storage._experimental.asyncio.async_grpc_client.AsyncGrpcClient`
:param client: async grpc client to use for making API requests.

:type bucket_name: str
Expand Down Expand Up @@ -304,7 +304,7 @@ async def _do_open():
self._is_stream_open = False

self.write_obj_stream = _AsyncWriteObjectStream(
client=self.client,
client=self.client.grpc_client,
bucket_name=self.bucket_name,
object_name=self.object_name,
generation_number=self.generation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class AsyncMultiRangeDownloader:
@classmethod
async def create_mrd(
cls,
client: AsyncGrpcClient.grpc_client,
client: AsyncGrpcClient,
bucket_name: str,
object_name: str,
generation_number: Optional[int] = None,
Expand All @@ -136,7 +136,7 @@ async def create_mrd(
"""Initializes a MultiRangeDownloader and opens the underlying bidi-gRPC
object for reading.

:type client: :class:`~google.cloud.storage._experimental.asyncio.async_grpc_client.AsyncGrpcClient.grpc_client`
:type client: :class:`~google.cloud.storage._experimental.asyncio.async_grpc_client.AsyncGrpcClient`
:param client: The asynchronous client to use for making API requests.

:type bucket_name: str
Expand Down Expand Up @@ -168,7 +168,7 @@ async def create_mrd(

def __init__(
self,
client: AsyncGrpcClient.grpc_client,
client: AsyncGrpcClient,
bucket_name: str,
object_name: str,
generation_number: Optional[int] = None,
Expand All @@ -177,7 +177,7 @@ def __init__(
"""Constructor for AsyncMultiRangeDownloader, clients are not adviced to
use it directly. Instead it's adviced to use the classmethod `create_mrd`.

:type client: :class:`~google.cloud.storage._experimental.asyncio.async_grpc_client.AsyncGrpcClient.grpc_client`
:type client: :class:`~google.cloud.storage._experimental.asyncio.async_grpc_client.AsyncGrpcClient`
:param client: The asynchronous client to use for making API requests.

:type bucket_name: str
Expand Down Expand Up @@ -273,7 +273,7 @@ async def _do_open():
self._is_stream_open = False

self.read_obj_str = _AsyncReadObjectStream(
client=self.client,
client=self.client.grpc_client,
bucket_name=self.bucket_name,
object_name=self.object_name,
generation_number=self.generation_number,
Expand Down Expand Up @@ -432,7 +432,7 @@ async def generator():

# Re-initialize stream
self.read_obj_str = _AsyncReadObjectStream(
client=self.client,
client=self.client.grpc_client,
bucket_name=self.bucket_name,
object_name=self.object_name,
generation_number=self.generation_number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def storage_create_and_write_appendable_object(
"""

if grpc_client is None:
grpc_client = AsyncGrpcClient().grpc_client
grpc_client = AsyncGrpcClient()
writer = AsyncAppendableObjectWriter(
client=grpc_client,
bucket_name=bucket_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def storage_finalize_appendable_object_upload(
"""

if grpc_client is None:
grpc_client = AsyncGrpcClient().grpc_client
grpc_client = AsyncGrpcClient()
writer = AsyncAppendableObjectWriter(
client=grpc_client,
bucket_name=bucket_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async def storage_open_multiple_objects_ranged_read(
grpc_client: an existing grpc_client to use, this is only for testing.
"""
if grpc_client is None:
grpc_client = AsyncGrpcClient().grpc_client
grpc_client = AsyncGrpcClient()

async def _download_range(object_name):
"""Helper coroutine to download a range from a single object."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def storage_open_object_multiple_ranged_read(
grpc_client: an existing grpc_client to use, this is only for testing.
"""
if grpc_client is None:
grpc_client = AsyncGrpcClient().grpc_client
grpc_client = AsyncGrpcClient()

mrd = AsyncMultiRangeDownloader(grpc_client, bucket_name, object_name)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def storage_open_object_read_full_object(
grpc_client: an existing grpc_client to use, this is only for testing.
"""
if grpc_client is None:
grpc_client = AsyncGrpcClient().grpc_client
grpc_client = AsyncGrpcClient()

# mrd = Multi-Range-Downloader
mrd = AsyncMultiRangeDownloader(grpc_client, bucket_name, object_name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def storage_open_object_single_ranged_read(
grpc_client: an existing grpc_client to use, this is only for testing.
"""
if grpc_client is None:
grpc_client = AsyncGrpcClient().grpc_client
grpc_client = AsyncGrpcClient()

mrd = AsyncMultiRangeDownloader(grpc_client, bucket_name, object_name)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def storage_pause_and_resume_appendable_upload(
grpc_client: an existing grpc_client to use, this is only for testing.
"""
if grpc_client is None:
grpc_client = AsyncGrpcClient().grpc_client
grpc_client = AsyncGrpcClient()

writer1 = AsyncAppendableObjectWriter(
client=grpc_client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async def read_appendable_object_tail(
grpc_client: an existing grpc_client to use, this is only for testing.
"""
if grpc_client is None:
grpc_client = AsyncGrpcClient().grpc_client
grpc_client = AsyncGrpcClient()
writer = AsyncAppendableObjectWriter(
client=grpc_client,
bucket_name=bucket_name,
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/zonal_buckets/zonal_snippets_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

async def create_async_grpc_client():
"""Initializes async client and gets the current event loop."""
return AsyncGrpcClient().grpc_client
return AsyncGrpcClient()


# Forcing a single event loop for the whole test session
Expand Down
2 changes: 1 addition & 1 deletion tests/perf/microbenchmarks/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def upload_appendable_object(bucket_name, object_name, object_size, chunk_
# this method is to write "appendable" objects which will be used for
# benchmarking reads, hence not concerned performance of writes here.
writer = AsyncAppendableObjectWriter(
AsyncGrpcClient().grpc_client,
AsyncGrpcClient(),
bucket_name,
object_name,
writer_options={"FLUSH_INTERVAL_BYTES": 1026 * 1024**2},
Expand Down
2 changes: 1 addition & 1 deletion tests/perf/microbenchmarks/reads/test_reads.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

async def create_client():
"""Initializes async client and gets the current event loop."""
return AsyncGrpcClient().grpc_client
return AsyncGrpcClient()


async def download_chunks_using_mrd_async(client, filename, other_params, chunks):
Expand Down
2 changes: 1 addition & 1 deletion tests/perf/microbenchmarks/writes/test_writes.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

async def create_client():
"""Initializes async client and gets the current event loop."""
return AsyncGrpcClient().grpc_client
return AsyncGrpcClient()


async def upload_chunks_using_grpc_async(client, filename, other_params):
Expand Down
2 changes: 1 addition & 1 deletion tests/system/test_zonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

async def create_async_grpc_client(attempt_direct_path=True):
"""Initializes async client and gets the current event loop."""
return AsyncGrpcClient(attempt_direct_path=attempt_direct_path).grpc_client
return AsyncGrpcClient(attempt_direct_path=attempt_direct_path)


@pytest.fixture(scope="session")
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/asyncio/test_async_appendable_object_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def test_non_retryable_errors(self, mock_appendable_writer):
@pytest.fixture
def mock_appendable_writer():
"""Fixture to provide a mock AsyncAppendableObjectWriter setup."""
mock_client = mock.AsyncMock()
mock_client = mock.MagicMock()
mock_client.grpc_client = mock.AsyncMock()
# Internal stream class patch
stream_patcher = mock.patch(
"google.cloud.storage._experimental.asyncio.async_appendable_object_writer._AsyncWriteObjectStream"
Expand Down
Loading