Skip to content

Commit

Permalink
Merge branch 'master' into safe_load_spacy
Browse files Browse the repository at this point in the history
  • Loading branch information
tabergma authored May 31, 2019
2 parents b01ef17 + 2e03ad4 commit 237bcfc
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 54 deletions.
22 changes: 17 additions & 5 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
<!-- THIS INFORMATION IS MANDATORY - YOUR ISSUE WILL BE CLOSED IF IT IS MISSING. If you don't know your Rasa Core version, use `pip list | grep rasa`. Removing the below information is allowed for FEATURE REQUESTS. -->
<!-- THIS INFORMATION IS MANDATORY - YOUR ISSUE WILL BE CLOSED IF IT IS MISSING. If you don't know your Rasa version, use `pip list | grep rasa`. Removing the below information is allowed for FEATURE REQUESTS. Please format any code or console output with the three ticks ``` above and below. -->

**Rasa version**:

**Python version**:
**Rasa X version** (if used & relevant):

**Python version**:

**Operating system** (windows, osx, ...):

**Issue**:



**Content of configuration file (config.yml)**:
**Error (including full traceback)**:
```
```

**Command or request that led to error**:
```
```

**Content of configuration file (config.yml)** (if relevant):
```yml

```

**Content of domain file (domain.yml)** (if used & relevant):
```yaml
**Content of domain file (domain.yml)** (if relevant):
```yml

