Exemplo n.º 1
0
def command(language: tuple, bot_uuid: str):
    """
    display selected bot runtime logs.

    Args:
        language: language code of the bot to get logs from
        bot_uuid (str): optional argument stating the ID of the bot to get logs from
    """
    validate_robo_session()

    if len(language) == 0:
        bot_dir = abspath('.')
    elif len(language) == 1:
        bot_dir = abspath(join('.', 'languages', language[0]))
    else:
        print_message('Please select only one bot to check the logs.')
        exit(0)

    if not bot_uuid:
        bot_uuid = get_current_bot_uuid(bot_dir)

    # validate_bot(bot_uuid)

    with loading_indicator('Fetching logs from server...'):
        logs = get_runtime_logs(bot_uuid)

    print_info("Displaying logs for bot '{0}'\n".format(bot_uuid))
    print_message(logs + "\n")
Exemplo n.º 2
0
def command(language: tuple, bot_uuid: str):
    """
    Display the bot status

    Args:
        language (tuple): language code of the bot for the status to be shown
        bot_uuid (str): optional argument stating the bot ID for the status to be shown
    """
    validate_robo_session()

    if len(language) == 0:
        bot_dir = abspath(".")
    elif len(language) == 1:
        bot_dir = abspath(join(".", "languages", language[0]))
    else:
        print_message("Please select only one bot to check the status.\n")
        exit(0)

    if not bot_uuid:
        bot_uuid = get_current_bot_uuid(bot_dir)

    print_message("Bot UUID: {0}".format(bot_uuid))

    if does_the_runtime_exist(bot_uuid):
        runtime = get_bot_runtime(bot_uuid)
        print_message("Bot runtime status: {0}".format(runtime.status.value))
        if runtime.createdAt != "None":
            print_message("Runtime created at: {0}".format(
                datetime.strptime(
                    runtime.createdAt,
                    "%Y-%m-%dT%H:%M:%S.%f%z").strftime("%b %d %Y %H:%M:%S")))
    else:
        print_message("Bot runtime status: Not Created\n")
Exemplo n.º 3
0
def command():
    """
    Clean (remove) the package if this is available in the bot dir.
    """
    print_message("Cleaning the packaging...")
    with loading_indicator("Cleaning package files..."):
        if os.path.isdir(BUILD_DIR):
            shutil.rmtree(BUILD_DIR)
    print_success("Successfully cleaned")
Exemplo n.º 4
0
def command(language: tuple, skip_packaging: bool, package_file: str,
            bot_uuid: str, runtime_base_version: str, model: str):
    """
    Deploy a bot into the ROBO.AI platform.

    Args:
        language: language code of the bot to be deployed
        skip_packaging (bool): optional flag indicating whether packaging should be skipped
        package_file (str): optional flag stating where the package file is stored
        bot_uuid (str): optional argument stating the ID of the bot
        runtime_base_version (str): optional argument stating the runtime version
        model (str): optional argument with the path to the model to be packaged.
                    If no model is passed then the latest one is picked up.
    """
    validate_robo_session()

    if len(language) == 0:
        bot_dir = bot_ignore_dir = abspath(".")
    elif len(language) == 1:
        bot_dir = abspath(join(".", "languages", language[0]))
        bot_ignore_dir = dirname(dirname(bot_dir))
    else:
        print_message("Please select only one bot to deploy.\n")
        exit(0)

    if not bot_uuid:
        bot_uuid = get_current_bot_uuid(bot_dir)

    if not runtime_base_version:
        runtime_base_version = get_current_bot_base_version(bot_dir)

    if package_file:
        validate_package_file(package_file)
    elif not skip_packaging:
        package_file = create_package(bot_dir, bot_ignore_dir, model)
    elif not package_file:
        package_file = get_default_package_path()

    validate_package_file(package_file)

    if does_the_runtime_exist(bot_uuid):
        update_runtime(bot_uuid, package_file, runtime_base_version)
    else:
        create_runtime(bot_uuid, package_file, runtime_base_version)

    print_success("Deployment complete.\n")
