Skip to content

Commit

Permalink
Merge branch 'remove_iter_text_lines' of https://github.com/iscai-msf…
Browse files Browse the repository at this point in the history
…t/azure-sdk-for-python into switch_to_protocol

* 'remove_iter_text_lines' of https://github.com/iscai-msft/azure-sdk-for-python:
  update tests
  remove iter_text and iter_lines
  [ServiceBus] Improve test stability and cpu usage (Azure#20352)
  t2-Netapp-update-to-2021-06-01 (Azure#20453)
  [AutoRelease] t2-keyvault-2021-08-26-55443 (Azure#20423)
  Sync eng/common directory with azure-sdk-tools for PR 1943 (Azure#20450)
  New dummy password in README (Azure#20328)
  • Loading branch information
iscai-msft committed Aug 30, 2021
2 parents 90da0a4 + d7e39c7 commit 60a8123
Show file tree
Hide file tree
Showing 153 changed files with 18,939 additions and 12,520 deletions.
10 changes: 8 additions & 2 deletions eng/common/TestResources/New-TestResources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,13 @@ try {
&$preDeploymentScript -ResourceGroupName $ResourceGroupName @PSBoundParameters
}

Log "Deploying template '$($templateFile.originalFilePath)' to resource group '$($resourceGroup.ResourceGroupName)'"
$msg = if ($templateFile.jsonFilePath -ne $templateFile.originalFilePath) {
"Deployment template $($templateFile.jsonFilePath) from $($templateFile.originalFilePath) to resource group $($resourceGroup.ResourceGroupName)"
} else {
"Deployment template $($templateFile.jsonFilePath) to resource group $($resourceGroup.ResourceGroupName)"
}
Log $msg

$deployment = Retry {
$lastDebugPreference = $DebugPreference
try {
Expand Down Expand Up @@ -538,7 +544,7 @@ try {
Write-Host 'File option is supported only on Windows'
}

$outputFile = "$($templateFile.jsonFilePath).env"
$outputFile = "$($templateFile.originalFilePath).env"

$environmentText = $deploymentOutputs | ConvertTo-Json;
$bytes = ([System.Text.Encoding]::UTF8).GetBytes($environmentText)
Expand Down
1 change: 1 addition & 0 deletions sdk/core/azure-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
an `encoding` parameter.
- `azure.core.rest.HttpResponse` and `azure.core.rest.AsyncHttpResponse` are now abstract base classes. They should not be initialized directly, instead
your transport responses should inherit from them and implement them.
- Removed `iter_text` and `iter_lines` from `azure.core.rest.HttpResponse` and `azure.core.rest.AsyncHttpResponse`

### Bugs Fixed

Expand Down
34 changes: 0 additions & 34 deletions sdk/core/azure-core/azure/core/rest/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,40 +226,6 @@ def lookup_encoding(encoding):
except LookupError:
return False

def parse_lines_from_text(text):
# largely taken from httpx's LineDecoder code
lines = []
last_chunk_of_text = ""
while text:
text_length = len(text)
for idx in range(text_length):
curr_char = text[idx]
next_char = None if idx == len(text) - 1 else text[idx + 1]
if curr_char == "\n":
lines.append(text[: idx + 1])
text = text[idx + 1: ]
break
if curr_char == "\r" and next_char == "\n":
# if it ends with \r\n, we only do \n
lines.append(text[:idx] + "\n")
text = text[idx + 2:]
break
if curr_char == "\r" and next_char is not None:
# if it's \r then a normal character, we switch \r to \n
lines.append(text[:idx] + "\n")
text = text[idx + 1:]
break
if next_char is None:
last_chunk_of_text += text
text = ""
break
if last_chunk_of_text.endswith("\r"):
# if ends with \r, we switch \r to \n
lines.append(last_chunk_of_text[:-1] + "\n")
elif last_chunk_of_text:
lines.append(last_chunk_of_text)
return lines

def to_pipeline_transport_request_helper(rest_request):
from ..pipeline.transport import HttpRequest as PipelineTransportHttpRequest
return PipelineTransportHttpRequest(
Expand Down
18 changes: 0 additions & 18 deletions sdk/core/azure-core/azure/core/rest/_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,21 +381,3 @@ def iter_bytes(self):
:return: An iterator of bytes from the response
:rtype: Iterator[str]
"""

@abc.abstractmethod
def iter_text(self):
# type: () -> Iterator[str]
"""Iterates over the text in the response.
:return: An iterator of string. Each string chunk will be a text from the response.
:rtype: Iterator[str]
"""

@abc.abstractmethod
def iter_lines(self):
# type: () -> Iterator[str]
"""Iterates over the lines in the response.
:return: An iterator of string. Each string chunk will be a line from the response.
:rtype: Iterator[str]
"""
40 changes: 0 additions & 40 deletions sdk/core/azure-core/azure/core/rest/_rest_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,24 +376,6 @@ def iter_bytes(self) -> Iterator[bytes]:
"""
...

@abc.abstractmethod
def iter_text(self) -> Iterator[str]:
"""Iterates over the text in the response.
:return: An iterator of string. Each string chunk will be a text from the response.
:rtype: Iterator[str]
"""
...

@abc.abstractmethod
def iter_lines(self) -> Iterator[str]:
"""Iterates over the lines in the response.
:return: An iterator of string. Each string chunk will be a line from the response.
:rtype: Iterator[str]
"""
...

class AsyncHttpResponse(_HttpResponseBase):
"""**Provisional** abstract base class for Async HTTP responses.
Expand Down Expand Up @@ -441,28 +423,6 @@ async def iter_bytes(self) -> AsyncIterator[bytes]:
# getting around mypy behavior, see https://github.com/python/mypy/issues/10732
yield # pylint: disable=unreachable

@abc.abstractmethod
async def iter_text(self) -> AsyncIterator[str]:
"""Asynchronously iterates over the text in the response.
:return: An async iterator of string. Each string chunk will be a text from the response
:rtype: AsyncIterator[str]
"""
raise NotImplementedError()
# getting around mypy behavior, see https://github.com/python/mypy/issues/10732
yield # pylint: disable=unreachable

@abc.abstractmethod
async def iter_lines(self) -> AsyncIterator[str]:
"""Asynchronously iterates over the lines in the response.
:return: An async iterator of string. Each string chunk will be a line from the response.
:rtype: AsyncIterator[str]
"""
raise NotImplementedError()
# getting around mypy behavior, see https://github.com/python/mypy/issues/10732
yield # pylint: disable=unreachable

@abc.abstractmethod
async def close(self) -> None:
...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,25 @@ async def test_iter_bytes(client):
assert response.is_closed
assert raw == b"Hello, world!"

@pytest.mark.asyncio
async def test_iter_text(client):
request = HttpRequest("GET", "/basic/string")
# @pytest.mark.asyncio
# async def test_iter_text(client):
# request = HttpRequest("GET", "/basic/string")

async with client.send_request(request, stream=True) as response:
content = ""
async for part in response.iter_text():
content += part
assert content == "Hello, world!"
# async with client.send_request(request, stream=True) as response:
# content = ""
# async for part in response.iter_text():
# content += part
# assert content == "Hello, world!"

@pytest.mark.asyncio
async def test_iter_lines(client):
request = HttpRequest("GET", "/basic/lines")
# @pytest.mark.asyncio
# async def test_iter_lines(client):
# request = HttpRequest("GET", "/basic/lines")

async with client.send_request(request, stream=True) as response:
content = []
async for line in response.iter_lines():
content.append(line)
assert content == ["Hello,\n", "world!"]
# async with client.send_request(request, stream=True) as response:
# content = []
# async for line in response.iter_lines():
# content.append(line)
# assert content == ["Hello,\n", "world!"]


@pytest.mark.asyncio
Expand Down Expand Up @@ -161,10 +161,10 @@ async def test_iter_read_back_and_forth(client):
# the reason why the code flow is like this, is because the 'iter_x' functions don't
# actually read the contents into the response, the output them. Once they're yielded,
# the stream is closed, so you have to catch the output when you iterate through it
request = HttpRequest("GET", "/basic/lines")
request = HttpRequest("GET", "/basic/string")

async with client.send_request(request, stream=True) as response:
async for line in response.iter_lines():
async for line in response.iter_bytes():
assert line
with pytest.raises(ResponseNotReadError):
response.text()
Expand All @@ -175,16 +175,16 @@ async def test_iter_read_back_and_forth(client):

@pytest.mark.asyncio
async def test_stream_with_return_pipeline_response(client):
request = HttpRequest("GET", "/basic/lines")
request = HttpRequest("GET", "/basic/string")
pipeline_response = await client.send_request(request, stream=True, _return_pipeline_response=True)
assert hasattr(pipeline_response, "http_request")
assert hasattr(pipeline_response.http_request, "content")
assert hasattr(pipeline_response, "http_response")
assert hasattr(pipeline_response, "context")
parts = []
async for line in pipeline_response.http_response.iter_lines():
async for line in pipeline_response.http_response.iter_bytes():
parts.append(line)
assert parts == ['Hello,\n', 'world!']
assert parts == [b'Hello, world!']
await client.close()

@pytest.mark.asyncio
Expand Down
46 changes: 23 additions & 23 deletions sdk/core/azure-core/tests/test_rest_stream_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,23 +79,23 @@ def test_iter_bytes(client):
assert response.is_stream_consumed
assert raw == b"Hello, world!"

def test_iter_text(client):
request = HttpRequest("GET", "/basic/string")
# def test_iter_text(client):
# request = HttpRequest("GET", "/basic/string")

with client.send_request(request, stream=True) as response:
content = ""
for part in response.iter_text():
content += part
assert content == "Hello, world!"
# with client.send_request(request, stream=True) as response:
# content = ""
# for part in response.iter_text():
# content += part
# assert content == "Hello, world!"

def test_iter_lines(client):
request = HttpRequest("GET", "/basic/lines")
# def test_iter_lines(client):
# request = HttpRequest("GET", "/basic/lines")

with client.send_request(request, stream=True) as response:
content = []
for line in response.iter_lines():
content.append(line)
assert content == ["Hello,\n", "world!"]
# with client.send_request(request, stream=True) as response:
# content = []
# for line in response.iter_lines():
# content.append(line)
# assert content == ["Hello,\n", "world!"]

def test_sync_streaming_response(client):
request = HttpRequest("GET", "/streams/basic")
Expand Down Expand Up @@ -175,16 +175,16 @@ def test_decompress_compressed_header(client):
url = "https://{}.blob.core.windows.net/tests/test_with_header.tar.gz".format(account_name)
request = HttpRequest("GET", url)
response = client.send_request(request, stream=True)
iter = response.iter_text()
data = "".join(list(iter))
assert data == "test"
iter = response.iter_bytes()
data = b"".join(list(iter))
assert data == b"test"

def test_iter_read(client):
# thanks to McCoy Patiño for this test!
request = HttpRequest("GET", "/basic/lines")
request = HttpRequest("GET", "/basic/string")
response = client.send_request(request, stream=True)
response.read()
iterator = response.iter_lines()
iterator = response.iter_bytes()
for line in iterator:
assert line
assert response.text()
Expand All @@ -196,9 +196,9 @@ def test_iter_read_back_and_forth(client):
# the reason why the code flow is like this, is because the 'iter_x' functions don't
# actually read the contents into the response, the output them. Once they're yielded,
# the stream is closed, so you have to catch the output when you iterate through it
request = HttpRequest("GET", "/basic/lines")
request = HttpRequest("GET", "/basic/string")
response = client.send_request(request, stream=True)
iterator = response.iter_lines()
iterator = response.iter_bytes()
for line in iterator:
assert line
with pytest.raises(ResponseNotReadError):
Expand All @@ -209,12 +209,12 @@ def test_iter_read_back_and_forth(client):
response.text()

def test_stream_with_return_pipeline_response(client):
request = HttpRequest("GET", "/basic/lines")
request = HttpRequest("GET", "/basic/string")
pipeline_response = client.send_request(request, stream=True, _return_pipeline_response=True)
assert hasattr(pipeline_response, "http_request")
assert hasattr(pipeline_response, "http_response")
assert hasattr(pipeline_response, "context")
assert list(pipeline_response.http_response.iter_lines()) == ['Hello,\n', 'world!']
assert list(pipeline_response.http_response.iter_bytes()) == [b'Hello, world!']

def test_error_reading(client):
request = HttpRequest("GET", "/errors/403")
Expand Down
10 changes: 10 additions & 0 deletions sdk/keyvault/azure-mgmt-keyvault/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Release History

## 9.1.0 (2021-08-26)

**Features**

- Model VirtualNetworkRule has a new parameter ignore_missing_vnet_service_endpoint
- Model VaultProperties has a new parameter hsm_pool_resource_id
- Model PrivateEndpointConnectionItem has a new parameter etag
- Model PrivateEndpointConnectionItem has a new parameter id
- Model ServiceSpecification has a new parameter metric_specifications

## 9.0.0 (2021-04-19)

**Features**
Expand Down
11 changes: 7 additions & 4 deletions sdk/keyvault/azure-mgmt-keyvault/_meta.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"autorest": "3.3.0",
"use": "@autorest/[email protected]",
"commit": "afa4f1aa31962637ee6fd722511337016a681515",
"autorest": "3.4.5",
"use": [
"@autorest/[email protected]",
"@autorest/[email protected]"
],
"commit": "277fe93bafa204e9e9a8544155ff07c33c5b54f1",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"autorest_command": "autorest specification/keyvault/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.6.5 --version=3.3.0",
"autorest_command": "autorest specification/keyvault/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/[email protected] --version=3.4.5",
"readme": "specification/keyvault/resource-manager/readme.md"
}
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,13 @@ def keys(self):
"""Instance depends on the API version:
* 2019-09-01: :class:`KeysOperations<azure.mgmt.keyvault.v2019_09_01.operations.KeysOperations>`
* 2020-04-01-preview: :class:`KeysOperations<azure.mgmt.keyvault.v2020_04_01_preview.operations.KeysOperations>`
"""
api_version = self._get_api_version('keys')
if api_version == '2019-09-01':
from .v2019_09_01.operations import KeysOperations as OperationClass
elif api_version == '2020-04-01-preview':
from .v2020_04_01_preview.operations import KeysOperations as OperationClass
else:
raise ValueError("API version {} does not have operation group 'keys'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
Expand Down Expand Up @@ -243,13 +246,10 @@ def secrets(self):
"""Instance depends on the API version:
* 2020-04-01-preview: :class:`SecretsOperations<azure.mgmt.keyvault.v2020_04_01_preview.operations.SecretsOperations>`
* 2021-04-01-preview: :class:`SecretsOperations<azure.mgmt.keyvault.v2021_04_01_preview.operations.SecretsOperations>`
"""
api_version = self._get_api_version('secrets')
if api_version == '2020-04-01-preview':
from .v2020_04_01_preview.operations import SecretsOperations as OperationClass
elif api_version == '2021-04-01-preview':
from .v2021_04_01_preview.operations import SecretsOperations as OperationClass
else:
raise ValueError("API version {} does not have operation group 'secrets'".format(api_version))
return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# license information.
# --------------------------------------------------------------------------

VERSION = "9.0.0"
VERSION = "9.1.0"
Loading

0 comments on commit 60a8123

Please sign in to comment.