Exemplo n.º 1
0
    def _Run(self, args, version):
        index_ref = args.CONCEPTS.index.Parse()
        region = index_ref.AsDict()['locationsId']
        with endpoint_util.AiplatformEndpointOverrides(version, region=region):
            operation = client.IndexesClient().PatchBeta(index_ref, args)
            if args.metadata_file is not None:
                # Update index content.
                op_ref = indexes_util.ParseIndexOperation(operation.name)
                log.status.Print(
                    constants.OPERATION_CREATION_DISPLAY_MESSAGE.format(
                        name=operation.name,
                        verb='update index',
                        id=op_ref.Name(),
                        sub_commands='--index={}'.format(index_ref.Name())))
                # We will not wait for the operation since it can take up to hours.
                return operation

            # Update index meta data.
            response_msg = operations_util.WaitForOpMaybe(
                operations_client=operations.OperationsClient(),
                op=operation,
                op_ref=indexes_util.ParseIndexOperation(operation.name),
                log_method='update')
            if response_msg is not None:
                response = encoding.MessageToPyValue(response_msg)
                if 'name' in response:
                    log.UpdatedResource(response['name'],
                                        kind='AI Platform index')
            return response_msg
Exemplo n.º 2
0
 def _Run(self, args, version):
     index_ref = args.CONCEPTS.index.Parse()
     region = index_ref.AsDict()['locationsId']
     index_id = index_ref.AsDict()['indexesId']
     with endpoint_util.AiplatformEndpointOverrides(version, region=region):
         console_io.PromptContinue(
             'This will delete index [{}]...'.format(index_id),
             cancel_on_no=True)
         operation = client.IndexesClient().Delete(index_ref)
         return operations_util.WaitForOpMaybe(
             operations_client=operations.OperationsClient(),
             op=operation,
             op_ref=indexes_util.ParseIndexOperation(operation.name))
Exemplo n.º 3
0
 def _Run(self, args, version):
     validation.ValidateDisplayName(args.display_name)
     region_ref = args.CONCEPTS.region.Parse()
     region = region_ref.AsDict()['locationsId']
     with endpoint_util.AiplatformEndpointOverrides(version, region=region):
         operation = client.IndexesClient().CreateBeta(region_ref, args)
         op_ref = indexes_util.ParseIndexOperation(operation.name)
         index_id = op_ref.AsDict()['indexesId']
         log.status.Print(
             constants.OPERATION_CREATION_DISPLAY_MESSAGE.format(
                 name=operation.name,
                 verb='create index',
                 id=op_ref.Name(),
                 sub_commands='--index={}'.format(index_id)))
         return operation
 def _Run(self, args, version):
     index_ref = args.CONCEPTS.index.Parse()
     region = index_ref.AsDict()['locationsId']
     with endpoint_util.AiplatformEndpointOverrides(version, region=region):
         return client.IndexesClient(version=version).Get(index_ref)