-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Storage][ADLS] API updates #10170
Merged
Merged
[Storage][ADLS] API updates #10170
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 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 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 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
53 changes: 53 additions & 0 deletions
53
sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_download.py
This file contains 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# ------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# -------------------------------------------------------------------------- | ||
|
||
from ._models import FileProperties | ||
|
||
|
||
class StorageStreamDownloader(object): | ||
annatisch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"""A streaming object to download from Azure Storage. | ||
|
||
:ivar str name: | ||
The name of the file being downloaded. | ||
:ivar ~azure.storage.filedatalake.FileProperties properties: | ||
The properties of the file being downloaded. If only a range of the data is being | ||
downloaded, this will be reflected in the properties. | ||
:ivar int size: | ||
The size of the total data in the stream. This will be the byte range if speficied, | ||
otherwise the total size of the file. | ||
""" | ||
|
||
def __init__(self, downloader): | ||
self._downloader = downloader | ||
self.name = self._downloader.name | ||
self.properties = FileProperties._from_blob_properties(self._downloader.properties) # pylint: disable=protected-access | ||
self.size = self._downloader.size | ||
annatisch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def __len__(self): | ||
return self.size | ||
|
||
def chunks(self): | ||
return self._downloader.chunks() | ||
|
||
def readall(self): | ||
"""Download the contents of this file. | ||
|
||
This operation is blocking until all data is downloaded. | ||
:rtype: bytes or str | ||
""" | ||
return self._downloader.readall() | ||
|
||
def readinto(self, stream): | ||
"""Download the contents of this file to a stream. | ||
|
||
:param stream: | ||
The stream to download to. This can be an open file-handle, | ||
or any writable stream. The stream must be seekable if the download | ||
uses more than one parallel connection. | ||
:returns: The number of bytes read. | ||
:rtype: int | ||
""" | ||
return self._downloader.readinto(stream) |
This file contains 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 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
53 changes: 53 additions & 0 deletions
53
sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/aio/_download_async.py
This file contains 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# ------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. See License.txt in the project root for | ||
# license information. | ||
# -------------------------------------------------------------------------- | ||
|
||
from .._models import FileProperties | ||
|
||
|
||
class StorageStreamDownloader(object): | ||
"""A streaming object to download from Azure Storage. | ||
|
||
:ivar str name: | ||
The name of the file being downloaded. | ||
:ivar ~azure.storage.filedatalake.FileProperties properties: | ||
The properties of the file being downloaded. If only a range of the data is being | ||
downloaded, this will be reflected in the properties. | ||
:ivar int size: | ||
The size of the total data in the stream. This will be the byte range if speficied, | ||
otherwise the total size of the file. | ||
""" | ||
|
||
def __init__(self, downloader): | ||
self._downloader = downloader | ||
self.name = self._downloader.name | ||
self.properties = FileProperties._from_blob_properties(self._downloader.properties) # pylint: disable=protected-access | ||
self.size = self._downloader.size | ||
|
||
def __len__(self): | ||
return self.size | ||
|
||
def chunks(self): | ||
return self._downloader.chunks() | ||
|
||
async def readall(self): | ||
"""Download the contents of this file. | ||
|
||
This operation is blocking until all data is downloaded. | ||
:rtype: bytes or str | ||
""" | ||
return await self._downloader.readall() | ||
|
||
async def readinto(self, stream): | ||
"""Download the contents of this file to a stream. | ||
|
||
:param stream: | ||
The stream to download to. This can be an open file-handle, | ||
or any writable stream. The stream must be seekable if the download | ||
uses more than one parallel connection. | ||
:returns: The number of bytes read. | ||
:rtype: int | ||
""" | ||
return await self._downloader.readinto(stream) |
This file contains 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 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.
Should we also update any samples @xiafu-msft added recently?
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.
@xiafu-msft I think the upload/download sample I updated is the only one?