def test_default_project_has_no_warnings(testdir: Testdir, default_config: Dict[Text, Any]): parser = create_argument_parser() rasa.cli.scaffold.create_initial_project(".") config = copy.deepcopy(default_config) for _, items in config.items(): for item in items: if "epochs" in item: item["epochs"] = 1 item["evaluate_every_number_of_epochs"] = -1 rasa.shared.utils.io.write_yaml(config, "config.yml") with pytest.warns(None) as warning_recorder: rasa.cli.data.validate_files(parser.parse_args(["data", "validate"])) rasa.cli.train.run_training(parser.parse_args(["train"])) # pytest.warns would override any warning filters that we could set assert not [ warning for warning in warning_recorder.list if not any( type(warning.message) == warning_type and re.match(warning_message, str(warning.message)) for warning_type, warning_message in EXPECTED_WARNINGS) ]
def _get_train_files_cmd(): """Get the raw train data by fetching the train file given in the command line arguments to the train script. """ cmdline_args = create_argument_parser().parse_args() if not cmdline_args.__contains__("nlu"): cmdline_args.nlu = 'data/nlu.json' files = utils.list_files(cmdline_args.nlu) return [file for file in files if _guess_format(file) == RASA_NLU]
def _get_train_files_cmd(): """Get the raw train data by fetching the train file given in the command line arguments to the train script. When training the NLU model explicitly, the training data will be in the "nlu" argument, otherwise it will be in the "data" argument. """ cmdline_args = create_argument_parser().parse_args() try: files = list_files(cmdline_args.nlu) except AttributeError: files = list(get_core_nlu_files(cmdline_args.data)[1]) return [file for file in files if _guess_format(file) == RASA_NLU]
def test_default_project_has_no_warnings(testdir: Testdir, default_config: Dict[Text, Any]): parser = create_argument_parser() rasa.cli.scaffold.create_initial_project(".") config = copy.deepcopy(default_config) for model_part, items in config.items(): for item in items: if "epochs" in item: item["epochs"] = 1 item["evaluate_every_number_of_epochs"] = -1 rasa.shared.utils.io.write_yaml(config, "config.yml") with pytest.warns(None) as warning_recorder: rasa.cli.data.validate_files(parser.parse_args(["data", "validate"])) rasa.cli.train.run_training(parser.parse_args(["train"])) assert not [ w for w in warning_recorder._list if not _warning_should_be_filtered_out(w) ]