From ed5a1cb917b13367805fcbdc09170143bb228582 Mon Sep 17 00:00:00 2001 From: Tawakalt Date: Mon, 5 Feb 2024 14:00:04 +0100 Subject: [PATCH 1/4] Add --endpoints flag --- rasa_sdk/cli/arguments.py | 7 ++++++- rasa_sdk/constants.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/rasa_sdk/cli/arguments.py b/rasa_sdk/cli/arguments.py index 0e1dbe78c..a3b218357 100644 --- a/rasa_sdk/cli/arguments.py +++ b/rasa_sdk/cli/arguments.py @@ -1,6 +1,6 @@ import argparse -from rasa_sdk.constants import DEFAULT_SERVER_PORT +from rasa_sdk.constants import DEFAULT_SERVER_PORT, DEFAULT_ENDPOINTS_PATH def action_arg(action): @@ -54,3 +54,8 @@ def add_endpoint_arguments(parser): help="Enable auto-reloading of modules containing Action subclasses.", action="store_true", ) + parser.add_argument( + "--endpoints", + default=DEFAULT_ENDPOINTS_PATH, + help="Configuration file for tracing as a yml file.", + ) diff --git a/rasa_sdk/constants.py b/rasa_sdk/constants.py index ad52aaeb1..16637dfb1 100644 --- a/rasa_sdk/constants.py +++ b/rasa_sdk/constants.py @@ -10,3 +10,4 @@ PYTHON_LOGGING_SCHEMA_DOCS = ( "https://docs.python.org/3/library/logging.config.html#dictionary-schema-details" ) +DEFAULT_ENDPOINTS_PATH = "endpoints.yml" From 36ee12410f198233f945e02c9bdcefd5c573d2cb Mon Sep 17 00:00:00 2001 From: Tawakalt Date: Mon, 5 Feb 2024 14:35:20 +0100 Subject: [PATCH 2/4] add changelog entry --- changelog/1072.improvement.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/1072.improvement.md diff --git a/changelog/1072.improvement.md b/changelog/1072.improvement.md new file mode 100644 index 000000000..96ccac73d --- /dev/null +++ b/changelog/1072.improvement.md @@ -0,0 +1 @@ +Add an `--endpoint` flag to the rasa_sdk CLI to enable tracing configuration. \ No newline at end of file From c928e65001afc70b355f00563c999de1586e52a0 Mon Sep 17 00:00:00 2001 From: Tawakalt Date: Mon, 5 Feb 2024 15:14:00 +0100 Subject: [PATCH 3/4] add test --- tests/test_arguments.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 tests/test_arguments.py diff --git a/tests/test_arguments.py b/tests/test_arguments.py new file mode 100644 index 000000000..4df2806e7 --- /dev/null +++ b/tests/test_arguments.py @@ -0,0 +1,12 @@ +import rasa_sdk.endpoint as ep + + +def test_arg_parser_endpoints(): + parser = ep.create_argument_parser() + args = ["--endpoints", "endpoint.yml"] + cmdline_args = parser.parse_args(args) + assert cmdline_args.endpoints == "endpoint.yml" + + help_text = parser.format_help() + assert "--endpoints ENDPOINTS" in help_text + assert " Configuration file for tracing as a yml file." in help_text From e9d7183b1700839db9b313b65fe7f7f39a2a1ab6 Mon Sep 17 00:00:00 2001 From: Tawakalt Date: Mon, 5 Feb 2024 15:59:35 +0100 Subject: [PATCH 4/4] implement PR feedback --- rasa_sdk/cli/arguments.py | 2 +- tests/test_arguments.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/rasa_sdk/cli/arguments.py b/rasa_sdk/cli/arguments.py index a3b218357..c520d72af 100644 --- a/rasa_sdk/cli/arguments.py +++ b/rasa_sdk/cli/arguments.py @@ -57,5 +57,5 @@ def add_endpoint_arguments(parser): parser.add_argument( "--endpoints", default=DEFAULT_ENDPOINTS_PATH, - help="Configuration file for tracing as a yml file.", + help="Configuration file for the assistant as a yml file.", ) diff --git a/tests/test_arguments.py b/tests/test_arguments.py index 4df2806e7..bbb111d52 100644 --- a/tests/test_arguments.py +++ b/tests/test_arguments.py @@ -1,12 +1,21 @@ import rasa_sdk.endpoint as ep +import pytest +from rasa_sdk.constants import DEFAULT_ENDPOINTS_PATH -def test_arg_parser_endpoints(): + +@pytest.mark.parametrize( + "args, expected", + [ + ([], DEFAULT_ENDPOINTS_PATH), + (["--endpoints", "a.yml"], "a.yml"), + ], +) +def test_arg_parser_endpoints(args, expected): parser = ep.create_argument_parser() - args = ["--endpoints", "endpoint.yml"] cmdline_args = parser.parse_args(args) - assert cmdline_args.endpoints == "endpoint.yml" + assert cmdline_args.endpoints == expected help_text = parser.format_help() assert "--endpoints ENDPOINTS" in help_text - assert " Configuration file for tracing as a yml file." in help_text + assert " Configuration file for the assistant as a yml file." in help_text