コード例 #1
0
 def deploy(
     name,
     namespace,
     bento,
     labels,
     region,
     api_name,
     memory_size,
     timeout,
     output,
     wait,
 ):
     yatai_client = get_default_yatai_client()
     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 != 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 Lambda deployment {name}',
           CLI_COLOR_SUCCESS)
     _print_deployment_info(result.deployment, output)
コード例 #2
0
def resolve_bundle_path(bento, pip_installed_bundle_path):
    if pip_installed_bundle_path:
        assert (
            bento is None
        ), "pip installed BentoService commands should not have Bento argument"
        return pip_installed_bundle_path

    if os.path.isdir(bento) or is_s3_url(bento) or is_gcs_url(bento):
        # saved_bundle already support loading local, s3 path and gcs path
        return bento

    elif ":" in bento:
        # assuming passing in BentoService in the form of Name:Version tag
        yatai_client = get_default_yatai_client()
        name, version = bento.split(':')
        get_bento_result = yatai_client.repository.get(name, version)
        if get_bento_result.status.status_code != yatai_proto.status_pb2.Status.OK:
            error_code, error_message = status_pb_to_error_code_and_message(
                get_bento_result.status)
            raise BentoMLException(
                f'BentoService {name}:{version} not found - '
                f'{error_code}:{error_message}')
        if get_bento_result.bento.uri.s3_presigned_url:
            # Use s3 presigned URL for downloading the repository if it is presented
            return get_bento_result.bento.uri.s3_presigned_url
        if get_bento_result.bento.uri.gcs_presigned_url:
            return get_bento_result.bento.uri.gcs_presigned_url
        else:
            return get_bento_result.bento.uri.uri
    else:
        raise BentoMLException(
            f'BentoService "{bento}" not found - either specify the file path of '
            f'the BentoService saved bundle, or the BentoService id in the form of '
            f'"name:version"')
コード例 #3
0
 def update(name, namespace, bento, memory_size, timeout, 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 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)
コード例 #4
0
ファイル: bento_management.py プロジェクト: qrithm/BentoML
    def retrieve(bento, target_dir):
        if ':' not in bento:
            _echo(f'BentoService {bento} invalid - specify name:version')
            return
        name, version = bento.split(':')

        yatai_client = get_default_yatai_client()

        get_bento_result = yatai_client.repository.get(name, version)
        if get_bento_result.status.status_code != yatai_proto.status_pb2.Status.OK:
            error_code, error_message = status_pb_to_error_code_and_message(
                get_bento_result.status)
            raise CLIException(
                f'Failed to access BentoService {name}:{version} - '
                f'{error_code}:{error_message}')

        if get_bento_result.bento.uri.s3_presigned_url:
            bento_service_bundle_path = get_bento_result.bento.uri.s3_presigned_url
        if get_bento_result.bento.uri.gcs_presigned_url:
            bento_service_bundle_path = get_bento_result.bento.uri.gcs_presigned_url
        else:
            bento_service_bundle_path = get_bento_result.bento.uri.uri

        safe_retrieve(bento_service_bundle_path, target_dir)

        click.echo('Service %s artifact directory => %s' % (name, target_dir))
コード例 #5
0
ファイル: bento_management.py プロジェクト: qrithm/BentoML
    def get(bento, limit, ascending_order, print_location, output):
        if ':' in bento:
            name, version = bento.split(':')
        else:
            name = bento
            version = None
        yatai_client = get_default_yatai_client()

        if name and version:
            output = output or 'json'
            get_bento_result = yatai_client.repository.get(name, version)
            if get_bento_result.status.status_code != yatai_proto.status_pb2.Status.OK:
                error_code, error_message = status_pb_to_error_code_and_message(
                    get_bento_result.status)
                raise CLIException(f'{error_code}:{error_message}')
            if print_location:
                _echo(get_bento_result.bento.uri.uri)
                return
            _print_bento_info(get_bento_result.bento, output)
        elif name:
            output = output or 'table'
            list_bento_versions_result = yatai_client.repository.list(
                bento_name=name, limit=limit, ascending_order=ascending_order)
            if (list_bento_versions_result.status.status_code !=
                    yatai_proto.status_pb2.Status.OK):
                error_code, error_message = status_pb_to_error_code_and_message(
                    list_bento_versions_result.status)
                raise CLIException(f'{error_code}:{error_message}')

            _print_bentos_info(list_bento_versions_result.bentos, output)
