Skip to content
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

Allow EndpointConfig as parameter type given to AwaitableTrackerStore.create() method #11368

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/11368.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handle the case when an `EndpointConfig` object is given as parameter to the `AwaitableTrackerStore.create()` method.
5 changes: 4 additions & 1 deletion rasa/core/tracker_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -1398,10 +1398,13 @@ def create(
"""Wrapper to call `create` method of primary tracker store."""
if isinstance(obj, TrackerStore):
return AwaitableTrackerStore(obj)
elif isinstance(obj, EndpointConfig):
return AwaitableTrackerStore(_create_from_endpoint_config(obj))
else:
raise ValueError(
f"{type(obj).__name__} supplied "
f"but expected object of type {TrackerStore.__name__}."
f"but expected object of type {TrackerStore.__name__} or "
f"of type {EndpointConfig.__name__}."
)

async def retrieve(self, sender_id: Text) -> Optional[DialogueStateTracker]:
Expand Down
10 changes: 10 additions & 0 deletions tests/core/test_tracker_stores.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,13 @@ def test_create_non_async_tracker_store(domain: Domain):
tracker_store = TrackerStore.create(endpoint_config)
assert isinstance(tracker_store, AwaitableTrackerStore)
assert isinstance(tracker_store._tracker_store, NonAsyncTrackerStore)


def test_create_awaitable_tracker_store_with_endpoint_config():
endpoint_config = EndpointConfig(
type="tests.core.test_tracker_stores.NonAsyncTrackerStore"
)
tracker_store = AwaitableTrackerStore.create(endpoint_config)

assert isinstance(tracker_store, AwaitableTrackerStore)
assert isinstance(tracker_store._tracker_store, NonAsyncTrackerStore)