Skip to content

Commit c8cc257

Browse files
committed
Merge branch 'switch_to_protocol' of https://github.com/iscai-msft/azure-sdk-for-python into switch_to_rest
* 'switch_to_protocol' of https://github.com/iscai-msft/azure-sdk-for-python: switch from protocol to abc add initial tests update changelog switch to protocol ensure test principal creation succeeds properly (Azure#20446) Update question-answering readme links (Azure#20439) Stip empty changelog sections before release (Azure#20437) [AutoRelease] t2-healthcareapis-2021-08-26-27542 (Azure#20422) [AutoRelease] t2-iothub-2021-08-25-25696 (Azure#20409) Get rid of LogsBatchQueryResult (Azure#20418)
2 parents 7fb1e18 + 324f1ae commit c8cc257

File tree

195 files changed

+24250
-1536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

195 files changed

+24250
-1536
lines changed

eng/common/TestResources/New-TestResources.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ try {
289289
$AzureTestPrincipal
290290
} else {
291291
Log "TestApplicationId was not specified; creating a new service principal in subscription '$SubscriptionId'"
292-
$global:AzureTestPrincipal = New-AzADServicePrincipal -Role Owner -Scope "/subscriptions/$SubscriptionId"
292+
$global:AzureTestPrincipal = New-AzADServicePrincipal -Role Owner -Scope "/subscriptions/$SubscriptionId" -DisplayName "test-resources-$($baseName).microsoft.com"
293293
$global:AzureTestSubscription = $SubscriptionId
294294

295295
Log "Created service principal '$($AzureTestPrincipal.ApplicationId)'"

eng/common/scripts/Prepare-Release.ps1

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,13 @@ else
184184
exit 1
185185
}
186186