コード例 #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)
コード例 #7
0
ファイル: bento_management.py プロジェクト: qrithm/BentoML
    def delete(bentos, yes):
        """Delete saved BentoService.

        BENTO is the target BentoService to be deleted, referenced by its name and
        version in format of name:version. For example: "iris_classifier:v1.2.0"

        `bentoml delete` command also supports deleting multiple saved BentoService at
        once, by providing name version tag separated by ",", for example:

        `bentoml delete iris_classifier:v1.2.0,my_svc:v1,my_svc2:v3`
        """
        yatai_client = get_default_yatai_client()
        for bento in bentos:
            name, version = bento.split(':')
            if not name and not version:
                raise CLIException(
                    'BentoService name or version is missing. Please provide in the '
                    'format of name:version')
            if not yes and not click.confirm(
                    f'Are you sure about delete {bento}? This will delete the BentoService '
                    f'saved bundle files permanently'):
                return
            result = yatai_client.repository.dangerously_delete_bento(
                name=name, version=version)
            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'BentoService {name}:{version} deleted')
コード例 #8
0
 def create(deployment_yaml, output, wait):
     yatai_client = get_default_yatai_client()
     deployment_name = deployment_yaml.get('name')
     with Spinner('Creating deployment '):
         result = yatai_client.deployment.create(deployment_yaml, 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 deployment {deployment_name}',
         CLI_COLOR_SUCCESS,
     )
     _print_deployment_info(result.deployment, output)
コード例 #9
0
 def delete(name, namespace, force):
     yatai_client = get_default_yatai_client()
     get_deployment_result = yatai_client.deployment.get(namespace, name)
     if get_deployment_result.status.status_code != yatai_proto.status_pb2.Status.OK:
         error_code, error_message = status_pb_to_error_code_and_message(
             get_deployment_result.status)
         raise CLIException(f'{error_code}:{error_message}')
     result = yatai_client.deployment.delete(name, namespace, force)
     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('Successfully deleted deployment "{}"'.format(name),
           CLI_COLOR_SUCCESS)
コード例 #10
0
    def get(name, namespace, output):
        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)
コード例 #11
0
ファイル: bento_management.py プロジェクト: qrithm/BentoML
    def list_bentos(limit, offset, order_by, ascending_order, output):
        yatai_client = get_default_yatai_client()
        list_bentos_result = yatai_client.repository.list(
            limit=limit,
            offset=offset,
            order_by=order_by,
            ascending_order=ascending_order,
        )
        if list_bentos_result.status.status_code != yatai_proto.status_pb2.Status.OK:
            error_code, error_message = status_pb_to_error_code_and_message(
                list_bentos_result.status)
            raise CLIException(f'{error_code}:{error_message}')

        _print_bentos_info(list_bentos_result.bentos, output)
コード例 #12
0
 def list_deployment(namespace, limit, labels, order_by, asc, output):
     yatai_client = get_default_yatai_client()
     list_result = yatai_client.deployment.list_azure_functions_deployments(
         limit=limit,
         labels_query=labels,
         namespace=namespace,
         order_by=order_by,
         ascending_order=asc,
     )
     if list_result.status.status_code != yatai_proto.status_pb2.Status.OK:
         error_code, error_message = status_pb_to_error_code_and_message(
             list_result.status)
         raise CLIException(f'{error_code}:{error_message}')
     _print_deployments_info(list_result.deployments, output)
コード例 #13
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)
コード例 #14
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)
コード例 #15
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 = 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)