Esempio n. 1
0
    def get(name, namespace, output):
        yatai_client = YataiClient()
        track_cli('deploy-get', PLATFORM_NAME)
        describe_result = yatai_client.deployment.describe(namespace, name)
        if describe_result.status.status_code != status_pb2.Status.OK:
            error_code, error_message = status_pb_to_error_code_and_message(
                describe_result.status
            )
            _echo(
                f'Failed to retrieve the latest status for AWS Lambda deployment '
                f'{name}. {error_code}:{error_message}',
                CLI_COLOR_ERROR,
            )
            return

        get_result = yatai_client.deployment.get(namespace, name)
        if get_result.status.status_code != status_pb2.Status.OK:
            error_code, error_message = status_pb_to_error_code_and_message(
                get_result.status
            )
            _echo(
                f'Failed to get AWS Lambda deployment {name}. '
                f'{error_code}:{error_message}',
                CLI_COLOR_ERROR,
            )
            return
        _print_deployment_info(get_result.deployment, output)
Esempio n. 2
0
 def get(name, namespace, output):
     yatai_client = YataiClient()
     track_cli('deploy-get', PLATFORM_NAME)
     try:
         get_result = yatai_client.deployment.get(namespace, name)
         if get_result.status.status_code != status_pb2.Status.OK:
             error_code, error_message = status_pb_to_error_code_and_message(
                 get_result.status)
             _echo(
                 f'Failed to get AWS Sagemaker deployment {name}. '
                 f'{error_code}:{error_message}',
                 CLI_COLOR_ERROR,
             )
             return
         describe_result = yatai_client.deployment.describe(namespace, name)
         if describe_result.status.status_code != status_pb2.Status.OK:
             error_code, error_message = status_pb_to_error_code_and_message(
                 describe_result.status)
             _echo(
                 f'Failed to retrieve the latest status for AWS Sagemaker '
                 f'deployment {name}. {error_code}:{error_message}',
                 CLI_COLOR_ERROR,
             )
             return
         get_result.deployment.state.CopyFrom(describe_result.state)
         _print_deployment_info(get_result.deployment, output)
     except BentoMLException as e:
         _echo(
             f'Failed to get AWS Sagemaker deployment {name} {str(e)}',
             CLI_COLOR_ERROR,
         )
Esempio n. 3
0
 def deploy(
     name,
     bento,
     namespace,
     region,
     min_size,
     desired_capacity,
     max_size,
     instance_type,
     ami_id,
     output,
     wait,
 ):
     yatai_client = get_default_yatai_client()
     bento_name, bento_version = bento.split(":")
     with Spinner(f"Deploying {bento} to AWS EC2"):
         result = yatai_client.deployment.create_ec2_deployment(
             name=name,
             namespace=namespace,
             bento_name=bento_name,
             bento_version=bento_version,
             region=region,
             min_size=min_size,
             desired_capacity=desired_capacity,
             max_size=max_size,
             instance_type=instance_type,
             ami_id=ami_id,
             wait=wait,
         )
     if result.status.status_code != yatai_proto.status_pb2.Status.OK:
         error_code, error_message = status_pb_to_error_code_and_message(
             result.status)
         raise CLIException(f'{error_code}:{error_message}')
     _print_deployment_info(result.deployment, output)
     _echo("Successfully created AWS EC2 deployment", CLI_COLOR_SUCCESS)
Esempio n. 4
0
 def deploy(
     name,
     namespace,
     bento,
     labels,
     region,
     api_name,
     memory_size,
     timeout,
     output,
     wait,
 ):
     yatai_client = YataiClient()
     bento_name, bento_version = bento.split(':')
     with Spinner(f'Deploying "{bento}" to AWS Lambda '):
         result = yatai_client.deployment.create_lambda_deployment(
             name=name,
             namespace=namespace,
             bento_name=bento_name,
             bento_version=bento_version,
             api_name=api_name,
             region=region,
             memory_size=memory_size,
             timeout=timeout,
             labels=labels,
             wait=wait,
         )
     if result.status.status_code != status_pb2.Status.OK:
         error_code, error_message = status_pb_to_error_code_and_message(
             result.status)
         raise CLIException(f'{error_code}:{error_message}')
     _echo(f'Successfully created AWS Lambda deployment {name}',
           CLI_COLOR_SUCCESS)
     _print_deployment_info(result.deployment, output)
