Ejemplo 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")
Ejemplo 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")
Ejemplo n.º 3
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")
Ejemplo n.º 4
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")
Ejemplo n.º 5
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")