Custom tracker store not found. Using InMemoryTrackerStore instead

Rasa version - 1.3.7

I am getting the below issue(custom sql tracker store not found on server) :

2019-10-04 00:19:21 WARNING rasa.core.tracker_store - Store type ‘tracker_store.MySQLTrackerStore’ not found. Using InMemoryTrackerStore instead - custom tracker store file code below

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals

import contextlib
import json
import logging
import os
import pickle
import typing

import re
import spacy

from datetime import datetime, timezone
from typing import Iterator, Optional, Text, Iterable, Union, Dict
import itertools

# noinspection PyPep8Naming
from time import sleep

from rasa.core.actions.action import ACTION_LISTEN_NAME
from rasa.core.brokers.event_channel import EventChannel
from rasa.core.domain import Domain
from rasa.core.trackers import ActionExecuted, DialogueStateTracker, EventVerbosity
from rasa.core.tracker_store import SQLTrackerStore

if typing.TYPE_CHECKING:
    from sqlalchemy.engine.url import URL
    from sqlalchemy.engine.base import Engine
    from sqlalchemy.orm import Session

logger = logging.getLogger(__name__)

class MySQLTrackerStore(SQLTrackerStore):

    def __init__(
        domain: Optional[Domain] = None,
        url: Optional[Text] = None,
        dialect: Text = "sqlite",
        host: Optional[Text] = None,
        port: Optional[int] = None,
        db: Text = "rasa.db",
        username: Text = None,
        password: Text = None,
        event_broker: Optional[EventChannel] = None,
        query: Optional[Dict] = None,
    ) -> None:
        logger.debug("Initializing MySQLTrackerStore ...")
        self.nlp = spacy.load('en')

        super(MySQLTrackerStore, self).__init__(domain, dialect, host, port, db, username, password, event_broker, query)

    def save(self, tracker: DialogueStateTracker) -> None:
        """Update database with events from the current conversation."""

        if self.event_broker:

        with self.session_scope() as session:
            # only store recent events
            events = self._additional_events(session, tracker)  # only store recent events

            for event in events:
                data = event.as_dict()

                intent = data.get("parse_data", {}).get("intent", {}).get("name")
                action = data.get("name")
                timestamp = data.get("timestamp")

                # mask any protential PII data
                if event.type_name == 'user':
                    data["text"] = self.mask_data(data["text"])
                    data["parse_data"]["text"] = self.mask_data(data["parse_data"]["text"])

                # noinspection PyArgumentList

            "Tracker with sender_id '{}' "
            "stored to database".format(tracker.sender_id)


  type: tracker_store.MySQLTrackerStore
  dialect: "sqlite"  # the dialect used to interact with the db
  url: "http://localhost/"
  db: "rasa.db"  # path to your db

Could anybody please help?

According to the documentation, type should be SQL and url should be empty.

Its a custom tracker and i think type should be the class name. Issue got resolved by setting the PYTHONPATH before rasa run

Hey do you mind explaining what you mean when you say, “setting the PYTHONPATH before rasa run” ? I don’t get that part.


Hi Nikita, please tell me more information about your solution. I don’t understand: " Issue got resolved by setting the PYTHONPATH before rasa run"