Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/RasaHQ/rasa into update_n…
Browse files Browse the repository at this point in the history
…lu_read
  • Loading branch information
arthurTemporim committed Jul 4, 2019
2 parents 03057ae + 4eebbc8 commit 0ff07df
Show file tree
Hide file tree
Showing 13 changed files with 56 additions and 27 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,10 @@ before_script:
jobs:
include:
- stage: test
name: "Black Formatting"
name: "Code Formatting"
python: 3.6
script:
- pip install black
- black --check .
- make lint
- stage: test
name: "Type Check"
python: 3.6
Expand All @@ -52,7 +51,7 @@ jobs:
name: "Test 3.5"
python: "3.5"
script:
- py.test tests --cov rasa
- make test
- <<: *run-tests
name: "Test 3.6"
python: '3.6'
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Added
- debug logging now tells you which tracker store is connected
- the response of ``/model/train`` now includes a response header for the trained model filename
- ``Validator`` class to help developing by checking if the files have any errors
- project's code is now linted using flake8

Changed
-------
Expand Down
38 changes: 22 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
.PHONY: clean test lint init check-readme

TEST_PATH=./

help:
@echo " clean"
@echo " Remove python artifacts and build artifacts."
@echo " Remove Python/build artifacts."
@echo " formatter"
@echo " Apply black formatting to code."
@echo " lint"
@echo " Check style with flake8."
@echo " Lint code with flake8, and check if black formatter should be applied."
@echo " types"
@echo " Check for type errors using pytype."
@echo " test"
@echo " Run py.test"
@echo " Run pytest on tests/."
@echo " check-readme"
@echo " Check if the readme can be converted from md to rst for pypi"
@echo " init"
@echo " Install Rasa Core"

init:
pip install -r requirements.txt
@echo " Check if the README can be converted from .md to .rst for PyPI."
@echo " doctest"
@echo " Run all doctests embedded in the documentation."
@echo " livedocs"
@echo " Build the docs locally."

clean:
find . -name '*.pyc' -exec rm -f {} +
Expand All @@ -24,22 +25,27 @@ clean:
rm -rf build/
rm -rf .pytype/
rm -rf dist/
rm -rf *.egg-info
rm -rf docs/_build

formatter:
black rasa tests

lint:
black .
flake8 rasa tests
black --check rasa tests

types:
pytype --keep-going rasa

test: clean
py.test tests --verbose --color=yes $(TEST_PATH)
black --check .
py.test tests --cov rasa

doctest: clean
cd docs && make doctest

livedocs:
cd docs && make livehtml

# if this runs through we can be sure the readme is properly shown on pypi
check-readme:
# if this runs through we can be sure the readme is properly shown on pypi
python setup.py check --restructuredtext --strict
13 changes: 13 additions & 0 deletions docs/migration-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ how you can migrate from one version to another.

Rasa NLU 0.14.x and Rasa Core 0.13.x to Rasa 1.0
------------------------------------------------
.. warning::

This is a release **breaking backwards compatibility**.
It is not possible to load previously trained models. Please make sure to retrain a
model before trying to use it with this improved version.

General
~~~~~~~
Expand All @@ -32,6 +37,10 @@ General
- If you were previously importing the ``Button`` or ``Element`` classes from
``rasa_core.dispatcher``, these are now to be imported from ``rasa_sdk.utils``.

- Rasa NLU and Core previously used `separate configuration files
<https://legacy-docs.rasa.com/docs/nlu/0.15.1/migrations/?&_ga=2.218966814.608734414.1560704810-314462423.1543594887#id1>`.
These two files should be merged into a single file either named ``config.yml``, or passed via the ``--config`` parameter.

Script parameters
~~~~~~~~~~~~~~~~~
- All script parameter names have been unified to follow the same schema.
Expand All @@ -50,3 +59,7 @@ Script parameters
defined with ``--max-history``. Output paths and log files cannot be specified with ``-o`` anymore; ``--out`` and
``--log-file`` should be used. NLU data has been standarized to be ``--nlu`` and the name of
any kind of data files or directory to be ``--data``.

