Skip to content

Commit

Permalink
Fix incorrect attribute for key prefix in RedisTrackerStore
Browse files Browse the repository at this point in the history
  • Loading branch information
ducminh-phan committed Nov 21, 2020
1 parent c3e9167 commit 7da2ce0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
8 changes: 5 additions & 3 deletions rasa/core/tracker_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,18 +346,20 @@ def save(self, tracker, timeout=None):
timeout = self.record_exp

serialised_tracker = self.serialise_tracker(tracker)
self.red.set(self.prefix + tracker.sender_id, serialised_tracker, ex=timeout)
self.red.set(
self.key_prefix + tracker.sender_id, serialised_tracker, ex=timeout
)

def retrieve(self, sender_id: Text) -> Optional[DialogueStateTracker]:
stored = self.red.get(self.prefix + sender_id)
stored = self.red.get(self.key_prefix + sender_id)
if stored is not None:
return self.deserialise_tracker(sender_id, stored)
else:
return None

def keys(self) -> Iterable[Text]:
"""Returns keys of the Redis Tracker Store"""
return self.red.keys(self.prefix + "*")
return self.red.keys(self.key_prefix + "*")


class DynamoTrackerStore(TrackerStore):
Expand Down
11 changes: 3 additions & 8 deletions tests/shared/core/test_trackers.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,15 @@


class MockRedisTrackerStore(RedisTrackerStore):
# skipcq:PYL-W0231
# can't call call super init since it would init a redis connection
def __init__(self, _domain: Domain) -> None:
super().__init__(_domain)

# Patch the Redis connection in RedisTrackerStore using fakeredis
self.red = fakeredis.FakeStrictRedis()
self.record_exp = None

# added in redis==3.3.0, but not yet in fakeredis
self.red.connection_pool.connection_class.health_check_interval = 0

# Defined in RedisTrackerStore but needs to be added for the MockRedisTrackerStore
self.prefix = "tracker:"

TrackerStore.__init__(self, _domain)


def stores_to_be_tested():
temp = tempfile.mkdtemp()
Expand Down

0 comments on commit 7da2ce0

Please sign in to comment.