8000 Merge branch 'master' into master · ShYuPe/botbuilder-python@ffb5d14 · GitHub
[go: up one dir, main page]

Skip to content

Commit ffb5d14

Browse files
authored
Merge branch 'master' into master
2 parents 740e9c7 + a94e899 commit ffb5d14

File tree

5 files changed

+92
-4
lines changed

5 files changed

+92
-4
lines changed

.github/CODEOWNERS

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Lines starting with '#' are comments.
2+
# Each line is a file pattern followed by one or more owners.
3+
4+
# More details are here: https://help.github.com/articles/about-codeowners/
5+
6+
# The '*' pattern is global owners.
7+
8+
# Order is important. The last matching pattern has the most precedence.
9+
# The folders are ordered as follows:
10+
11+
# In each subsection folders are ordered first by depth, then alphabetically.
12+
# This should make it easy to add new rules without breaking existing ones.
13+
14+
# Bot Framework SDK notes:
15+
# The first code owners for a file or library are the primary approvers.
16+
# The later code owners represent a "escalation path" in case the primary code owners are unavailable.
17+
# - @microsoft/bb-python will also never receive a request for a PR review and should be manually requested
18+
# for PRs that only trigger the Global rule ("*")
19+
# - @microsoft/bf-admin should never receive a request for a PR review
20+
21+
# Global rule:
22+
* @microsoft/bb-python @microsoft/bf-admin
23+
24+
# Adapters
25+
/libraries/botbuilder-adapters-slack/** @garypretty @microsoft/bb-python @microsoft/bf-admin
26+
27+
# Platform Integration Libaries
28+
/libraries/botbuilder-integration-aiohttp/** @microsoft/bf-admin @axelsrz @tracyboehrer
29+
/libraries/botbuilder-integration-applicationinsights-aiohttp/** @microsoft/bf-admin @axelsrz @tracyboehrer
30+
31+
# BotBuilder libraries
32+
/libraries/botbuilder-ai/botbuilder/ai/luis/** @microsoft/bf-admin @bb-python @munozemilio
33+
/libraries/botbuilder-ai/botbuilder/ai/qna/** @microsoft/bf-admin @bb-python @johnataylor
34+
/libraries/botbuilder-applicationinsights/** @microsoft/bf-admin @bb-python @munozemilio
35+
/libraries/botbuilder-core/** @johnataylor @microsoft/bb-python @microsoft/bf-admin
36+
/libraries/botbuilder-core/botbuilder/core/teams/** @microsoft/bb-python @microsoft/bf-admin @microsoft/bf-teams
37+
/libraries/botbuilder-dialogs/** @johnataylor @microsoft/bb-python @microsoft/bf-admin
38+
/libraries/botframework-connector/** @microsoft/bf-admin @bb-python @johnataylor
39+
/libraries/botframework-connector/botframework/connector/auth/** @microsoft/bf-admin @bb-python @bf-auth
40+
/libraries/botbuilder-streaming/** @microsoft/bf-admin @microsoft/bf-streaming

libraries/botbuilder-applicationinsights/botbuilder/applicationinsights/application_insights_telemetry_client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,18 @@ def __init__(
3838
instrumentation_key: str,
3939
telemetry_client: TelemetryClient = None,
4040
telemetry_processor: Callable[[object, object], bool] = None,
41+
client_queue_size: int = None,
4142
):
4243
self._instrumentation_key = instrumentation_key
44+
4345
self._client = (
4446
telemetry_client
4547
if telemetry_client is not None
4648
else TelemetryClient(self._instrumentation_key)
4749
)
50+
if client_queue_size:
51+
self._client.channel.queue.max_queue_length = client_queue_size
52+
4853
# Telemetry Processor
4954
processor = (
5055
telemetry_processor

libraries/botbuilder-core/botbuilder/core/adapter_extensions.py

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Copyright (c) Microsoft Corporation. All rights reserved.
22
# Licensed under the MIT License.
3+
from warnings import warn
4+
35
from botbuilder.core import (
46
BotAdapter,
7+
BotState,
58
Storage,
69
RegisterClassMiddleware,
710
UserState,
@@ -23,6 +26,39 @@ def use_storage(adapter: BotAdapter, storage: Storage) -> BotAdapter:
2326
"""
2427
return adapter.use(RegisterClassMiddleware(storage))
2528

29+
@staticmethod
30+
def use_bot_state(
31+
bot_adapter: BotAdapter, *bot_states: BotState, auto: bool = True
32+
) -> BotAdapter:
33+
"""
34+
Registers bot state object into the TurnContext. The botstate will be available via the turn context.
35+
36+
:param bot_adapter: The BotAdapter on which to register the state objects.
37+
:param bot_states: One or more BotState objects to register.
38+
:return: The updated adapter.
39+
"""
40+
if not bot_states:
41+
raise TypeError("At least one BotAdapter is required")
42+
43+
for bot_state in bot_states:
44+
bot_adapter.use(
45+
RegisterClassMiddleware(
46+
bot_state, AdapterExtensions.fullname(bot_state)
47+
)
48+
)
49+
50+
if auto:
51+
bot_adapter.use(AutoSaveStateMiddleware(bot_states))
52+
53+
return bot_adapter
< A3E2 /code>54+
55+
@staticmethod
56+
def fullname(obj):
57+
module = obj.__class__.__module__
58+
if module is None or module == str.__class__.__module__:
59+
return obj.__class__.__name__ # Avoid reporting __builtin__
60+
return module + "." + obj.__class__.__name__
61+
2662
@staticmethod
2763
def use_state(
2864
adapter: BotAdapter,
@@ -31,7 +67,7 @@ def use_state(
3167
auto: bool = True,
3268
) -> BotAdapter:
3369
"""
34-
Registers user and conversation state objects with the adapter. These objects will be available via
70+
[DEPRECATED] Registers user and conversation state objects with the adapter. These objects will be available via
3571
the turn context's `turn_state` property.
3672
3773
:param adapter: The BotAdapter on which to register the state objects.
@@ -40,6 +76,11 @@ def use_state(
4076
:param auto: True to automatically persist state each turn.
4177
:return: The BotAdapter
4278
"""
79+
warn(
80+
"This method is deprecated in 4.9. You should use the method .use_bot_state() instead.",
81+
DeprecationWarning,
82+
)
83+
4384
if not adapter:
4485
raise TypeError("BotAdapter is required")
4586

libraries/botbuilder-core/botbuilder/core/register_class_middleware.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,18 @@ class RegisterClassMiddleware(Middleware):
1010
Middleware for adding an object to or registering a service with the current turn context.
1111
"""
1212

13-
def __init__(self, service):
13+
def __init__(self, service, key: str = None):
1414
self.service = service
15+
self._key = key
1516

1617
async def on_turn(
1718
self, context: TurnContext, logic: Callable[[TurnContext], Awaitable]
1819
):
1920
# C# has TurnStateCollection with has overrides for adding items
2021
# to TurnState. Python does not. In C#'s case, there is an 'Add'
2122
# to handle adding object, and that uses the fully qualified class name.
22-
context.turn_state[self.fullname(self.service)] = self.service
23+
key = self._key or self.fullname(self.service)
24+
context.turn_state[key] = self.service
2325
await logic()
2426

2527
@staticmethod

libraries/botbuilder-dialogs/tests/test_dialogextensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ async def capture_eoc(
221221
logic, TestAdapter.create_conversation_reference(conversation_id)
222222
)
223223
AdapterExtensions.use_storage(adapter, storage)
224-
AdapterExtensions.use_state(adapter, user_state, convo_state)
224+
AdapterExtensions.use_bot_state(adapter, user_state, convo_state)
225225
adapter.use(TranscriptLoggerMiddleware(ConsoleTranscriptLogger()))
226226

227227
return TestFlow(None, adapter)

0 commit comments

Comments
 (0)
0