Esempio n. 5
0
 def update(name, namespace, bento, memory_size, timeout, output, wait):
     _echo(
         message=
         'AWS Lambda deployment functionalities are being migrated to a '
         'separate tool and related CLI commands will be deprecated in BentoML '
         'itself, please use https://github.com/bentoml/aws-lambda-deploy '
         'going forward.',
         color='yellow',
     )
     yatai_client = get_default_yatai_client()
     if bento:
         bento_name, bento_version = bento.split(':')
     else:
         bento_name = None
         bento_version = None
     with Spinner('Updating Lambda deployment '):
         result = yatai_client.deployment.update_lambda_deployment(
             bento_name=bento_name,
             bento_version=bento_version,
             deployment_name=name,
             namespace=namespace,
             memory_size=memory_size,
             timeout=timeout,
             wait=wait,
         )
     if result.status.status_code != yatai_proto.status_pb2.Status.OK:
         error_code, error_message = status_pb_to_error_code_and_message(
             result.status)
         raise CLIException(f'{error_code}:{error_message}')
     _echo(
         f'Successfully updated AWS Lambda deployment {name}',
         CLI_COLOR_SUCCESS,
     )
     _print_deployment_info(result.deployment, output)
Esempio n. 6
0
 def update(name, namespace, bento, min_instances, max_burst,
            premium_plan_sku, output, wait):
     yatai_client = get_default_yatai_client()
     if bento:
         bento_name, bento_version = bento.split(':')
     else:
         bento_name = None
         bento_version = None
     with Spinner(f'Updating Azure Functions deployment {name}'):
         result = yatai_client.deployment.update_azure_functions_deployment(
             namespace=namespace,
             deployment_name=name,
             bento_name=bento_name,
             bento_version=bento_version,
             min_instances=min_instances,
             max_burst=max_burst,
             premium_plan_sku=premium_plan_sku,
             wait=wait,
         )
         if result.status.status_code != yatai_proto.status_pb2.Status.OK:
             error_code, error_message = status_pb_to_error_code_and_message(
                 result.status)
             raise CLIException(f'{error_code}:{error_message}')
         _echo(
             f'Successfully updated Azure Functions deployment {name}',
             CLI_COLOR_SUCCESS,
         )
         _print_deployment_info(result.deployment, output)
Esempio n. 7
0
 def update(name, namespace, bento, memory_size, timeout, output, wait):
     yatai_client = YataiClient()
     if bento:
         bento_name, bento_version = bento.split(':')
     else:
         bento_name = None
         bento_version = None
     with Spinner('Updating Lambda deployment '):
         result = yatai_client.deployment.update_lambda_deployment(
             bento_name=bento_name,
             bento_version=bento_version,
             deployment_name=name,
             namespace=namespace,
             memory_size=memory_size,
             timeout=timeout,
             wait=wait,
         )
     if result.status.status_code != status_pb2.Status.OK:
         error_code, error_message = status_pb_to_error_code_and_message(
             result.status)
         raise CLIException(f'{error_code}:{error_message}')
     _echo(
         f'Successfully updated AWS Lambda deployment {name}',
         CLI_COLOR_SUCCESS,
     )
     _print_deployment_info(result.deployment, output)
Esempio n. 8
0
 def deploy(
     name,
     namespace,
     bento,
     labels,
     region,
     api_name,
     memory_size,
     timeout,
     output,
     wait,
 ):
     track_cli('deploy-create', PLATFORM_NAME)
     yatai_client = YataiClient()
     bento_name, bento_version = bento.split(':')
     try:
         with Spinner(f'Deploying "{bento}" to AWS Lambda '):
             result = yatai_client.deployment.create_lambda_deployment(
                 name=name,
                 namespace=namespace,
                 bento_name=bento_name,
                 bento_version=bento_version,
                 api_name=api_name,
                 region=region,
                 memory_size=memory_size,
                 timeout=timeout,
                 labels=labels,
                 wait=wait,
             )
         if result.status.status_code != status_pb2.Status.OK:
             error_code, error_message = status_pb_to_error_code_and_message(
                 result.status)
             track_cli(
                 'deploy-create-failure',
                 PLATFORM_NAME,
                 {
                     'error_code': error_code,
                     'error_message': error_message
                 },
             )
             _echo(
                 f'Failed to create AWS Lambda deployment {name} '
                 f'{error_code}:{error_message}',
                 CLI_COLOR_ERROR,
             )
             return
         track_cli('deploy-create-success', PLATFORM_NAME)
         _echo(f'Successfully created AWS Lambda deployment {name}',
               CLI_COLOR_SUCCESS)
         _print_deployment_info(result.deployment, output)
     except BentoMLException as e:
         track_cli('deploy-create-failure', PLATFORM_NAME,
                   {'error_message': str(e)})
         _echo(
             f'Failed to create AWS Lambda deployment {name} {str(e)}',
             CLI_COLOR_ERROR,
         )
