Ejemplo n.º 1
0
def list_deployments(
    limit=None,
    filters=None,
    labels=None,
    namespace=None,
    is_all_namespaces=False,
    yatai_service=None,
):
    if yatai_service is None:
        from bentoml.yatai import get_yatai_service

        yatai_service = get_yatai_service()

    if is_all_namespaces:
        if namespace is not None:
            logger.warning(
                'Ignoring `namespace=%s` due to the --all-namespace flag presented',
                namespace,
            )
        namespace = ALL_NAMESPACE_TAG

    return yatai_service.ListDeployments(
        ListDeploymentsRequest(limit=limit,
                               filter=filters,
                               labels=labels,
                               namespace=namespace))
Ejemplo n.º 2
0
    def list_deployments(output, limit, filters, labels, namespace,
                         all_namespaces):
        track_cli('deploy-list')

        if all_namespaces:
            if namespace is not None:
                logger.warning(
                    'Ignoring `namespace=%s` due to the --all-namespace flag presented',
                    namespace,
                )
            namespace = ALL_NAMESPACE_TAG

        result = get_yatai_service().ListDeployments(
            ListDeploymentsRequest(
                limit=limit,
                filter=filters,
                labels=parse_key_value_pairs(labels),
                namespace=namespace,
            ))
        if result.status.status_code != Status.OK:
            _echo(
                'Failed to list deployments. code: {error_code}, message: '
                '{error_message}'.format(
                    error_code=Status.Code.Name(result.status.status_code),
                    error_message=result.status.error_message,
                ),
                CLI_COLOR_ERROR,
            )
        else:
            for deployment_pb in result.deployments:
                display_deployment_info(deployment_pb, output)
Ejemplo n.º 3
0
 def list(output, limit=None, filter=None, labels=None):
     track_cli('deploy-list')
     result = get_yatai_service().ListDeployments(
         ListDeploymentsRequest(limit=limit,
                                filter=filter,
                                labels=parse_key_value_pairs(labels)))
     if result.status.status_code != Status.OK:
         _echo(
             'Failed to list deployments. code: {error_code}, message: {error_message}'
             .format(
                 error_code=Status.Code.Name(result.status.status_code),
                 error_message=result.status.error_message,
             ),
             CLI_COLOR_ERROR,
         )
     else:
         for deployment_pb in result.deployments:
             display_deployment_info(deployment_pb, output)
Ejemplo n.º 4
0
    def list(
        self,
        limit=None,
        filters=None,
        labels=None,
        namespace=None,
        is_all_namespaces=False,
    ):
        if is_all_namespaces:
            if namespace is not None:
                logger.warning(
                    'Ignoring `namespace=%s` due to the --all-namespace flag presented',
                    namespace,
                )
            namespace = ALL_NAMESPACE_TAG

        return self.yatai_service.ListDeployments(
            ListDeploymentsRequest(limit=limit,
                                   filter=filters,
                                   labels=labels,
                                   namespace=namespace))
Ejemplo n.º 5
0
    def list(
        self,
        limit=None,
        offset=None,
        labels_query=None,
        namespace=None,
        is_all_namespaces=False,
        operator=None,
        order_by=None,
        ascending_order=None,
    ):
        if is_all_namespaces:
            if namespace is not None:
                logger.warning(
                    'Ignoring `namespace=%s` due to the --all-namespace flag presented',
                    namespace,
                )
            namespace = ALL_NAMESPACE_TAG
        if isinstance(operator, str):
            if operator == 'sagemaker':
                operator = DeploymentSpec.AWS_SAGEMAKER
            elif operator == 'lambda':
                operator = DeploymentSpec.AWS_LAMBDA
            else:
                raise BentoMLException(f'Unrecognized operator {operator}')

        return self.yatai_service.ListDeployments(
            ListDeploymentsRequest(
                limit=limit,
                offset=offset,
                labels_query=labels_query,
                namespace=namespace,
                operator=operator,
                order_by=order_by,
                ascending_order=ascending_order,
            )
        )