```
49 changes: 11 additions & 38 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ env:
# https://github.com/travis-ci/travis-ci/issues/7940
global:
- BOTO_CONFIG=/dev/null
- COVERALLS_PARALLEL=true
- PIP_USE_PEP517=false

install:
Expand All @@ -33,50 +32,26 @@ install:
before_script:
- mkdir $HOME/tmp
- export TMPDIR=$HOME/tmp
after_success:
- coveralls
jobs:
include:
- stage: test
name: "Black Formatting"
python: 3.6
script: pip install black; black --check .
- &test-core
- &run-tests
stage: test
name: "Test Core 3.6"
python: "3.6"
name: "Test 3.5"
python: "3.5"
script:
- py.test tests/core --cov rasa -v --cov-append
- <<: *test-core
name: "Test Core 3.5"
python: '3.5'
- <<: *test-core
name: "Test Core 3.7"
python: '3.7'
- &test-nlu-base
stage: test
name: "Test NLU 3.6"
python: "3.6"
script:
- py.test tests/nlu/base --cov rasa -v --cov-append
- <<: *test-nlu-base
name: "Test NLU 3.5"
python: '3.5'
- <<: *test-nlu-base
name: "Test NLU 3.7"
python: '3.7'
- &test-nlu-training
stage: test
name: "Test NLU training 3.6"
python: "3.6"
script:
- py.test tests/nlu/training --cov rasa -v --cov-append
- <<: *test-nlu-training
name: "Test NLU training 3.5"
python: '3.5'
- <<: *test-nlu-training
name: "Test NLU training 3.7"
- py.test tests --cov rasa -v
- <<: *run-tests
name: "Test 3.6"
python: '3.6'
- <<: *run-tests
name: "Test 3.7"
python: '3.7'
after_success:
- coveralls # only this version will submit results to coveralls
- stage: integration
name: "Test API specification"
language: python
Expand All @@ -85,8 +60,6 @@ jobs:
script:
- swagger-cli validate docs/_static/spec/action-server.yml
- swagger-cli validate docs/_static/spec/rasa.yml
after_success:
- coveralls
- stage: test
if: branch =~ /(\d+\.\d+\.x)/ or branch = "master" # only new version PRs & PRs to master will test starter packs
name: "NLU starter pack (NLU only)"
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ This project adheres to `Semantic Versioning`_ starting with version 1.0.

Added
-----
- automatic creation of index on the ``sender_id`` column when using an SQL
tracker store. If you have an existing data and you are running into performance
issues, please make sure to add an index manually using
``CREATE INDEX event_idx_sender_id ON events (sender_id);``.

Changed
-------
Expand Down
2 changes: 1 addition & 1 deletion rasa/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
DEFAULT_REQUEST_TIMEOUT = 60 * 5 # 5 minutes

DOCS_BASE_URL = "https://rasa.com/docs/rasa"
LEGACY_DOCS_BASE_URL = "https://legacy-docs.rasa.com"
LEGACY_DOCS_BASE_URL = "http://legacy-docs.rasa.com"

FALLBACK_CONFIG_PATH = pkg_resources.resource_filename(
__name__, "cli/default_config.yml"
Expand Down
9 changes: 8 additions & 1 deletion rasa/core/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,15 @@ def __init__(
self._check_domain_sanity()

def __hash__(self) -> int:
self_as_string = json.dumps(self.as_dict())
from rasa.utils.common import sort_list_of_dicts_by_first_key

self_as_dict = self.as_dict()
self_as_dict["intents"] = sort_list_of_dicts_by_first_key(
self_as_dict["intents"]
)
self_as_string = json.dumps(self_as_dict, sort_keys=True)
text_hash = utils.get_text_hash(self_as_string)

return int(text_hash, 16)

@utils.lazyproperty
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/tracker_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class SQLEvent(Base):
__tablename__ = "events"

id = Column(Integer, primary_key=True)
sender_id = Column(String, nullable=False)
sender_id = Column(String, nullable=False, index=True)
type_name = Column(String, nullable=False)
timestamp = Column(Float)
intent_name = Column(String)
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def list_routes(app: Sanic):

def find_route(suffix, path):
for name, (uri, _) in app.router.routes_names.items():
if name.endswith(suffix) and uri == path:
if name.split(".")[-1] == suffix and uri == path:
return name
return None

Expand Down
5 changes: 5 additions & 0 deletions rasa/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,8 @@ def is_logging_disabled() -> bool:
log_level = os.environ.get(ENV_LOG_LEVEL, DEFAULT_LOG_LEVEL)

return log_level == "ERROR" or log_level == "WARNING"


def sort_list_of_dicts_by_first_key(dicts: List[Dict]) -> List[Dict]:
"""Sorts a list of dictionaries by their first key."""
return sorted(dicts, key=lambda d: list(d.keys())[0])
2 changes: 1 addition & 1 deletion tests/core/test_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def test_facebook_channel():
# the above marker marks the end of the code snipped included
# in the docs
routes_list = utils.list_routes(s)
print (routes_list)

assert routes_list.get("fb_webhook.health").startswith("/webhooks/facebook")
assert routes_list.get("fb_webhook.webhook").startswith(
"/webhooks/facebook/webhook"
Expand Down
12 changes: 6 additions & 6 deletions tests/test_skill.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_load_imports_from_directory_tree(tmpdir_factory: TempdirFactory):
subdirectory_3 = root / "Skill C"
subdirectory_3.mkdir()

actual = SkillSelector.load(root / "config.yml")
actual = SkillSelector.load(str(root / "config.yml"))
expected = {
os.path.join(str(skill_a_directory)),
os.path.join(str(skill_b_directory)),
Expand All @@ -60,9 +60,9 @@ def test_load_imports_without_imports(tmpdir_factory: TempdirFactory):
skill_b_directory.mkdir()
utils.dump_obj_as_yaml_to_file(skill_b_directory / "config.yml", empty_config)

actual = SkillSelector.load(root / "config.yml")
actual = SkillSelector.load(str(root / "config.yml"))

assert actual.is_imported(root / "Skill C")
assert actual.is_imported(str(root / "Skill C"))


@pytest.mark.parametrize("input_dict", [{}, {"imports": None}])
Expand All @@ -82,7 +82,7 @@ def test_load_if_subskill_is_more_specific_than_parent(tmpdir_factory: TempdirFa
skill_a_imports = {"imports": ["Skill B"]}
utils.dump_obj_as_yaml_to_file(skill_a_directory / "config.yml", skill_a_imports)

actual = SkillSelector.load(config_path)
actual = SkillSelector.load(str(config_path))

assert actual.is_imported(str(skill_a_directory))

Expand Down Expand Up @@ -131,7 +131,7 @@ def test_cyclic_imports(tmpdir_factory):
skill_b_imports = {"imports": ["../Skill A"]}
utils.dump_obj_as_yaml_to_file(skill_b_directory / "config.yml", skill_b_imports)

actual = SkillSelector.load(root / "config.yml")
actual = SkillSelector.load(str(root / "config.yml"))

assert actual._imports == {str(skill_a_directory), str(skill_b_directory)}

Expand All @@ -151,7 +151,7 @@ def test_import_outside_project_directory(tmpdir_factory):
skill_b_imports = {"imports": ["../Skill C"]}
utils.dump_obj_as_yaml_to_file(skill_b_directory / "config.yml", skill_b_imports)

actual = SkillSelector.load(skill_a_directory / "config.yml")
actual = SkillSelector.load(str(skill_a_directory / "config.yml"))

assert actual._imports == {str(skill_b_directory), str(root / "Skill C")}

Expand Down
10 changes: 10 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from aioresponses import aioresponses
from rasa.utils.endpoints import EndpointConfig
from tests.utilities import latest_request, json_of_latest_request
from rasa.utils.common import sort_list_of_dicts_by_first_key


async def test_endpoint_config():
Expand Down Expand Up @@ -51,3 +52,12 @@ async def test_endpoint_config():
assert s._default_headers.get("X-Powered-By") == "Rasa"
assert s._default_auth.login == "user"
assert s._default_auth.password == "pass"


def test_sort_dicts_by_keys():
test_data = [{"Z": 1}, {"A": 10}]

expected = [{"A": 10}, {"Z": 1}]
actual = sort_list_of_dicts_by_first_key(test_data)

assert actual == expected

0 comments on commit 237bcfc

Please sign in to comment.