Esempio n. 9
0
 def deploy(
     name,
     bento,
     namespace,
     labels,
     region,
     instance_type,
     instance_count,
     num_of_gunicorn_workers_per_instance,
     api_name,
     timeout,
     output,
     wait,
 ):
     # use the DeploymentOperator name in proto to be consistent with amplitude
     track_cli('deploy-create', PLATFORM_NAME)
     bento_name, bento_version = bento.split(':')
     yatai_client = YataiClient()
     try:
         with Spinner('Deploying Sagemaker deployment '):
             result = yatai_client.deployment.create_sagemaker_deployment(
                 name=name,
                 namespace=namespace,
                 labels=labels,
                 bento_name=bento_name,
                 bento_version=bento_version,
                 instance_count=instance_count,
                 instance_type=instance_type,
                 num_of_gunicorn_workers_per_instance=
                 num_of_gunicorn_workers_per_instance,  # noqa E501
                 api_name=api_name,
                 timeout=timeout,
                 region=region,
                 wait=wait,
             )
         if result.status.status_code != status_pb2.Status.OK:
             error_code, error_message = status_pb_to_error_code_and_message(
                 result.status)
             _echo(
                 f'Failed to create AWS Sagemaker deployment {name} '
                 f'{error_code}:{error_message}',
                 CLI_COLOR_ERROR,
             )
             return
         track_cli('deploy-create-success', PLATFORM_NAME)
         _echo(
             f'Successfully created AWS Sagemaker deployment {name}',
             CLI_COLOR_SUCCESS,
         )
         _print_deployment_info(result.deployment, output)
     except BentoMLException as e:
         _echo(
             'Failed to create AWS Sagemaker deployment {}.: {}'.format(
                 name, str(e)),
             CLI_COLOR_ERROR,
         )
Esempio n. 10
0
 def deploy(
     name,
     bento,
     namespace,
     labels,
     region,
     instance_type,
     instance_count,
     num_of_gunicorn_workers_per_instance,
     api_name,
     timeout,
     output,
     wait,
     data_capture_s3_prefix,
     data_capture_sample_percent,
 ):
     _echo(
         message=
         'AWS Sagemaker deployment functionalities are being migrated to a '
         'separate tool and related CLI commands will be deprecated in BentoML '
         'itself, please use https://github.com/bentoml/aws-sagemaker-deploy '
         'going forward.',
         color='yellow',
     )
     # use the DeploymentOperator name in proto to be consistent with amplitude
     bento_name, bento_version = bento.split(':')
     yatai_client = get_default_yatai_client()
     with Spinner('Deploying Sagemaker deployment '):
         result = yatai_client.deployment.create_sagemaker_deployment(
             name=name,
             namespace=namespace,
             labels=labels,
             bento_name=bento_name,
             bento_version=bento_version,
             instance_count=instance_count,
             instance_type=instance_type,
             num_of_gunicorn_workers_per_instance=
             num_of_gunicorn_workers_per_instance,  # noqa E501
             api_name=api_name,
             timeout=timeout,
             region=region,
             wait=wait,
             data_capture_s3_prefix=data_capture_s3_prefix,
             data_capture_sample_percent=data_capture_sample_percent,
         )
     if result.status.status_code != yatai_proto.status_pb2.Status.OK:
         error_code, error_message = status_pb_to_error_code_and_message(
             result.status)
         raise CLIException(f'{error_code}:{error_message}')
     _echo(
         f'Successfully created AWS Sagemaker deployment {name}',
         CLI_COLOR_SUCCESS,
     )
     _print_deployment_info(result.deployment, output)