Exemplo n.º 5
0
def command(
    language: tuple,
    bot_uuid: str,
    target_dir: str,
    base_version: str = "rasa-1.10.0",
):
    """
    Connect a local bot to a ROBO.AI server bot instance.
    This instance must be already created in the ROBO.AI platform.
    This command will generate a JSON file (robo-manifest) with metadata about the bot to be deployed.

    Args:
        language: language code of the bot to be connected.
        bot_uuid (str): optional argument stating the ID of the bot.
        target_dir (str): optional argument stating where the robo-manifest file should be stored.
        base_version (str): optional argument stating the engine base version. Defaults to 'rasa-1.10.0'
    """
    validate_robo_session()

    if not bot_uuid:
        bot_uuid = get_bot_uuid()

    # validate_bot(bot_uuid)

    if len(language) == 0:
        bot_dir = bot_ignore_dir = (os.path.abspath(target_dir)
                                    if target_dir else
                                    create_implementation_directory(bot_uuid))
    elif len(language) == 1:
        bot_dir = (os.path.abspath(join(target_dir, "languages", language[0]))
                   if target_dir else create_implementation_directory(bot_uuid)
                   )  # TODO check what this does
        bot_ignore_dir = join(dirname(dirname(bot_dir)))
    else:
        print_message("Please select only one bot to connect to.")
        exit(0)

    print_message("Bot target directory: {0}".format(bot_dir))

    create_bot_manifest(bot_dir, bot_uuid, base_version)
    create_bot_ignore(bot_ignore_dir)
    print_success("The bot was successfully initialized.")
Exemplo n.º 6
0
def command(language: tuple, model: str):
    """

    Package the required bot and make it ready for deployment.

    Args:
        language (tuple): language code of the bot to create a package of.
    """
    if len(language) == 0:
        bot_dir = bot_ignore_dir = abspath(".")
    elif len(language) == 1:
        bot_dir = abspath(join(".", "languages", language[0]))
        bot_ignore_dir = dirname(dirname(bot_dir))
    else:
        print_message("Please select only one bot to package.")
        exit(0)

    package_path = create_package(bot_dir, bot_ignore_dir, model)
    print_message("Package file: {0}".format(package_path))
    print_success("The packaging is complete.\n")
Exemplo n.º 7
0
def command(language: tuple, bot_uuid: str):
    """
    Remove a deployed bot from the ROBO.AI platform

    Args:
        language (tuple): language code of the bot to be removed
        bot_uuid (str): optional argument stating the ID of the bot to be removed
    """
    validate_robo_session()
    if len(language) == 0:
        bot_dir = abspath(".")
    elif len(language) == 1:
        bot_dir = abspath(join(".", "languages", language[0]))
    else:
        print_message("Please select only one bot runtime to be removed.\n")
        exit(0)
    if not bot_uuid:
        bot_uuid = get_current_bot_uuid(bot_dir)

    # validate_bot(bot_uuid)
    remove_runtime(bot_uuid)
    print_success("The bot runtime was successfully removed.\n")
Exemplo n.º 8
0
def command(language: tuple, bot_uuid: str):
    """
    Stop a bot running in the ROBO.AI platform.

    Args:
        language: language code of the bot to be stopped
        bot_uuid (str): optional argument stating the bot ID to be stopped.
    """
    validate_robo_session()

    if len(language) == 0:
        bot_dir = abspath(".")
    elif len(language) == 1:
        bot_dir = abspath(join(".", "languages", language[0]))
    else:
        print_message("Please select only one bot runtime to be stopped.\n")
        exit(0)

    if not bot_uuid:
        bot_uuid = get_current_bot_uuid(bot_dir)

    # validate_bot(bot_uuid)
    stop_runtime(bot_uuid)
    print_success("The bot runtime was successfully stopped.\n")
Exemplo n.º 9
0
def run():
    print_message(get_motd())
    cli()