def run_locally(args: argparse.Namespace) -> None: """Run a Rasa X instance locally. Args: args: commandline arguments """ _prevent_failure_if_git_is_not_available() try: # noinspection PyUnresolvedReferences from rasax.community import local except ModuleNotFoundError: raise MissingDependencyException( f"Rasa X does not seem to be installed, but it is needed for this " f"CLI command. You can find more information on how to install Rasa X " f"in local mode in the documentation: " f"{DOCS_BASE_URL_RASA_X}/installation-and-setup/install/local-mode" ) args.rasa_x_port = args.rasa_x_port or DEFAULT_RASA_X_PORT args.port = args.port or DEFAULT_RASA_PORT project_path = "." _validate_rasa_x_start(args, project_path) rasa_x_token = generate_rasa_x_token() process = start_rasa_for_local_rasa_x(args, rasa_x_token=rasa_x_token) config_path = _get_config_path(args) domain_path = _get_domain_path(args) telemetry.track_rasa_x_local() # noinspection PyBroadException try: local.main( args, project_path, args.data, token=rasa_x_token, config_path=config_path, domain_path=domain_path, ) except RasaXTermsError: # User didn't accept the Rasa X terms. pass except Exception: print(traceback.format_exc()) rasa.shared.utils.cli.print_error( "Sorry, something went wrong (see error above). Make sure to start " "Rasa X with valid data and valid domain and config files. Please, " "also check any warnings that popped up.\nIf you need help fixing " "the issue visit our forum: https://forum.rasa.com/." ) finally: process.terminate()
def validate_requirements(component_names: List[Optional[Text]]) -> None: """Validates that all required importable python packages are installed. Raises: InvalidConfigException: If one of the component names is `None`, likely indicates that a custom implementation is missing this property or that there is an invalid configuration file that we did not catch earlier. Args: component_names: The list of component names. """ from rasa.nlu import registry # Validate that all required packages are installed failed_imports = {} for component_name in component_names: if component_name is None: raise InvalidConfigException( "Your pipeline configuration contains a component that is missing " "a name. Please double check your configuration or if this is a " "custom component make sure to implement the name property for " "the component." ) component_class = registry.get_component_class(component_name) unavailable_packages = find_unavailable_packages( component_class.required_packages() ) if unavailable_packages: failed_imports[component_name] = unavailable_packages if failed_imports: # pragma: no cover dependency_component_map = defaultdict(list) for component, missing_dependencies in failed_imports.items(): for dependency in missing_dependencies: dependency_component_map[dependency].append(component) missing_lines = [ f"{d} (needed for {', '.join(cs)})" for d, cs in dependency_component_map.items() ] missing = "\n - ".join(missing_lines) raise MissingDependencyException( f"Not all required importable packages are installed to use " f"the configured NLU pipeline. " f"To use this pipeline, you need to install the " f"missing modules: \n" f" - {missing}\n" f"Please install the packages that contain the missing modules." )
def validate_requirements(component_names: List[Text]) -> None: """Validates that all required importable python packages are installed. Args: component_names: The list of component names. """ from rasa.nlu import registry # Validate that all required packages are installed failed_imports = {} for component_name in component_names: component_class = registry.get_component_class(component_name) unavailable_packages = find_unavailable_packages( component_class.required_packages() ) if unavailable_packages: failed_imports[component_name] = unavailable_packages if failed_imports: # pragma: no cover dependency_component_map = defaultdict(list) for component, missing_dependencies in failed_imports.items(): for dependency in missing_dependencies: dependency_component_map[dependency].append(component) missing_lines = [ f"{d} (needed for {', '.join(cs)})" for d, cs in dependency_component_map.items() ] missing = "\n - ".join(missing_lines) raise MissingDependencyException( f"Not all required importable packages are installed to use " f"the configured NLU pipeline. " f"To use this pipeline, you need to install the " f"missing modules: \n" f" - {missing}\n" f"Please install the packages that contain the missing modules." )