Esempio n. 11
0
 def deploy(
     namespace,
     name,
     bento,
     location,
     min_instances,
     max_burst,
     premium_plan_sku,
     labels,
     function_auth_level,
     output,
     wait,
 ):
     track_cli('deploy-create', PLATFORM_NAME)
     bento_name, bento_version = bento.split(':')
     yatai_client = YataiClient()
     try:
         with Spinner(f'Deploying {bento} to Azure Functions'):
             result = yatai_client.deployment.create_azure_functions_deployment(
                 name=name,
                 namespace=namespace,
                 labels=labels,
                 bento_name=bento_name,
                 bento_version=bento_version,
                 location=location,
                 min_instances=min_instances,
                 max_burst=max_burst,
                 premium_plan_sku=premium_plan_sku,
                 function_auth_level=function_auth_level,
                 wait=wait,
             )
             if result.status.status_code != status_pb2.Status.OK:
                 error_code, error_message = status_pb_to_error_code_and_message(
                     result.status
                 )
                 _echo(
                     f'Failed to create Azure Functions deployment {name} '
                     f'{error_code}:{error_message}',
                     CLI_COLOR_ERROR,
                 )
                 return
             track_cli('deploy-create-success', PLATFORM_NAME)
             _echo(
                 f'Successfully created Azure Functions deployment {name}',
                 CLI_COLOR_SUCCESS,
             )
             _print_deployment_info(result.deployment, output)
     except BentoMLException as e:
         _echo(
             f'Failed to create Azure Functions deployment {name}. {str(e)}',
             CLI_COLOR_ERROR,
         )
Esempio n. 12
0
 def update(
     name,
     namespace,
     bento,
     api_name,
     instance_type,
     instance_count,
     num_of_gunicorn_workers_per_instance,
     timeout,
     output,
     wait,
 ):
     yatai_client = YataiClient()
     track_cli('deploy-update', PLATFORM_NAME)
     if bento:
         bento_name, bento_version = bento.split(':')
     else:
         bento_name = None
         bento_version = None
     try:
         with Spinner('Updating Sagemaker deployment '):
             result = yatai_client.deployment.update_sagemaker_deployment(
                 namespace=namespace,
                 deployment_name=name,
                 bento_name=bento_name,
                 bento_version=bento_version,
                 instance_count=instance_count,
                 instance_type=instance_type,
                 num_of_gunicorn_workers_per_instance=
                 num_of_gunicorn_workers_per_instance,  # noqa E501
                 timeout=timeout,
                 api_name=api_name,
                 wait=wait,
             )
         if result.status.status_code != status_pb2.Status.OK:
             error_code, error_message = status_pb_to_error_code_and_message(
                 result.status)
             _echo(f'Failed to update AWS Sagemaker deployment {name}.'
                   f'{error_code}:{error_message}')
         track_cli('deploy-update-success', PLATFORM_NAME)
         _echo(
             f'Successfully updated AWS Sagemaker deployment {name}',
             CLI_COLOR_SUCCESS,
         )
         _print_deployment_info(result.deployment, output)
     except BentoMLException as e:
         _echo(
             f'Failed to update AWS Sagemaker deployment {name}: {str(e)}',
             CLI_COLOR_ERROR,
         )
Esempio n. 13
0
    def get(name, namespace, output):
        yatai_client = YataiClient()
        describe_result = yatai_client.deployment.describe(namespace, name)
        if describe_result.status.status_code != status_pb2.Status.OK:
            error_code, error_message = status_pb_to_error_code_and_message(
                describe_result.status)
            raise CLIException(f'{error_code}:{error_message}')

        get_result = yatai_client.deployment.get(namespace, name)
        if get_result.status.status_code != status_pb2.Status.OK:
            error_code, error_message = status_pb_to_error_code_and_message(
                get_result.status)
            raise CLIException(f'{error_code}:{error_message}')
        _print_deployment_info(get_result.deployment, output)
