Skip to content

[Storage] [Named Keywords] [Blob] _blob_client.py and aio #40206

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
wants to merge 43 commits into
base: feature/storage-blob-named-keywords
Choose a base branch
from

Conversation

weirongw23-msft
Copy link
Member

@weirongw23-msft weirongw23-msft commented Mar 24, 2025

Edit: With the number of named keywords added, pylint is recognizing them as local variables. We have APIs that exceed the allowed amount of 25. For now, I've suppressed the error.

@github-actions github-actions bot added the Storage Storage Service (Queues, Blobs, Files) label Mar 24, 2025
@azure-sdk
Copy link
Collaborator

API change check

APIView has identified API level changes in this PR and created following API reviews.

azure-storage-blob

@weirongw23-msft
Copy link
Member Author

/azp run python - storage - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@weirongw23-msft
Copy link
Member Author

/azp run python - storage - tests

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@weirongw23-msft weirongw23-msft marked this pull request as ready for review April 9, 2025 19:55
Copy link
Member

@vincenttran-msft vincenttran-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good to me! Will defer to Jacob for the final stamp of approval. :shipit:

Comment on lines +189 to +195
max_block_size: int = 4 * 1024 * 1024,
max_page_size: int = 4 * 1024 * 1024,
max_chunk_get_size: int = 4 * 1024 * 1024,
max_single_put_size: int = 64 * 1024 * 1024,
max_single_get_size: int = 32 * 1024 * 1024,
min_large_block_upload_threshold: int = 4 * 1024 * 1024 + 1,
use_byte_buffer: Optional[bool] = None,
Copy link
Member

@vincenttran-msft vincenttran-msft Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Making a comment here although I know we have had backs and forths- my stance is that I think these could stay, but again I think either way is fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also good with letting this stay for now :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

__init__, from_blob_url, from_connection_string

raise ValueError("Customer provided encryption key must be used over HTTPS.")
options = _download_blob_options(
blob_name=self.blob_name,
container_name=self.container_name,
version_id=get_version_id(self.version_id, kwargs),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the only instance-- but eventually could delete this helper once unused

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup made a note of this! This will be deleted once I go thru container client and service client.

@@ -2407,7 +3064,7 @@ def get_page_ranges(
:returns:
A tuple of two lists of page ranges as dictionaries with 'start' and 'end' keys.
The first element are filled page ranges, the 2nd element is cleared page ranges.
:rtype: tuple(list(dict(str, str), list(dict(str, str))
:rtype: tuple(list(Dict[str, str], list(Dict[str, str])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Can we do capitals on Tuple and List? Also any other instances in this file

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 137 to 141
validate_content = kwargs.pop('validate_content') or False
content_settings = kwargs.pop('content_settings') or None
overwrite = kwargs.pop('overwrite') or False
max_concurrency = kwargs.pop('max_concurrency') or 1
cpk = kwargs.pop('cpk') or None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reasoning for this? Assuming maybe something with type of default valued kwargs.pop()?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not strictly needed for cpk or content_settings, or anytime we do kwargs.pop('kwarg', None). The idea behind doing this is for example kwargs.pop('max_concurrency', 1), if max_concurrency=None, it will default to None instead of 1.

@@ -687,7 +734,7 @@ def _stage_block_options(
) -> Dict[str, Any]:
block_id = encode_base64(str(block_id))
if isinstance(data, str):
data = data.encode(kwargs.pop('encoding', 'UTF-8')) # type: ignore
data = data.encode(kwargs.pop('encoding') or 'UTF-8') # type: ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same q as above and on L746-- fine to resolve if there is a reason (but also, can we get a more specific ignore here or is there multiple errors 😄 )

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah if encoding is None, it will default to None instead of UTF-8 which is what we want. This fix actually removed the need for a type ignore, so I'll remove that :)

if offset is None or offset % 512 != 0:
raise ValueError("offset must be an integer that aligns with 512 page size")
if length is None or length % 512 != 0:
raise ValueError("length must be an integer that aligns with 512 page size")
end_range = offset + length - 1 # Reformat to an inclusive range index
content_range = f'bytes={offset}-{end_range}' # type: ignore
content_range = f'bytes={offset}-{end_range}' # type: ignore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.) Is this ignore still needed
2.) Can we make it more specific?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! We don't need this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went thru all the files to either remove redundant ignores or made them more specific :)

@@ -121,14 +121,17 @@ class BlobServiceClient(StorageAccountHostsMixin, StorageEncryptionMixin):
def __init__(
self, account_url: str,
credential: Optional[Union[str, Dict[str, str], "AzureNamedKeyCredential", "AzureSasCredential", "TokenCredential"]] = None, # pylint: disable=line-too-long
*,
api_version: Optional[str] = None,
# TODO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could remove this TODO if you want 😄 or leave it since it's going into a feature branch

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah I'll leave it so I know where to start <3

@weirongw23-msft
Copy link
Member Author

/azp run python - pullrequest

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Storage Storage Service (Queues, Blobs, Files)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants