Skip to content

Commit

Permalink
Catch non existing config file.
Browse files Browse the repository at this point in the history
  • Loading branch information
tabergma committed Jun 11, 2019
1 parent 5d435ad commit 7420ce2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions rasa/cli/train.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import os
import tempfile
from typing import List, Optional, Text, Dict
import rasa.cli.arguments as arguments
Expand Down Expand Up @@ -182,6 +183,14 @@ def _get_valid_config(
if config:
# config is provided via '-c' argument. config file needs to contain
# all mandatory keys
if not os.path.exists(config):
print_error(
"The config file '{}' does not exist. Use '--config' to specify a "
"valid config file."
"".format(config)
)
exit(1)

missing_keys = missing_config_keys(config, mandatory_keys)
if missing_keys:
print_error(
Expand Down
5 changes: 5 additions & 0 deletions tests/cli/test_rasa_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,8 @@ def test_get_valid_config(parameters):
if expected_data is not None:
for k, v in expected_data.items():
assert config_data[k] == v


def test_get_valid_config_with_non_existing_file():
with pytest.raises(SystemExit):
_get_valid_config("non-existing-file.yml", CONFIG_MANDATORY_KEYS)

0 comments on commit 7420ce2

Please sign in to comment.