Esempio n. 14
0
 def update(name, namespace, bento, memory_size, timeout, output, wait):
     yatai_client = YataiClient()
     if bento:
         bento_name, bento_version = bento.split(':')
     else:
         bento_name = None
         bento_version = None
     try:
         with Spinner('Updating Lambda deployment '):
             result = yatai_client.deployment.update_lambda_deployment(
                 bento_name=bento_name,
                 bento_version=bento_version,
                 deployment_name=name,
                 namespace=namespace,
                 memory_size=memory_size,
                 timeout=timeout,
                 wait=wait,
             )
             if result.status.status_code != status_pb2.Status.OK:
                 error_code, error_message = status_pb_to_error_code_and_message(
                     result.status)
                 track_cli(
                     'deploy-update-failure',
                     PLATFORM_NAME,
                     {
                         'error_code': error_code,
                         'error_message': error_message
                     },
                 )
                 _echo(
                     f'Failed to update AWS Lambda deployment {name} '
                     f'{error_code}:{error_message}',
                     CLI_COLOR_ERROR,
                 )
                 return
             track_cli('deploy-update-success', PLATFORM_NAME)
             _echo(
                 f'Successfully updated AWS Lambda deployment {name}',
                 CLI_COLOR_SUCCESS,
             )
             _print_deployment_info(result.deployment, output)
     except BentoMLException as e:
         track_cli('deploy-update-failure', PLATFORM_NAME,
                   {'error_message': str(e)})
         _echo(
             f'Failed to updated AWS Lambda deployment {name}: {str(e)}',
             CLI_COLOR_ERROR,
         )
Esempio n. 15
0
    def update(
        name,
        bento,
        namespace,
        min_size,
        desired_capacity,
        max_size,
        instance_type,
        ami_id,
        output,
        wait,
    ):
        _echo(
            message='AWS EC2 deployment functionalities are being migrated to a '
            'separate tool and related CLI commands will be deprecated in BentoML '
            'itself, please use https://github.com/bentoml/aws-ec2-deploy '
            'going forward.',
            color='yellow',
        )
        yatai_client = get_default_yatai_client()
        if bento:
            bento_name, bento_version = bento.split(":")
        else:
            bento_name = None
            bento_version = None

        with Spinner("Updating EC2 deployment"):
            update_result = yatai_client.deployment.update_ec2_deployment(
                deployment_name=name,
                bento_name=bento_name,
                bento_version=bento_version,
                namespace=namespace,
                min_size=min_size,
                desired_capacity=desired_capacity,
                max_size=max_size,
                instance_type=instance_type,
                ami_id=ami_id,
                wait=wait,
            )
            if update_result.status.status_code != yatai_proto.status_pb2.Status.OK:
                error_code, error_message = status_pb_to_error_code_and_message(
                    update_result.status)
                raise CLIException(f"{error_code}:{error_message}")

        _print_deployment_info(update_result.deployment, output)
        _echo(f"Successfiully updated AWS EC2 deployment '{name}'",
              CLI_COLOR_SUCCESS)
Esempio n. 16
0
 def deploy(
     namespace,
     name,
     bento,
     location,
     min_instances,
     max_burst,
     premium_plan_sku,
     labels,
     function_auth_level,
     output,
     wait,
 ):
     _echo(
         message=
         'Azure Functions deployment functionalities are being migrated to '
         'a separate tool and related CLI commands will be deprecated in BentoML '
         'itself, please use https://github.com/bentoml/azure-functions-deploy '
         'going forward.',
         color='yellow',
     )
     bento_name, bento_version = bento.split(':')
     yatai_client = get_default_yatai_client()
     with Spinner(f'Deploying {bento} to Azure Functions'):
         result = yatai_client.deployment.create_azure_functions_deployment(
             name=name,
             namespace=namespace,
             labels=labels,
             bento_name=bento_name,
             bento_version=bento_version,
             location=location,
             min_instances=min_instances,
             max_burst=max_burst,
             premium_plan_sku=premium_plan_sku,
             function_auth_level=function_auth_level,
             wait=wait,
         )
         if result.status.status_code != yatai_proto.status_pb2.Status.OK:
             error_code, error_message = status_pb_to_error_code_and_message(
                 result.status)
             raise CLIException(f'{error_code}:{error_message}')
         _echo(
             f'Successfully created Azure Functions deployment {name}',
             CLI_COLOR_SUCCESS,
         )
         _print_deployment_info(result.deployment, output)