HTTP API
~~~~~~~~
- There are numerous HTTP API endpoint changes which can be found `here <http://rasa.com/docs/rasa/api/http-api/>`.
2 changes: 0 additions & 2 deletions rasa/cli/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ def train_core(
args.stories, "stories", DEFAULT_DATA_PATH, none_is_valid=True
)

_train_path = train_path or tempfile.mkdtemp()

# Policies might be a list for the compare training. Do normal training
# if only list item was passed.
if not isinstance(args.config, list) or len(args.config) == 1:
Expand Down
4 changes: 4 additions & 0 deletions rasa/core/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,10 @@ def cleaned_domain(self) -> Dict[Text, Any]:
for idx, intent_info in enumerate(domain_data["intents"]):
for name, intent in intent_info.items():
if intent.get("use_entities"):
intent.pop("use_entities")
if not intent.get("ignore_entities"):
intent.pop("ignore_entities")
if len(intent) == 0:
domain_data["intents"][idx] = name

for slot in domain_data["slots"].values(): # pytype: disable=attribute-error
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/training/dsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ async def read_from_folder(
story_steps.extend(steps)

# if exclusion percentage is not 100
if exclusion_percentage and exclusion_percentage is not 100:
if exclusion_percentage and exclusion_percentage != 100:
import random

idx = int(round(exclusion_percentage / 100.0 * len(story_steps)))
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def from_files(
"""Create an instance from the domain, nlu and story files."""

domain = Domain.load(domain_file)
loop = asyncio.new_event_loop()
asyncio.new_event_loop()
stories = await StoryFileReader.read_from_folder(story_data, domain)
intents = load_data(nlu_data)

Expand Down
2 changes: 1 addition & 1 deletion rasa/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def read_yaml(content: Text) -> Union[List[Any], Dict[Text, Any]]:
# noinspection PyUnresolvedReferences
try:
return yaml_parser.load(content) or {}
except yaml.scanner.ScannerError as _:
except yaml.scanner.ScannerError:
# A `ruamel.yaml.scanner.ScannerError` might happen due to escaped
# unicode sequences that form surrogate pairs. Try converting the input
# to a parsable format based on
Expand Down
4 changes: 4 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ nbsphinx==0.3.2
aioresponses==0.6.0
moto==1.3.8

# lint/format
black==19.3b0; python_version>='3.6'
flake8==3.7.7

# pipeline dependencies
spacy==2.1.4
jieba==0.39
Expand Down
4 changes: 4 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ log_cli_level = WARNING
[metadata]
description-file = README.md
license_file = LICENSE.txt

[flake8]
max-line-length = 88
ignore = W503, E121, E126, E211, E225, E501, E203, W391, E402, F401, F811, F405, F403
2 changes: 1 addition & 1 deletion tests/core/test_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async def test_agent_train(tmpdir, default_domain):
assert [s.name for s in loaded.domain.slots] == [s.name for s in agent.domain.slots]

# test policies
assert type(loaded.policy_ensemble) is type(agent.policy_ensemble) # nopep8
assert isinstance(loaded.policy_ensemble, type(agent.policy_ensemble))
assert [type(p) for p in loaded.policy_ensemble.policies] == [
type(p) for p in agent.policy_ensemble.policies
]
Expand Down
2 changes: 1 addition & 1 deletion tests/nlu/base/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_remove_model_invalid(empty_model_dir):
test_file_path = os.path.join(empty_model_dir, test_file)
write_to_file(test_file_path, test_content)

with pytest.raises(ValueError) as e:
with pytest.raises(ValueError):
remove_model(empty_model_dir)

os.remove(test_file_path)
Expand Down

0 comments on commit 0ff07df

Please sign in to comment.