def shell(args: argparse.Namespace) -> None: """Talk with a bot though the command line.""" from rasa.cli.utils import get_validated_path from rasa.shared.constants import DEFAULT_MODELS_PATH args.connector = "cmdline" model = get_validated_path(args.model, "model", DEFAULT_MODELS_PATH) try: model = get_latest_model(model) except ModelNotFound: print_error("No model found. Train a model before running the " "server using `rasa train`.") return metadata = LocalModelStorage.metadata_from_archive(model) if metadata.training_type == TrainingType.NLU: import rasa.nlu.run telemetry.track_shell_started("nlu") rasa.nlu.run.run_cmdline(model) else: import rasa.cli.run telemetry.track_shell_started("rasa") rasa.cli.run.run(args)
def shell(args: argparse.Namespace) -> None: from rasa.cli.utils import get_validated_path from rasa.shared.constants import DEFAULT_MODELS_PATH from rasa.model import get_model, get_model_subdirectories args.connector = "cmdline" model = get_validated_path(args.model, "model", DEFAULT_MODELS_PATH) try: model_path = get_model(model) except ModelNotFound: print_error( "No model found. Train a model before running the " "server using `rasa train`." ) return core_model, nlu_model = get_model_subdirectories(model_path) if not core_model: import rasa.nlu.run telemetry.track_shell_started("nlu") rasa.nlu.run.run_cmdline(nlu_model) else: import rasa.cli.run telemetry.track_shell_started("rasa") rasa.cli.run.run(args)
async def test_events_schema( monkeypatch: MonkeyPatch, default_agent: Agent, config_path: Text ): # this allows us to patch the printing part used in debug mode to collect the # reported events monkeypatch.setenv("RASA_TELEMETRY_DEBUG", "true") monkeypatch.setenv("RASA_TELEMETRY_ENABLED", "true") mock = Mock() monkeypatch.setattr(telemetry, "print_telemetry_event", mock) with open(TELEMETRY_EVENTS_JSON) as f: schemas = json.load(f)["events"] initial = asyncio.all_tasks() # Generate all known backend telemetry events, and then use events.json to # validate their schema. training_data = TrainingDataImporter.load_from_config(config_path) with telemetry.track_model_training(training_data, "rasa"): await asyncio.sleep(1) telemetry.track_telemetry_disabled() telemetry.track_data_split(0.5, "nlu") telemetry.track_validate_files(True) telemetry.track_data_convert("yaml", "nlu") telemetry.track_tracker_export(5, TrackerStore(domain=None), EventBroker()) telemetry.track_interactive_learning_start(True, False) telemetry.track_server_start([CmdlineInput()], None, None, 42, True) telemetry.track_project_init("tests/") telemetry.track_shell_started("nlu") telemetry.track_rasa_x_local() telemetry.track_visualization() telemetry.track_core_model_test(5, True, default_agent) telemetry.track_nlu_model_test(TrainingData()) pending = asyncio.all_tasks() - initial await asyncio.gather(*pending) assert mock.call_count == 15 for args, _ in mock.call_args_list: event = args[0] # `metrics_id` automatically gets added to all event but is # not part of the schema so we need to remove it before validation del event["properties"]["metrics_id"] jsonschema.validate( instance=event["properties"], schema=schemas[event["event"]] )