Esempio n. 17
0
 def deploy(
     name,
     bento,
     namespace,
     labels,
     region,
     instance_type,
     instance_count,
     num_of_gunicorn_workers_per_instance,
     api_name,
     timeout,
     output,
     wait,
     data_capture_s3_prefix,
     data_capture_sample_percent,
 ):
     # use the DeploymentOperator name in proto to be consistent with amplitude
     bento_name, bento_version = bento.split(':')
     yatai_client = get_default_yatai_client()
     with Spinner('Deploying Sagemaker deployment '):
         result = yatai_client.deployment.create_sagemaker_deployment(
             name=name,
             namespace=namespace,
             labels=labels,
             bento_name=bento_name,
             bento_version=bento_version,
             instance_count=instance_count,
             instance_type=instance_type,
             num_of_gunicorn_workers_per_instance=
             num_of_gunicorn_workers_per_instance,  # noqa E501
             api_name=api_name,
             timeout=timeout,
             region=region,
             wait=wait,
             data_capture_s3_prefix=data_capture_s3_prefix,
             data_capture_sample_percent=data_capture_sample_percent,
         )
     if result.status.status_code != yatai_proto.status_pb2.Status.OK:
         error_code, error_message = status_pb_to_error_code_and_message(
             result.status)
         raise CLIException(f'{error_code}:{error_message}')
     _echo(
         f'Successfully created AWS Sagemaker deployment {name}',
         CLI_COLOR_SUCCESS,
     )
     _print_deployment_info(result.deployment, output)
Esempio n. 18
0
 def update(
     name,
     namespace,
     bento,
     api_name,
     instance_type,
     instance_count,
     num_of_gunicorn_workers_per_instance,
     timeout,
     output,
     wait,
     data_capture_s3_prefix,
     data_capture_sample_percent,
 ):
     yatai_client = get_default_yatai_client()
     if bento:
         bento_name, bento_version = bento.split(':')
     else:
         bento_name = None
         bento_version = None
     with Spinner('Updating Sagemaker deployment '):
         result = yatai_client.deployment.update_sagemaker_deployment(
             namespace=namespace,
             deployment_name=name,
             bento_name=bento_name,
             bento_version=bento_version,
             instance_count=instance_count,
             instance_type=instance_type,
             num_of_gunicorn_workers_per_instance=
             num_of_gunicorn_workers_per_instance,  # noqa E501
             timeout=timeout,
             api_name=api_name,
             wait=wait,
             data_capture_s3_prefix=data_capture_s3_prefix,
             data_capture_sample_percent=data_capture_sample_percent,
         )
     if result.status.status_code != yatai_proto.status_pb2.Status.OK:
         error_code, error_message = status_pb_to_error_code_and_message(
             result.status)
         raise CLIException(f'{error_code}:{error_message}')
     _echo(
         f'Successfully updated AWS Sagemaker deployment {name}',
         CLI_COLOR_SUCCESS,
     )
     _print_deployment_info(result.deployment, output)
Esempio n. 19
0
 def deploy(
     name,
     bento,
     namespace,
     region,
     min_size,
     desired_capacity,
     max_size,
     instance_type,
     ami_id,
     output,
     wait,
 ):
     _echo(
         message='AWS EC2 deployment functionalities are being migrated to a '
         'separate tool and related CLI commands will be deprecated in BentoML '
         'itself, please use https://github.com/bentoml/aws-ec2-deploy '
         'going forward.',
         color='yellow',
     )
     yatai_client = get_default_yatai_client()
     bento_name, bento_version = bento.split(":")
     with Spinner(f"Deploying {bento} to AWS EC2"):
         result = yatai_client.deployment.create_ec2_deployment(
             name=name,
             namespace=namespace,
             bento_name=bento_name,
             bento_version=bento_version,
             region=region,
             min_size=min_size,
             desired_capacity=desired_capacity,
             max_size=max_size,
             instance_type=instance_type,
             ami_id=ami_id,
             wait=wait,
         )
     if result.status.status_code != yatai_proto.status_pb2.Status.OK:
         error_code, error_message = status_pb_to_error_code_and_message(
             result.status)
         raise CLIException(f'{error_code}:{error_message}')
     _print_deployment_info(result.deployment, output)
     _echo("Successfully created AWS EC2 deployment", CLI_COLOR_SUCCESS)
