Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change --data type in 'rasa data validate' command #8225

Merged
merged 28 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f85134c
Change --data type in 'rasa data validate' command
martasls Mar 17, 2021
85754b4
Merge branch 'main' into change-validate-data-type
ArjaanBuijk Mar 18, 2021
7658a36
Merge branch 'main' into change-validate-data-type
martasls Mar 19, 2021
ff8917e
Merge branch 'main' into change-validate-data-type
martasls Mar 23, 2021
aadd823
Merge branch 'main' into change-validate-data-type
martasls Mar 23, 2021
a3a6542
Add changelog entry
martasls Mar 23, 2021
48425df
Merge branch 'main' into change-validate-data-type
martasls Apr 3, 2021
2a9b90d
Fix data path in convert data method
martasls Apr 3, 2021
4bc12a3
Merge branch 'change-validate-data-type' of github.com:martasls/rasa …
martasls Apr 3, 2021
a95fac0
Merge branch 'main' into change-validate-data-type
martasls May 6, 2021
3364a3a
Adapt code to unit tests
martasls May 6, 2021
d054053
Merge branch 'change-validate-data-type' of github.com:martasls/rasa …
martasls May 6, 2021
e864fd1
Merge branch 'main' into change-validate-data-type
martasls May 7, 2021
189fe7a
Add missing import
martasls May 7, 2021
0eaa63f
Merge branch 'main' into change-validate-data-type
ArjaanBuijk May 7, 2021
4411a6c
Check date_file type on convert_training_data
martasls May 8, 2021
4f14b39
Merge branch 'main' into change-validate-data-type
martasls May 11, 2021
60f2c5a
Merge branch 'main' into change-validate-data-type
martasls May 12, 2021
69e34bc
Add docstrings to convert_training_data method
martasls May 12, 2021
124ad18
Merge branch 'main' into change-validate-data-type
martasls May 12, 2021
2974dde
Merge branch 'main' into change-validate-data-type
martasls May 12, 2021
5d35f6c
Update linting
martasls May 12, 2021
7de3aad
Merge branch 'change-validate-data-type' of github.com:martasls/rasa …
martasls May 12, 2021
eaca487
Remove other (binary) file
martasls May 12, 2021
a6020fc
Remove blank line after docstrings
martasls May 12, 2021
d2762d8
Merge branch 'main' into change-validate-data-type
ArjaanBuijk May 12, 2021
abf0eef
Make sure data_file is a string when passed to os.path.exists()
martasls May 12, 2021
f0941a9
Merge branch 'change-validate-data-type' of github.com:martasls/rasa …
martasls May 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/8225.improvement.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed --data option type in the ``rasa data validate``` command to allow more than one path to be passed.
2 changes: 0 additions & 2 deletions data/test_config/config_defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ pipeline: []
# - name: DIETClassifier
# epochs: 100
# constrain_similarities: true
# model_confidence: cosine
# - name: EntitySynonymMapper
# - name: ResponseSelector
# epochs: 100
# constrain_similarities: true
# model_confidence: cosine
# - name: FallbackClassifier
# threshold: 0.3
# ambiguity_threshold: 0.1
Expand Down
5 changes: 3 additions & 2 deletions rasa/cli/arguments/default_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ def add_data_param(
) -> None:
parser.add_argument(
"--data",
type=str,
default=default,
help=f"Path to the file or directory containing {data_type} data.",
nargs="+",
type=str,
help=f"Paths to the files or directories containing {data_type} data.",
required=required,
)

Expand Down
7 changes: 5 additions & 2 deletions rasa/cli/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
import shutil
from pathlib import Path
from typing import Dict, List, Text, TYPE_CHECKING
from typing import Dict, Union, List, Text, TYPE_CHECKING

import rasa.shared.core.domain
from rasa import telemetry
Expand Down Expand Up @@ -376,9 +376,12 @@ def _migrate_responses(args: argparse.Namespace) -> None:


async def _convert_to_yaml(
out_path: Text, data_path: Text, converter: "TrainingDataConverter"
out_path: Text, data_path: Union[list, Text], converter: "TrainingDataConverter"
) -> None:

if isinstance(data_path, list):
data_path = data_path[0]

output = Path(out_path)
if not os.path.exists(output):
rasa.shared.utils.cli.print_error_and_exit(
Expand Down
19 changes: 17 additions & 2 deletions rasa/nlu/convert.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
import argparse
import os
from typing import Text
from typing import Text, Union

from rasa.shared.utils.cli import print_error
import rasa.shared.nlu.training_data.loading
from rasa.nlu.utils import write_to_file


def convert_training_data(
data_file: Text, out_file: Text, output_format: Text, language: Text
data_file: Union[list, Text], out_file: Text, output_format: Text, language: Text
) -> None:
"""Convert training data.

Args:
data_file (Union[list, Text]): Path to the file or directory
containing Rasa data.
out_file (Text): File or existing path where to save
training data in Rasa format.
output_format (Text): Output format the training data
should be converted into.
language (Text): Language of the data.
"""

if isinstance(data_file, list):
data_file = data_file[0]

if not os.path.exists(data_file):
print_error(
"Data file '{}' does not exist. Provide a valid NLU data file using "
Expand Down
6 changes: 4 additions & 2 deletions tests/cli/test_rasa_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_data_convert_help(run: Callable[..., RunResult]):
output = run("data", "convert", "nlu", "--help")

help_text = """usage: rasa data convert nlu [-h] [-v] [-vv] [--quiet] [-f {json,md,yaml}]
--data DATA [--out OUT] [-l LANGUAGE]"""
--data DATA [DATA ...] [--out OUT] [-l LANGUAGE]"""

lines = help_text.split("\n")
# expected help text lines should appear somewhere in the output
Expand All @@ -109,7 +109,9 @@ def test_data_validate_help(run: Callable[..., RunResult]):

help_text = """usage: rasa data validate [-h] [-v] [-vv] [--quiet]
[--max-history MAX_HISTORY] [-c CONFIG]
[--fail-on-warnings] [-d DOMAIN] [--data DATA]"""
[--fail-on-warnings] [-d DOMAIN]
[--data DATA [DATA ...]]
{stories} ..."""

lines = help_text.split("\n")
# expected help text lines should appear somewhere in the output
Expand Down
4 changes: 2 additions & 2 deletions tests/cli/test_rasa_x.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
def test_x_help(run: Callable[..., RunResult]):
output = run("x", "--help")

help_text = """usage: rasa x [-h] [-v] [-vv] [--quiet] [-m MODEL] [--data DATA] [-c CONFIG]
[-d DOMAIN] [--no-prompt] [--production]
help_text = """usage: rasa x [-h] [-v] [-vv] [--quiet] [-m MODEL] [--data DATA [DATA ...]]
[-c CONFIG] [-d DOMAIN] [--no-prompt] [--production]
[--rasa-x-port RASA_X_PORT] [--config-endpoint CONFIG_ENDPOINT]
[--log-file LOG_FILE] [--endpoints ENDPOINTS] [-p PORT]
[-t AUTH_TOKEN] [--cors [CORS [CORS ...]]] [--enable-api]
Expand Down