def delete(self, bento): """ Delete bento Args: bento: a BentoService identifier in the format of NAME:VERSION Example: >>> >>> yatai_client = get_yatai_client() >>> yatai_client.repository.delete('my_service:version') """ track('py-api-delete') if ':' not in bento: raise BentoMLException( 'BentoService name or version is missing. Please provide in the ' 'format of name:version' ) name, version = bento.split(':') result = self.yatai_service.DangerouslyDeleteBento( DangerouslyDeleteBentoRequest(bento_name=name, bento_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 BentoMLException( f'Failed to delete Bento {bento} {error_code}:{error_message}' )
def dangerously_delete_bento(self, name, version): dangerously_delete_bento_request = DangerouslyDeleteBentoRequest( bento_name=name, bento_version=version ) return self.yatai_service.DangerouslyDeleteBento( dangerously_delete_bento_request )
def delete(self, bento): track('py-api-delete') if ':' not in bento: raise BentoMLException( 'BentoService name or version is missing. Please provide in the ' 'format of name:version') name, version = bento.split(':') result = self.yatai_service.DangerouslyDeleteBento( DangerouslyDeleteBentoRequest(bento_name=name, bento_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 BentoMLException( f'Failed to delete Bento {bento} {error_code}:{error_message}')
def _delete_bento_bundle(self, bento_tag, require_confirm): bento_pb = self.get(bento_tag) if require_confirm and not click.confirm( f'Permanently delete {bento_tag}?'): return result = self.yatai_service.DangerouslyDeleteBento( DangerouslyDeleteBentoRequest(bento_name=bento_pb.name, bento_version=bento_pb.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) # Rather than raise Exception, continue to delete the next bentos logger.error( f'Failed to delete {bento_pb.name}:{bento_pb.version} - ' f'{error_code}:{error_message}') else: logger.info(f'Deleted {bento_pb.name}:{bento_pb.version}')