Esempio n. 20
0
 def update(
     name, namespace, bento, min_instances, max_burst, premium_plan_sku, output, wait
 ):
     yatai_client = YataiClient()
     track_cli('deploy-update', PLATFORM_NAME)
     if bento:
         bento_name, bento_version = bento.split(':')
     else:
         bento_name = None
         bento_version = None
     try:
         with Spinner(f'Updating Azure Functions deployment {name}'):
             result = yatai_client.deployment.update_azure_functions_deployment(
                 namespace=namespace,
                 deployment_name=name,
                 bento_name=bento_name,
                 bento_version=bento_version,
                 min_instances=min_instances,
                 max_burst=max_burst,
                 premium_plan_sku=premium_plan_sku,
                 wait=wait,
             )
             if result.status.status_code != status_pb2.Status.OK:
                 error_code, error_message = status_pb_to_error_code_and_message(
                     result.status
                 )
                 _echo(
                     f'Failed to update Azure Functions deployment {name}. '
                     f'{error_code}:{error_message}'
                 )
             track_cli('deploy-update-success', PLATFORM_NAME)
             _echo(
                 f'Successfully update Azure Functions deployment {name}',
                 CLI_COLOR_SUCCESS,
             )
             _print_deployment_info(result.deployment, output)
     except BentoMLException as e:
         _echo(
             f'Failed to update Azure Functions deployment {name}: {str(e)}',
             CLI_COLOR_ERROR,
         )
Esempio n. 21
0
    def update(
        name,
        bento,
        namespace,
        min_size,
        desired_capacity,
        max_size,
        instance_type,
        ami_id,
        output,
        wait,
    ):
        yatai_client = get_default_yatai_client()
        if bento:
            bento_name, bento_version = bento.split(":")
        else:
            bento_name = None
            bento_version = None

        with Spinner("Updating EC2 deployment"):
            update_result = yatai_client.deployment.update_ec2_deployment(
                deployment_name=name,
                bento_name=bento_name,
                bento_version=bento_version,
                namespace=namespace,
                min_size=min_size,
                desired_capacity=desired_capacity,
                max_size=max_size,
                instance_type=instance_type,
                ami_id=ami_id,
                wait=wait,
            )
            if update_result.status.status_code != yatai_proto.status_pb2.Status.OK:
                error_code, error_message = status_pb_to_error_code_and_message(
                    update_result.status)
                raise CLIException(f"{error_code}:{error_message}")

        _print_deployment_info(update_result.deployment, output)
        _echo(f"Successfiully updated AWS EC2 deployment '{name}'",
              CLI_COLOR_SUCCESS)
Esempio n. 22
0
 def deploy(
     namespace,
     name,
     bento,
     location,
     min_instances,
     max_burst,
     premium_plan_sku,
     labels,
     function_auth_level,
     output,
     wait,
 ):
     bento_name, bento_version = bento.split(':')
     yatai_client = YataiClient()
     with Spinner(f'Deploying {bento} to Azure Functions'):
         result = yatai_client.deployment.create_azure_functions_deployment(
             name=name,
             namespace=namespace,
             labels=labels,
             bento_name=bento_name,
             bento_version=bento_version,
             location=location,
             min_instances=min_instances,
             max_burst=max_burst,
             premium_plan_sku=premium_plan_sku,
             function_auth_level=function_auth_level,
             wait=wait,
         )
         if result.status.status_code != status_pb2.Status.OK:
             error_code, error_message = status_pb_to_error_code_and_message(
                 result.status
             )
             raise CLIException(f'{error_code}:{error_message}')
         _echo(
             f'Successfully created Azure Functions deployment {name}',
             CLI_COLOR_SUCCESS,
         )
         _print_deployment_info(result.deployment, output)
Esempio n. 23
0
    def get(name, namespace, output):
        _echo(
            message=
            'AWS Lambda deployment functionalities are being migrated to a '
            'separate tool and related CLI commands will be deprecated in BentoML '
            'itself, please use https://github.com/bentoml/aws-lambda-deploy '
            'going forward.',
            color='yellow',
        )
        yatai_client = get_default_yatai_client()
        describe_result = yatai_client.deployment.describe(namespace, name)
        if describe_result.status.status_code != yatai_proto.status_pb2.Status.OK:
            error_code, error_message = status_pb_to_error_code_and_message(
                describe_result.status)
            raise CLIException(f'{error_code}:{error_message}')

        get_result = yatai_client.deployment.get(namespace, name)
        if get_result.status.status_code != yatai_proto.status_pb2.Status.OK:
            error_code, error_message = status_pb_to_error_code_and_message(
                get_result.status)
            raise CLIException(f'{error_code}:{error_message}')
        _print_deployment_info(get_result.deployment, output)