187+
$changelogIsValid = Confirm-ChangeLogEntry -ChangeLogLocation $packageProperties.ChangeLogPath -VersionString $newVersion -ForRelease $true
188+
189+
if (!$changelogIsValid)
190+
{
191+
Write-Host "The changelog [$($packageProperties.ChangeLogPath)] is not valid for release. Please make sure it is valid before queuing release build." -ForegroundColor Red
192+
}
193+
187194
git diff -s --exit-code $packageProperties.DirectoryPath
188195
if ($LASTEXITCODE -ne 0)
189196
{

eng/common/scripts/Update-ChangeLog.ps1

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,47 @@ if ($LatestsSorted[0] -ne $Version) {
106106

107107
if ($ReplaceLatestEntryTitle)
108108
{
109-
$newChangeLogEntry = New-ChangeLogEntry -Version $Version -Status $ReleaseStatus -Content $ChangeLogEntries[$LatestVersion].ReleaseContent
109+
# Remove empty sections from content
110+
$sanitizedContent = @()
111+
$sectionContent = @()
112+
$sectionContentCount = 0
113+
$latesVersionContent = $ChangeLogEntries[$LatestVersion].ReleaseContent
114+
115+
foreach ($line in $latesVersionContent)
116+
{
117+
if ($line.StartsWith("### ") -or $sectionContentCount -gt 0)
118+
{
119+
if ($line.StartsWith("#") -and $sectionContentCount -gt 1)
120+
{
121+
$sanitizedContent += $sectionContent
122+
$sectionContent = @()
123+
$sectionContentCount = 0
124+
}
125+
126+
if ($line.StartsWith("#") -and $sectionContentCount -eq 1)
127+
{
128+
$sectionContent = @()
129+
$sectionContentCount = 0
130+
}
131+
132+
$sectionContent += $line
133+
if (-not [System.String]::IsNullOrWhiteSpace($line))
134+
{
135+
$sectionContentCount++
136+
}
137+
}
138+
elseif ($sectionContent.Count -eq 0)
139+
{
140+
$sanitizedContent += $line
141+
}
142+
}
143+
144+
if ($sectionContentCount -gt 1)
145+
{
146+
$sanitizedContent += $sectionContent
147+
}
148+
149+
$newChangeLogEntry = New-ChangeLogEntry -Version $Version -Status $ReleaseStatus -Content $sanitizedContent
110150
LogDebug "Resetting latest entry title to [$($newChangeLogEntry.ReleaseTitle)]"
111151
$ChangeLogEntries.Remove($LatestVersion)
112152
if ($newChangeLogEntry) {

sdk/cognitivelanguage/azure-ai-language-questionanswering/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ params = qna.KnowledgeBaseQueryOptions(
7979
question="How long should my Surface battery last?"
8080
)
8181

82-
output = client.query_knowledge_base(
82+
output = client.query_knowledgebase(
8383
params,
8484
project_name="FAQ",
8585
)
@@ -93,18 +93,17 @@ You can set additional properties on `KnowledgeBaseQueryOptions` to limit the nu
9393

9494
### Ask a follow-up question
9595

96-
If your knowledge base is configured for [chit-chat][questionanswering_docs_chat], you can ask a follow-up question provided the previous question-answering ID and, optionally, the exact question the user asked:
96+
If your knowledge base is configured for [chit-chat][questionanswering_docs_chat], the answers from the knowledge base may include suggested [prompts for follow-up questions][questionanswering_refdocs_prompts] to initiate a conversation. You can ask a follow-up question by providing the ID of your chosen answer as the context for the continued conversation:
9797

9898
```python
9999
params = qna.models.KnowledgeBaseQueryOptions(
100100
question="How long should charging take?"
101101
context=qna.models.KnowledgeBaseAnswerRequestContext(
102-
previous_user_query="How long should my Surface battery last?",
103102
previous_qna_id=previous_answer.id
104103
)
105104
)
106105

107-
output = client.query_knowledge_base(
106+
output = client.query_knowledgebase(
108107
params,
109108
project_name="FAQ"
110109
)
@@ -127,7 +126,7 @@ params = qna.KnowledgeBaseQueryOptions(
127126
question="How long should my Surface battery last?"
128127
)
129128

130-
output = await client.query_knowledge_base(
129+
output = await client.query_knowledgebase(
131130
params,
132131
project_name="FAQ"
133132
)
@@ -148,7 +147,7 @@ For example, if you submit a question to a non-existant knowledge base, a `400`
148147
from azure.core.exceptions import HttpResponseError
149148

150149
try:
151-
client.query_knowledge_base(
150+
client.query_knowledgebase(
152151
params,
153152
project_name="invalid-knowledge-base"
154153
)
@@ -198,14 +197,15 @@ This project has adopted the [Microsoft Open Source Code of Conduct][code_of_con
198197
[azure_core_ref_docs]: https://azuresdkdocs.blob.core.windows.net/$web/python/azure-core/latest/azure.core.html
199198
[azure_core_readme]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/core/azure-core/README.md
200199
[pip_link]:https://pypi.org/project/pip/
201-
[questionanswering_client_class]: https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/cognitivelanguage/azure-ai-language-questionanswering/azure/ai/language/questionanswering/_question_answering_client.py#L27
200+
[questionanswering_client_class]: https://azuresdkdocs.blob.core.windows.net/$web/python/azure-ai-language-questionanswering/1.0.0b1/azure.ai.language.questionanswering.html#azure.ai.language.questionanswering.QuestionAnsweringClient
201+
[questionanswering_refdocs_prompts]: https://azuresdkdocs.blob.core.windows.net/$web/python/azure-ai-language-questionanswering/1.0.0b1/azure.ai.language.questionanswering.models.html#azure.ai.language.questionanswering.models.KnowledgeBaseAnswerDialog
202202
[questionanswering_client_src]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cognitivelanguage/azure-ai-language-questionanswering/
203203
[questionanswering_docs]: https://azure.microsoft.com/services/cognitive-services/qna-maker/
204204
[questionanswering_docs_chat]: https://docs.microsoft.com/azure/cognitive-services/qnamaker/how-to/chit-chat-knowledge-base
205205
[questionanswering_docs_demos]: https://azure.microsoft.com/services/cognitive-services/qna-maker/#demo
206206
[questionanswering_docs_features]: https://azure.microsoft.com/services/cognitive-services/qna-maker/#features
207-
[questionanswering_pypi_package]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cognitivelanguage/azure-ai-language-questionanswering/
208-
[questionanswering_refdocs]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cognitivelanguage/azure-ai-language-questionanswering/
207+
[questionanswering_pypi_package]: https://pypi.org/project/azure-ai-language-questionanswering/
208+
[questionanswering_refdocs]: https://azuresdkdocs.blob.core.windows.net/$web/python/azure-ai-language-questionanswering/1.0.0b1/azure.ai.language.questionanswering.html
209209
[questionanswering_rest_docs]: https://docs.microsoft.com/rest/api/cognitiveservices-qnamaker/
210210
[questionanswering_samples]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/cognitivelanguage/azure-ai-language-questionanswering/samples/README.md
211211

sdk/core/azure-core/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
- The `text` property on `azure.core.rest.HttpResponse` and `azure.core.rest.AsyncHttpResponse` has changed to a method, which also takes
1212
an `encoding` parameter.
13+
- `azure.core.rest.HttpResponse` and `azure.core.rest.AsyncHttpResponse` are now abstract base classes. They should not be initialized directly, instead
14+
your transport responses should inherit from them and implement them.
1315

1416
### Bugs Fixed
1517

sdk/core/azure-core/azure/core/_pipeline_client_async.py

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
# --------------------------------------------------------------------------
2626

2727
import logging
28-
from collections.abc import Iterable
28+
import collections.abc
2929
from typing import Any, Awaitable
3030
from .configuration import Configuration
3131
from .pipeline import AsyncPipeline
@@ -61,6 +61,26 @@
6161

6262
_LOGGER = logging.getLogger(__name__)
6363

64+
class _AsyncContextManager(collections.abc.Awaitable):
65+
66+
def __init__(self, wrapped: collections.abc.Awaitable):
67+
super().__init__()
68+
self.wrapped = wrapped
69+
self.response = None
70+
71+
def __await__(self):
72+
return self.wrapped.__await__()
73+
74+
async def __aenter__(self):
75+
self.response = await self
76+
return self.response
77+
78+
async def __aexit__(self, *args):
79+
await self.response.__aexit__(*args)
80+
81+
async def close(self):
82+
await self.response.close()
83+
6484

6585
class AsyncPipelineClient(PipelineClientBase):
6686
"""Service client core methods.
@@ -124,7 +144,7 @@ def _build_pipeline(self, config, **kwargs): # pylint: disable=no-self-use
124144
config.proxy_policy,
125145
ContentDecodePolicy(**kwargs)
126146
]
127-
if isinstance(per_call_policies, Iterable):
147+
if isinstance(per_call_policies, collections.abc.Iterable):
128148
policies.extend(per_call_policies)
129149
else:
130150
policies.append(per_call_policies)
@@ -133,7 +153,7 @@ def _build_pipeline(self, config, **kwargs): # pylint: disable=no-self-use
133153
config.retry_policy,
134154
config.authentication_policy,
135155
config.custom_hook_policy])
136-
if isinstance(per_retry_policies, Iterable):
156+
if isinstance(per_retry_policies, collections.abc.Iterable):
137157
policies.extend(per_retry_policies)
138158
else:
139159
policies.append(per_retry_policies)
@@ -142,13 +162,13 @@ def _build_pipeline(self, config, **kwargs): # pylint: disable=no-self-use
142162
DistributedTracingPolicy(**kwargs),
143163
config.http_logging_policy or HttpLoggingPolicy(**kwargs)])
144164
else:
145-
if isinstance(per_call_policies, Iterable):
165+
if isinstance(per_call_policies, collections.abc.Iterable):
146166
per_call_policies_list = list(per_call_policies)
147167
else:
148168
per_call_policies_list = [per_call_policies]
149169
per_call_policies_list.extend(policies)
150170
policies = per_call_policies_list
151-
if isinstance(per_retry_policies, Iterable):
171+
if isinstance(per_retry_policies, collections.abc.Iterable):
152172
per_retry_policies_list = list(per_retry_policies)
153173
else:
154174
per_retry_policies_list = [per_retry_policies]
@@ -204,6 +224,5 @@ def send_request(
204224
:return: The response of your network call. Does not do error handling on your response.
205225
:rtype: ~azure.core.rest.AsyncHttpResponse
206226
"""
207-
from .rest._rest_py3 import _AsyncContextManager
208227
wrapped = self._make_pipeline_call(request, stream=stream, **kwargs)
209228
return _AsyncContextManager(wrapped=wrapped)

sdk/core/azure-core/azure/core/pipeline/_tools_async.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ def _get_response_type(pipeline_transport_response):
5555
return RestTrioRequestsTransportResponse
5656
except ImportError:
5757
pass
58-
from ..rest import AsyncHttpResponse
59-
return AsyncHttpResponse
58+
raise ValueError("Unknown transport response")
6059

6160
async def read_in_response(response, is_stream_response: Optional[bool]) -> None:
6261
try:

0 commit comments

Comments
 (0)