Funktionen verwalten und finden

Hier erfahren Sie, wie Sie Features verwalten und finden.

Feature erstellen

Erstellen Sie ein einzelnes Feature für einen vorhandenen Entitätstyp. Informationen zum Erstellen mehrerer Features in einer einzigen Anfrage finden Sie unter Features der Batcherstellung.

Web-UI

  1. Rufen Sie im Bereich "Vertex AI" der Google Cloud Console die Seite Features auf.

    Zur Seite „Features“

  2. Wählen Sie eine Region aus der Drop-down-Liste Region aus.
  3. Rufen Sie in der Tabelle „Features“ die Spalte Entitätstyp auf und klicken Sie auf den Entitätstyp, dem Sie Features hinzufügen möchten.
  4. Klicken Sie auf Features hinzufügen, um den Bereich Features hinzufügen zu öffnen.
  5. Geben Sie einen Namen, einen Werttyp und optional eine Beschreibung für das Feature an.
  6. Wählen Sie zum Aktivieren des Feature-Monitoring (Vorschau) unter Feature-Monitoring die Option Monitoring-Konfiguration für Entitätstyp überschreiben aus und geben Sie die Anzahl der Tage zwischen Snapshots an. Diese Konfiguration überschreibt alle vorhandenen oder zukünftigen Monitoringkonfigurationen für den Entitätstyp des Features. Weitere Informationen finden Sie unter Featurewert-Monitoring.
  7. Wenn Sie weitere Features hinzufügen möchten, klicken Sie auf Weiteres Feature hinzufügen.
  8. Klicken Sie auf Speichern.

REST

Wenn Sie ein Feature für einen vorhandenen Entitätstyp erstellen möchten, senden Sie eine POST-Anfrage mit der Methode featurestores.entityTypes.features.create.

Ersetzen Sie diese Werte in den folgenden Anfragedaten:

  • LOCATION_ID: Die Region, in der sich der Featurestore befindet, z. B. us-central1.
  • PROJECT_ID: Ihre Projekt-ID.
  • FEATURESTORE_ID: ID des Featurestores.
  • ENTITY_TYPE_ID: ID des Entitätstyps.
  • FEATURE_ID: Eine ID für das Feature.
  • DESCRIPTION: Beschreibung der Funktion.
  • VALUE_TYPE: Der Werttyp des Features.

HTTP-Methode und URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID?featureId=FEATURE_ID

JSON-Text der Anfrage:

{
  "description": "DESCRIPTION",
  "valueType": "VALUE_TYPE"
}

Wenn Sie die Anfrage senden möchten, wählen Sie eine der folgenden Optionen aus:

curl

Speichern Sie den Anfragetext in einer Datei mit dem Namen request.json und führen Sie den folgenden Befehl aus:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID?featureId=FEATURE_ID"

PowerShell

Speichern Sie den Anfragetext in einer Datei mit dem Namen request.json und führen Sie folgenden Befehl aus:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID?featureId=FEATURE_ID" | Select-Object -Expand Content

Die Ausgabe sieht in etwa so aus: Sie können OPERATION_ID in der Antwort verwenden, um den Status des Vorgangs abzurufen.

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.CreateFeatureOperationMetadata",
    "genericMetadata": {
      "createTime": "2021-03-02T00:04:13.039166Z",
      "updateTime": "2021-03-02T00:04:13.039166Z"
    }
  }
}

Python

Informationen zum Installieren oder Aktualisieren von Python finden Sie unter Vertex AI SDK für Python installieren. Weitere Informationen finden Sie in der Referenzdokumentation zur Python API.

from google.cloud import aiplatform

def create_feature_sample(
    project: str,
    location: str,
    feature_id: str,
    value_type: str,
    entity_type_id: str,
    featurestore_id: str,
):

    aiplatform.init(project=project, location=location)

    my_feature = aiplatform.Feature.create(
        feature_id=feature_id,
        value_type=value_type,
        entity_type_name=entity_type_id,
        featurestore_id=featurestore_id,
    )

    my_feature.wait()

    return my_feature

Python

Die Clientbibliothek für Vertex AI ist bei der Installation des Vertex AI SDK für Python enthalten. Informationen zur Installation des Vertex AI SDK für Python finden Sie unter Vertex AI SDK für Python installieren. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI SDK for Python API.

from google.cloud import aiplatform

def create_feature_sample(
    project: str,
    featurestore_id: str,
    entity_type_id: str,
    feature_id: str,
    value_type: aiplatform.gapic.Feature.ValueType,
    description: str = "sample feature",
    location: str = "us-central1",
    api_endpoint: str = "us-central1-aiplatform.googleapis.com",
    timeout: int = 300,
):
    # The AI Platform services require regional API endpoints, which need to be
    # in the same region or multi-region overlap with the Feature Store location.
    client_options = {"api_endpoint": api_endpoint}
    # Initialize client that will be used to create and send requests.
    # This client only needs to be created once, and can be reused for multiple requests.
    client = aiplatform.gapic.FeaturestoreServiceClient(client_options=client_options)
    parent = f"projects/{project}/locations/{location}/featurestores/{featurestore_id}/entityTypes/{entity_type_id}"
    create_feature_request = aiplatform.gapic.CreateFeatureRequest(
        parent=parent,
        feature=aiplatform.gapic.Feature(
            value_type=value_type, description=description
        ),
        feature_id=feature_id,
    )
    lro_response = client.create_feature(request=create_feature_request)
    print("Long running operation:", lro_response.operation.name)
    create_feature_response = lro_response.result(timeout=timeout)
    print("create_feature_response:", create_feature_response)

Java

Bevor Sie dieses Beispiel anwenden, folgen Sie den Java-Einrichtungsschritten in der Vertex AI-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI Java API.

Richten Sie zur Authentifizierung bei Vertex AI Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1.CreateFeatureOperationMetadata;
import com.google.cloud.aiplatform.v1.CreateFeatureRequest;
import com.google.cloud.aiplatform.v1.EntityTypeName;
import com.google.cloud.aiplatform.v1.Feature;
import com.google.cloud.aiplatform.v1.Feature.ValueType;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class CreateFeatureSample {

  public static void main(String[] args)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String featurestoreId = "YOUR_FEATURESTORE_ID";
    String entityTypeId = "YOUR_ENTITY_TYPE_ID";
    String featureId = "YOUR_FEATURE_ID";
    String description = "YOUR_FEATURE_DESCRIPTION";
    ValueType valueType = ValueType.STRING;
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";
    int timeout = 900;
    createFeatureSample(
        project,
        featurestoreId,
        entityTypeId,
        featureId,
        description,
        valueType,
        location,
        endpoint,
        timeout);
  }

  static void createFeatureSample(
      String project,
      String featurestoreId,
      String entityTypeId,
      String featureId,
      String description,
      ValueType valueType,
      String location,
      String endpoint,
      int timeout)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {

    FeaturestoreServiceSettings featurestoreServiceSettings =
        FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (FeaturestoreServiceClient featurestoreServiceClient =
        FeaturestoreServiceClient.create(featurestoreServiceSettings)) {

      Feature feature =
          Feature.newBuilder().setDescription(description).setValueType(valueType).build();

      CreateFeatureRequest createFeatureRequest =
          CreateFeatureRequest.newBuilder()
              .setParent(
                  EntityTypeName.of(project, location, featurestoreId, entityTypeId).toString())
              .setFeature(feature)
              .setFeatureId(featureId)
              .build();

      OperationFuture<Feature, CreateFeatureOperationMetadata> featureFuture =
          featurestoreServiceClient.createFeatureAsync(createFeatureRequest);
      System.out.format("Operation name: %s%n", featureFuture.getInitialFuture().get().getName());
      System.out.println("Waiting for operation to finish...");
      Feature featureResponse = featureFuture.get(timeout, TimeUnit.SECONDS);
      System.out.println("Create Feature Response");
      System.out.format("Name: %s%n", featureResponse.getName());
      featurestoreServiceClient.close();
    }
  }
}

Node.js

Bevor Sie dieses Beispiel anwenden, folgen Sie den Node.js-Einrichtungsschritten in der Vertex AI-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI Node.js API.

Richten Sie zur Authentifizierung bei Vertex AI Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */

// const project = 'YOUR_PROJECT_ID';
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
// const entityTypeId = 'YOUR_ENTITY_TYPE_ID';
// const featureId = 'YOUR_FEATURE_ID';
// const valueType = 'FEATURE_VALUE_DATA_TYPE';
// const description = 'YOUR_ENTITY_TYPE_DESCRIPTION';
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// Imports the Google Cloud Featurestore Service Client library
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: apiEndpoint,
};

// Instantiates a client
const featurestoreServiceClient = new FeaturestoreServiceClient(
  clientOptions
);

async function createFeature() {
  // Configure the parent resource
  const parent = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}`;

  const feature = {
    valueType: valueType,
    description: description,
  };

  const request = {
    parent: parent,
    feature: feature,
    featureId: featureId,
  };

  // Create Feature request
  const [operation] = await featurestoreServiceClient.createFeature(request, {
    timeout: Number(timeout),
  });
  const [response] = await operation.promise();

  console.log('Create feature response');
  console.log(`Name : ${response.name}`);
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
createFeature();

Features im Batch erstellen

Mehrere Funktionen für einen vorhandenen Typ erstellen Bei Anfragen für Batcherstellungen erstellt der Vertex AI Feature Store (Legacy) mehrere Features gleichzeitig, was für das Erstellen einer großen Anzahl von Features im Vergleich zur Methode featurestores.entityTypes.features.create schneller ist.

Web-UI

Siehe Feature erstellen.

REST

Senden Sie mit der Methode featurestores.entityTypes.features.batchCreate eine POST-Anfrage, um ein oder mehrere Features für einen vorhandenen Entitätstyp zu erstellen. Dies wird im folgenden Beispiel gezeigt:

Ersetzen Sie diese Werte in den folgenden Anfragedaten:

  • LOCATION_ID: Die Region, in der sich der Featurestore befindet, z. B. us-central1.
  • PROJECT_ID: Ihre Projekt-ID.
  • FEATURESTORE_ID: ID des Featurestores.
  • ENTITY_TYPE_ID: ID des Entitätstyps.
  • PARENT: Der Ressourcenname des Entitätstyps, unter dem die Features erstellt werden. Erforderliches Format:
    projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID
  • FEATURE_ID: Eine ID für das Feature.
  • DESCRIPTION: Beschreibung der Funktion.
  • VALUE_TYPE: Der Werttyp des Features.
  • DURATION: (Optional) Die Intervalldauer zwischen den Snapshots in Sekunden. Der Wert muss mit einem „s“ enden.

HTTP-Methode und URL:

POST https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features:batchCreate

JSON-Text der Anfrage:

{
  "requests": [
    {
      "parent" : "PARENT_1",
      "feature": {
        "description": "DESCRIPTION_1",
        "valueType": "VALUE_TYPE_1",
        "monitoringConfig": {
          "snapshotAnalysis": {
            "monitoringInterval": "DURATION"
          }
        }
      },
      "featureId": "FEATURE_ID_1"
    },
    {
      "parent" : "PARENT_2",
      "feature": {
        "description": "DESCRIPTION_2",
        "valueType": "VALUE_TYPE_2",
        "monitoringConfig": {
          "snapshotAnalysis": {
            "monitoringInterval": "DURATION"
          }
        }
      },
      "featureId": "FEATURE_ID_2"
    }
  ]
}

Wenn Sie die Anfrage senden möchten, wählen Sie eine der folgenden Optionen aus:

curl

Speichern Sie den Anfragetext in einer Datei mit dem Namen request.json und führen Sie den folgenden Befehl aus:

curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features:batchCreate"

PowerShell

Speichern Sie den Anfragetext in einer Datei mit dem Namen request.json und führen Sie folgenden Befehl aus:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features:batchCreate" | Select-Object -Expand Content

Die Ausgabe sieht in etwa so aus: Sie können OPERATION_ID in der Antwort verwenden, um den Status des Vorgangs abzurufen.

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.BatchCreateFeaturesOperationMetadata",
    "genericMetadata": {
      "createTime": "2021-03-02T00:04:13.039166Z",
      "updateTime": "2021-03-02T00:04:13.039166Z"
    }
  }
}

Python

Informationen zum Installieren oder Aktualisieren von Python finden Sie unter Vertex AI SDK für Python installieren. Weitere Informationen finden Sie in der Referenzdokumentation zur Python API.

from google.cloud import aiplatform

def batch_create_features_sample(
    project: str,
    location: str,
    entity_type_id: str,
    featurestore_id: str,
    sync: bool = True,
):

    aiplatform.init(project=project, location=location)

    my_entity_type = aiplatform.featurestore.EntityType(
        entity_type_name=entity_type_id, featurestore_id=featurestore_id
    )

    FEATURE_CONFIGS = {
        "age": {"value_type": "INT64", "description": "User age"},
        "gender": {"value_type": "STRING", "description": "User gender"},
        "liked_genres": {
            "value_type": "STRING_ARRAY",
            "description": "An array of genres this user liked",
        },
    }

    my_entity_type.batch_create_features(feature_configs=FEATURE_CONFIGS, sync=sync)

Python

Die Clientbibliothek für Vertex AI ist bei der Installation des Vertex AI SDK für Python enthalten. Informationen zur Installation des Vertex AI SDK für Python finden Sie unter Vertex AI SDK für Python installieren. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI SDK for Python API.

from google.cloud import aiplatform

def batch_create_features_sample(
    project: str,
    featurestore_id: str,
    entity_type_id: str,
    location: str = "us-central1",
    api_endpoint: str = "us-central1-aiplatform.googleapis.com",
    timeout: int = 300,
):
    # The AI Platform services require regional API endpoints, which need to be
    # in the same region or multi-region overlap with the Feature Store location.
    client_options = {"api_endpoint": api_endpoint}
    # Initialize client that will be used to create and send requests.
    # This client only needs to be created once, and can be reused for multiple requests.
    client = aiplatform.gapic.FeaturestoreServiceClient(client_options=client_options)
    parent = f"projects/{project}/locations/{location}/featurestores/{featurestore_id}/entityTypes/{entity_type_id}"
    age_feature = aiplatform.gapic.Feature(
        value_type=aiplatform.gapic.Feature.ValueType.INT64, description="User age",
    )
    age_feature_request = aiplatform.gapic.CreateFeatureRequest(
        feature=age_feature, feature_id="age"
    )

    gender_feature = aiplatform.gapic.Feature(
        value_type=aiplatform.gapic.Feature.ValueType.STRING, description="User gender"
    )
    gender_feature_request = aiplatform.gapic.CreateFeatureRequest(
        feature=gender_feature, feature_id="gender"
    )

    liked_genres_feature = aiplatform.gapic.Feature(
        value_type=aiplatform.gapic.Feature.ValueType.STRING_ARRAY,
        description="An array of genres that this user liked",
    )
    liked_genres_feature_request = aiplatform.gapic.CreateFeatureRequest(
        feature=liked_genres_feature, feature_id="liked_genres"
    )

    requests = [
        age_feature_request,
        gender_feature_request,
        liked_genres_feature_request,
    ]
    batch_create_features_request = aiplatform.gapic.BatchCreateFeaturesRequest(
        parent=parent, requests=requests
    )
    lro_response = client.batch_create_features(request=batch_create_features_request)
    print("Long running operation:", lro_response.operation.name)
    batch_create_features_response = lro_response.result(timeout=timeout)
    print("batch_create_features_response:", batch_create_features_response)

Java

Bevor Sie dieses Beispiel anwenden, folgen Sie den Java-Einrichtungsschritten in der Vertex AI-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI Java API.

Richten Sie zur Authentifizierung bei Vertex AI Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1.BatchCreateFeaturesOperationMetadata;
import com.google.cloud.aiplatform.v1.BatchCreateFeaturesRequest;
import com.google.cloud.aiplatform.v1.BatchCreateFeaturesResponse;
import com.google.cloud.aiplatform.v1.CreateFeatureRequest;
import com.google.cloud.aiplatform.v1.EntityTypeName;
import com.google.cloud.aiplatform.v1.Feature;
import com.google.cloud.aiplatform.v1.Feature.ValueType;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class BatchCreateFeaturesSample {

  public static void main(String[] args)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String featurestoreId = "YOUR_FEATURESTORE_ID";
    String entityTypeId = "YOUR_ENTITY_TYPE_ID";
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";
    int timeout = 300;
    batchCreateFeaturesSample(project, featurestoreId, entityTypeId, location, endpoint, timeout);
  }

  static void batchCreateFeaturesSample(
      String project,
      String featurestoreId,
      String entityTypeId,
      String location,
      String endpoint,
      int timeout)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    FeaturestoreServiceSettings featurestoreServiceSettings =
        FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (FeaturestoreServiceClient featurestoreServiceClient =
        FeaturestoreServiceClient.create(featurestoreServiceSettings)) {

      List<CreateFeatureRequest> createFeatureRequests = new ArrayList<>();

      Feature titleFeature =
          Feature.newBuilder()
              .setDescription("The title of the movie")
              .setValueType(ValueType.STRING)
              .build();
      Feature genresFeature =
          Feature.newBuilder()
              .setDescription("The genres of the movie")
              .setValueType(ValueType.STRING)
              .build();
      Feature averageRatingFeature =
          Feature.newBuilder()
              .setDescription("The average rating for the movie, range is [1.0-5.0]")
              .setValueType(ValueType.DOUBLE)
              .build();

      createFeatureRequests.add(
          CreateFeatureRequest.newBuilder().setFeature(titleFeature).setFeatureId("title").build());

      createFeatureRequests.add(
          CreateFeatureRequest.newBuilder()
              .setFeature(genresFeature)
              .setFeatureId("genres")
              .build());

      createFeatureRequests.add(
          CreateFeatureRequest.newBuilder()
              .setFeature(averageRatingFeature)
              .setFeatureId("average_rating")
              .build());

      BatchCreateFeaturesRequest batchCreateFeaturesRequest =
          BatchCreateFeaturesRequest.newBuilder()
              .setParent(
                  EntityTypeName.of(project, location, featurestoreId, entityTypeId).toString())
              .addAllRequests(createFeatureRequests)
              .build();

      OperationFuture<BatchCreateFeaturesResponse, BatchCreateFeaturesOperationMetadata>
          batchCreateFeaturesFuture =
              featurestoreServiceClient.batchCreateFeaturesAsync(batchCreateFeaturesRequest);
      System.out.format(
          "Operation name: %s%n", batchCreateFeaturesFuture.getInitialFuture().get().getName());
      System.out.println("Waiting for operation to finish...");
      BatchCreateFeaturesResponse batchCreateFeaturesResponse =
          batchCreateFeaturesFuture.get(timeout, TimeUnit.SECONDS);
      System.out.println("Batch Create Features Response");
      System.out.println(batchCreateFeaturesResponse);
      featurestoreServiceClient.close();
    }
  }
}

Node.js

Bevor Sie dieses Beispiel anwenden, folgen Sie den Node.js-Einrichtungsschritten in der Vertex AI-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI Node.js API.

Richten Sie zur Authentifizierung bei Vertex AI Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */

// const project = 'YOUR_PROJECT_ID';
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
// const entityTypeId = 'YOUR_ENTITY_TYPE_ID';
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// Imports the Google Cloud Featurestore Service Client library
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: apiEndpoint,
};

// Instantiates a client
const featurestoreServiceClient = new FeaturestoreServiceClient(
  clientOptions
);

async function batchCreateFeatures() {
  // Configure the parent resource
  const parent = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}`;

  const ageFeature = {
    valueType: 'INT64',
    description: 'User age',
  };

  const ageFeatureRequest = {
    feature: ageFeature,
    featureId: 'age',
  };

  const genderFeature = {
    valueType: 'STRING',
    description: 'User gender',
  };

  const genderFeatureRequest = {
    feature: genderFeature,
    featureId: 'gender',
  };

  const likedGenresFeature = {
    valueType: 'STRING_ARRAY',
    description: 'An array of genres that this user liked',
  };

  const likedGenresFeatureRequest = {
    feature: likedGenresFeature,
    featureId: 'liked_genres',
  };

  const requests = [
    ageFeatureRequest,
    genderFeatureRequest,
    likedGenresFeatureRequest,
  ];

  const request = {
    parent: parent,
    requests: requests,
  };

  // Batch Create Features request
  const [operation] = await featurestoreServiceClient.batchCreateFeatures(
    request,
    {timeout: Number(timeout)}
  );
  const [response] = await operation.promise();

  console.log('Batch create features response');
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
batchCreateFeatures();

Features auflisten

Listen Sie alle Features in einem bestimmten Speicherort auf. Informationen zum Suchen nach Features für alle Entitätstypen und Feature Stores in einem bestimmten Speicherort finden Sie unter der Methode Nach Features suchen.

Web-UI

  1. Rufen Sie im Bereich "Vertex AI" der Google Cloud Console die Seite Features auf.

    Zur Seite „Features“

  2. Wählen Sie eine Region aus der Drop-down-Liste Region aus.
  3. In der Tabelle Features sehen Sie in der Spalte Features die Features in Ihrem Projekt für die ausgewählte Region.

REST

Zum Auflisten aller Features für einen einzelnen Entitätstyp senden Sie eine GET-Anfrage mit der Methode featurestores.entityTypes.features.list.

Ersetzen Sie diese Werte in den folgenden Anfragedaten:

  • LOCATION_ID: Die Region, in der sich der Featurestore befindet, z. B. us-central1.
  • PROJECT_ID: Ihre Projekt-ID.
  • FEATURESTORE_ID: ID des Featurestores.
  • ENTITY_TYPE_ID: ID des Entitätstyps.

HTTP-Methode und URL:

GET https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features

Senden Sie die Anfrage mithilfe einer der folgenden Optionen:

curl

Führen Sie folgenden Befehl aus:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features"

PowerShell

Führen Sie folgenden Befehl aus:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features" | Select-Object -Expand Content

Sie sollten in etwa folgende JSON-Antwort erhalten:

{
  "features": [
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID_1",
      "description": "DESCRIPTION",
      "valueType": "VALUE_TYPE",
      "createTime": "2021-03-01T22:41:20.626644Z",
      "updateTime": "2021-03-01T22:41:20.626644Z",
      "labels": {
        "environment": "testing"
      },
      "etag": "AMEw9yP0qJeLao6P3fl9cKEGY4ie5-SanQaiN7c_Ca4QOa0u7AxwO6i75Vbp0Cr51MSf"
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID_2",
      "description": "DESCRIPTION",
      "valueType": "VALUE_TYPE",
      "createTime": "2021-02-25T01:27:00.544230Z",
      "updateTime": "2021-02-25T01:27:00.544230Z",
      "labels": {
        "environment": "testing"
      },
      "etag": "AMEw9yMdrLZ7Waty0ane-DkHq4kcsIVC-piqJq7n6A_Y-BjNzPY4rNlokDHNyUqC7edw"
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID_3",
      "description": "DESCRIPTION",
      "valueType": "VALUE_TYPE",
      "createTime": "2021-03-01T22:41:20.628493Z",
      "updateTime": "2021-03-01T22:41:20.628493Z",
      "labels": {
        "environment": "testing"
      },
      "etag": "AMEw9yM-sAkv-u-jzkUOToaAVovK7GKbrubd9DbmAonik-ojTWG8-hfSRYt6jHKRTQ35"
    }
  ]
}

Java

Bevor Sie dieses Beispiel anwenden, folgen Sie den Java-Einrichtungsschritten in der Vertex AI-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI Java API.

Richten Sie zur Authentifizierung bei Vertex AI Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.


import com.google.cloud.aiplatform.v1.EntityTypeName;
import com.google.cloud.aiplatform.v1.Feature;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import com.google.cloud.aiplatform.v1.ListFeaturesRequest;
import java.io.IOException;

public class ListFeaturesSample {

  public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String featurestoreId = "YOUR_FEATURESTORE_ID";
    String entityTypeId = "YOUR_ENTITY_TYPE_ID";
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";

    listFeaturesSample(project, featurestoreId, entityTypeId, location, endpoint);
  }

  static void listFeaturesSample(
      String project, String featurestoreId, String entityTypeId, String location, String endpoint)
      throws IOException {
    FeaturestoreServiceSettings featurestoreServiceSettings =
        FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (FeaturestoreServiceClient featurestoreServiceClient =
        FeaturestoreServiceClient.create(featurestoreServiceSettings)) {

      ListFeaturesRequest listFeaturesRequest =
          ListFeaturesRequest.newBuilder()
              .setParent(
                  EntityTypeName.of(project, location, featurestoreId, entityTypeId).toString())
              .build();
      System.out.println("List Features Response");
      for (Feature element :
          featurestoreServiceClient.listFeatures(listFeaturesRequest).iterateAll()) {
        System.out.println(element);
      }
      featurestoreServiceClient.close();
    }
  }
}

Node.js

Bevor Sie dieses Beispiel anwenden, folgen Sie den Node.js-Einrichtungsschritten in der Vertex AI-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI Node.js API.

Richten Sie zur Authentifizierung bei Vertex AI Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */

// const project = 'YOUR_PROJECT_ID';
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
// const entityTypeId = 'YOUR_ENTITY_TYPE_ID';
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// Imports the Google Cloud Featurestore Service Client library
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: apiEndpoint,
};

// Instantiates a client
const featurestoreServiceClient = new FeaturestoreServiceClient(
  clientOptions
);

async function listFeatures() {
  // Configure the parent resource
  const parent = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}`;

  const request = {
    parent: parent,
  };

  // List Features request
  const [response] = await featurestoreServiceClient.listFeatures(request, {
    timeout: Number(timeout),
  });

  console.log('List features response');
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
listFeatures();

Weitere Sprachen

Informationen zum Installieren und Verwenden des Vertex AI SDK für Python finden Sie unter Vertex AI SDK für Python verwenden. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI SDK for Python API.

Nach Features suchen

Suchen Sie anhand von einer oder mehreren Eigenschaften nach Features, z. B. Feature-ID, Entitätstyp-ID oder Featurebeschreibung. Vertex AI Feature Store (Legacy) durchsucht alle Featurestores und Entitätstypen an einem bestimmten Standort. Sie können die Ergebnisse auch eingrenzen, indem Sie nach bestimmten Featurestores, Werttypen und Labels filtern.

Informationen zum Auflisten aller Features finden Sie unter Features auflisten.

Web-UI

  1. Rufen Sie im Bereich "Vertex AI" der Google Cloud Console die Seite Features auf.

    Zur Seite „Features“

  2. Wählen Sie eine Region aus der Drop-down-Liste Region aus.
  3. Klicken Sie in der Features-Tabelle auf das Feld Filter.
  4. Wählen Sie eine Eigenschaft aus, nach der gefiltert werden soll, z. B. Feature, was Features zurückgibt, die an einer beliebigen Stelle in ihrer ID einen übereinstimmenden String enthalten.
  5. Geben Sie einen Wert für den Filter ein und drücken Sie die Eingabetaste. Vertex AI Feature Store (Legacy) gibt Ergebnisse in der Funktionstabelle zurück.
  6. Wenn Sie weitere Filter hinzufügen möchten, klicken Sie noch einmal auf das Feld Filter.

REST

Senden Sie zum Suchen nach Features eine GET-Anfrage mit der Methode featurestores.searchFeatures. Im folgenden Beispiel werden mehrere Suchparameter verwendet, die als featureId:test AND valueType=STRING geschrieben werden. Die Abfrage gibt Features zurück, die test in ihrer ID enthalten und deren Werte vom Typ STRING sind.

Ersetzen Sie diese Werte in den folgenden Anfragedaten:

  • LOCATION_ID: Die Region, in der sich der Featurestore befindet, z. B. us-central1.
  • PROJECT_ID: Ihre Projekt-ID.

HTTP-Methode und URL:

GET https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores:searchFeatures?query="featureId:test%20AND%20valueType=STRING"

Senden Sie die Anfrage mithilfe einer der folgenden Optionen:

curl

Führen Sie folgenden Befehl aus:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores:searchFeatures?query="featureId:test%20AND%20valueType=STRING""

PowerShell

Führen Sie folgenden Befehl aus:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores:searchFeatures?query="featureId:test%20AND%20valueType=STRING"" | Select-Object -Expand Content

Sie sollten in etwa folgende JSON-Antwort erhalten:

{
  "features": [
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_IDfeature-delete.html/featurestores/featurestore_demo/entityTypes/testing/features/test1",
      "description": "featurestore test1",
      "createTime": "2021-02-26T18:16:09.528185Z",
      "updateTime": "2021-02-26T18:16:09.528185Z",
      "labels": {
        "environment": "testing"
      }
    }
  ]
}

Java

Bevor Sie dieses Beispiel anwenden, folgen Sie den Java-Einrichtungsschritten in der Vertex AI-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI Java API.

Richten Sie zur Authentifizierung bei Vertex AI Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.


import com.google.cloud.aiplatform.v1.Feature;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import com.google.cloud.aiplatform.v1.LocationName;
import com.google.cloud.aiplatform.v1.SearchFeaturesRequest;
import java.io.IOException;

public class SearchFeaturesSample {

  public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String query = "YOUR_QUERY";
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";
    searchFeaturesSample(project, query, location, endpoint);
  }

  static void searchFeaturesSample(String project, String query, String location, String endpoint)
      throws IOException {
    FeaturestoreServiceSettings featurestoreServiceSettings =
        FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (FeaturestoreServiceClient featurestoreServiceClient =
        FeaturestoreServiceClient.create(featurestoreServiceSettings)) {

      SearchFeaturesRequest searchFeaturesRequest =
          SearchFeaturesRequest.newBuilder()
              .setLocation(LocationName.of(project, location).toString())
              .setQuery(query)
              .build();
      System.out.println("Search Features Response");
      for (Feature element :
          featurestoreServiceClient.searchFeatures(searchFeaturesRequest).iterateAll()) {
        System.out.println(element);
      }
      featurestoreServiceClient.close();
    }
  }
}

Node.js

Bevor Sie dieses Beispiel anwenden, folgen Sie den Node.js-Einrichtungsschritten in der Vertex AI-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI Node.js API.

Richten Sie zur Authentifizierung bei Vertex AI Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */

// const project = 'YOUR_PROJECT_ID';
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// Imports the Google Cloud Featurestore Service Client library
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: apiEndpoint,
};

// Instantiates a client
const featurestoreServiceClient = new FeaturestoreServiceClient(
  clientOptions
);

async function searchFeatures() {
  // Configure the locationResource resource
  const locationResource = `projects/${project}/locations/${location}`;

  const request = {
    location: locationResource,
    query: query,
  };

  // Search Features request
  const [response] = await featurestoreServiceClient.searchFeatures(request, {
    timeout: Number(timeout),
  });

  console.log('Search features response');
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
searchFeatures();

Weitere Sprachen

Informationen zum Installieren und Verwenden des Vertex AI SDK für Python finden Sie unter Vertex AI SDK für Python verwenden. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI SDK for Python API.

Featuredetails ansehen

Sie können sich Details zu einem Feature wie den Werttyp oder die Beschreibung ansehen. Wenn Sie die Google Cloud Console verwenden und das Feature-Monitoring aktiviert haben, können Sie auch die Verteilung der Featurewerte im Zeitverlauf einsehen.

Web-UI

  1. Rufen Sie im Bereich "Vertex AI" der Google Cloud Console die Seite Features auf.

    Zur Seite „Features“

  2. Wählen Sie eine Region aus der Drop-down-Liste Region aus.
  3. In der Features-Tabelle sehen Sie in der Spalte Features das Feature, dessen Details Sie sich ansehen möchten.
  4. Klicken Sie auf den Namen eines Features, um dessen Details aufzurufen.
  5. Klicken Sie auf Messwerte, um seine Messwerte aufzurufen. Vertex AI Feature Store (Legacy) bietet Verteilungsmesswerte für das Feature.

REST

Wenn Sie Details zu einem Feature abrufen möchten, senden Sie eine GET-Anfrage mit der Methode featurestores.entityTypes.features.get.

Ersetzen Sie diese Werte in den folgenden Anfragedaten:

  • LOCATION_ID: Die Region, in der sich der Featurestore befindet, z. B. us-central1.
  • PROJECT_ID: Ihre Projekt-ID.
  • FEATURESTORE_ID: ID des Featurestores.
  • ENTITY_TYPE_ID: ID des Entitätstyps.
  • FEATURE_ID: ID des Features.

HTTP-Methode und URL:

GET https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID

Senden Sie die Anfrage mithilfe einer der folgenden Optionen:

curl

Führen Sie folgenden Befehl aus:

curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID"

PowerShell

Führen Sie folgenden Befehl aus:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID" | Select-Object -Expand Content

Sie sollten in etwa folgende JSON-Antwort erhalten:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID",
  "description": "DESCRIPTION",
  "valueType": "VALUE_TYPE",
  "createTime": "2021-03-01T22:41:20.628493Z",
  "updateTime": "2021-03-01T22:41:20.628493Z",
  "labels": {
    "environment": "testing"
  },
  "etag": "AMEw9yOZbdYKHTyjV22ziZR1vUX3nWOi0o2XU3-OADahSdfZ8Apklk_qPruhF-o1dOSD",
  "monitoringConfig": {}
}

Java

Bevor Sie dieses Beispiel anwenden, folgen Sie den Java-Einrichtungsschritten in der Vertex AI-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI Java API.

Richten Sie zur Authentifizierung bei Vertex AI Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.


import com.google.cloud.aiplatform.v1.Feature;
import com.google.cloud.aiplatform.v1.FeatureName;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import com.google.cloud.aiplatform.v1.GetFeatureRequest;
import java.io.IOException;

public class GetFeatureSample {

  public static void main(String[] args) throws IOException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String featurestoreId = "YOUR_FEATURESTORE_ID";
    String entityTypeId = "YOUR_ENTITY_TYPE_ID";
    String featureId = "YOUR_FEATURE_ID";
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";

    getFeatureSample(project, featurestoreId, entityTypeId, featureId, location, endpoint);
  }

  static void getFeatureSample(
      String project,
      String featurestoreId,
      String entityTypeId,
      String featureId,
      String location,
      String endpoint)
      throws IOException {

    FeaturestoreServiceSettings featurestoreServiceSettings =
        FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (FeaturestoreServiceClient featurestoreServiceClient =
        FeaturestoreServiceClient.create(featurestoreServiceSettings)) {

      GetFeatureRequest getFeatureRequest =
          GetFeatureRequest.newBuilder()
              .setName(
                  FeatureName.of(project, location, featurestoreId, entityTypeId, featureId)
                      .toString())
              .build();

      Feature feature = featurestoreServiceClient.getFeature(getFeatureRequest);
      System.out.println("Get Feature Response");
      System.out.println(feature);
      featurestoreServiceClient.close();
    }
  }
}

Node.js

Bevor Sie dieses Beispiel anwenden, folgen Sie den Node.js-Einrichtungsschritten in der Vertex AI-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI Node.js API.

Richten Sie zur Authentifizierung bei Vertex AI Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */

// const project = 'YOUR_PROJECT_ID';
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
// const entityTypeId = 'YOUR_ENTITY_TYPE_ID';
// const featureId = 'YOUR_FEATURE_ID';
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// Imports the Google Cloud Featurestore Service Client library
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: apiEndpoint,
};

// Instantiates a client
const featurestoreServiceClient = new FeaturestoreServiceClient(
  clientOptions
);

async function getFeature() {
  // Configure the name resource
  const name = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}/features/${featureId}`;

  const request = {
    name: name,
  };

  // Get Feature request
  const [response] = await featurestoreServiceClient.getFeature(request, {
    timeout: Number(timeout),
  });

  console.log('Get feature response');
  console.log(`Name : ${response.name}`);
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
getFeature();

Weitere Sprachen

Informationen zum Installieren und Verwenden des Vertex AI SDK für Python finden Sie unter Vertex AI SDK für Python verwenden. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI SDK for Python API.

Feature löschen

Löscht ein Feature und alle zugehörigen Werte.

Web-UI

  1. Rufen Sie im Bereich "Vertex AI" der Google Cloud Console die Seite Features auf.

    Zur Seite „Features“

  2. Wählen Sie eine Region aus der Drop-down-Liste Region aus.
  3. Suchen Sie in der Features-Tabelle die Spalte Feature das Feature, das Sie löschen möchten.
  4. Klicken Sie auf den Namen des Features.
  5. Klicken Sie in der Aktionsleiste auf Löschen.
  6. Klicken Sie auf Bestätigen, um das Feature und seine Werte zu löschen.

REST

Senden Sie eine DELETE-Anfrage mit der Methode featurestores.entityTypes.features.delete, um ein Feature zu löschen.

Ersetzen Sie diese Werte in den folgenden Anfragedaten:

  • LOCATION_ID: Die Region, in der sich der Featurestore befindet, z. B. us-central1.
  • PROJECT_ID: Ihre Projekt-ID.
  • FEATURESTORE_ID: ID des Featurestores.
  • ENTITY_TYPE_ID: ID des Entitätstyps.
  • FEATURE_ID: ID des Features.

HTTP-Methode und URL:

DELETE https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID

Senden Sie die Anfrage mithilfe einer der folgenden Optionen:

curl

Führen Sie folgenden Befehl aus:

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID"

PowerShell

Führen Sie folgenden Befehl aus:

$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "https://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/entityTypes/ENTITY_TYPE_ID/features/FEATURE_ID" | Select-Object -Expand Content

Sie sollten in etwa folgende JSON-Antwort erhalten:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.DeleteOperationMetadata",
    "genericMetadata": {
      "createTime": "2021-02-26T17:32:56.008325Z",
      "updateTime": "2021-02-26T17:32:56.008325Z"
    }
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.protobuf.Empty"
  }
}

Java

Bevor Sie dieses Beispiel anwenden, folgen Sie den Java-Einrichtungsschritten in der Vertex AI-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI Java API.

Richten Sie zur Authentifizierung bei Vertex AI Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1.DeleteFeatureRequest;
import com.google.cloud.aiplatform.v1.DeleteOperationMetadata;
import com.google.cloud.aiplatform.v1.FeatureName;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import com.google.protobuf.Empty;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class DeleteFeatureSample {

  public static void main(String[] args)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    // TODO(developer): Replace these variables before running the sample.
    String project = "YOUR_PROJECT_ID";
    String featurestoreId = "YOUR_FEATURESTORE_ID";
    String entityTypeId = "YOUR_ENTITY_TYPE_ID";
    String featureId = "YOUR_FEATURE_ID";
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";
    int timeout = 300;

    deleteFeatureSample(
        project, featurestoreId, entityTypeId, featureId, location, endpoint, timeout);
  }

  static void deleteFeatureSample(
      String project,
      String featurestoreId,
      String entityTypeId,
      String featureId,
      String location,
      String endpoint,
      int timeout)
      throws IOException, InterruptedException, ExecutionException, TimeoutException {
    FeaturestoreServiceSettings featurestoreServiceSettings =
        FeaturestoreServiceSettings.newBuilder().setEndpoint(endpoint).build();

    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests. After completing all of your requests, call
    // the "close" method on the client to safely clean up any remaining background resources.
    try (FeaturestoreServiceClient featurestoreServiceClient =
        FeaturestoreServiceClient.create(featurestoreServiceSettings)) {

      DeleteFeatureRequest deleteFeatureRequest =
          DeleteFeatureRequest.newBuilder()
              .setName(
                  FeatureName.of(project, location, featurestoreId, entityTypeId, featureId)
                      .toString())
              .build();

      OperationFuture<Empty, DeleteOperationMetadata> operationFuture =
          featurestoreServiceClient.deleteFeatureAsync(deleteFeatureRequest);
      System.out.format("Operation name: %s%n", operationFuture.getInitialFuture().get().getName());
      System.out.println("Waiting for operation to finish...");
      operationFuture.get(timeout, TimeUnit.SECONDS);
      System.out.format("Deleted Feature.");
      featurestoreServiceClient.close();
    }
  }
}

Node.js

Bevor Sie dieses Beispiel anwenden, folgen Sie den Node.js-Einrichtungsschritten in der Vertex AI-Kurzanleitung zur Verwendung von Clientbibliotheken. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI Node.js API.

Richten Sie zur Authentifizierung bei Vertex AI Standardanmeldedaten für Anwendungen ein. Weitere Informationen finden Sie unter Authentifizierung für eine lokale Entwicklungsumgebung einrichten.

/**
 * TODO(developer): Uncomment these variables before running the sample.\
 * (Not necessary if passing values as arguments)
 */

// const project = 'YOUR_PROJECT_ID';
// const featurestoreId = 'YOUR_FEATURESTORE_ID';
// const entityTypeId = 'YOUR_ENTITY_TYPE_ID';
// const featureId = 'YOUR_FEATURE_ID';
// const location = 'YOUR_PROJECT_LOCATION';
// const apiEndpoint = 'YOUR_API_ENDPOINT';
// const timeout = <TIMEOUT_IN_MILLI_SECONDS>;

// Imports the Google Cloud Featurestore Service Client library
const {FeaturestoreServiceClient} = require('@google-cloud/aiplatform').v1;

// Specifies the location of the api endpoint
const clientOptions = {
  apiEndpoint: apiEndpoint,
};

// Instantiates a client
const featurestoreServiceClient = new FeaturestoreServiceClient(
  clientOptions
);

async function deleteFeature() {
  // Configure the name resource
  const name = `projects/${project}/locations/${location}/featurestores/${featurestoreId}/entityTypes/${entityTypeId}/features/${featureId}`;

  const request = {
    name: name,
  };

  // Delete Feature request
  const [operation] = await featurestoreServiceClient.deleteFeature(request, {
    timeout: Number(timeout),
  });
  const [response] = await operation.promise();

  console.log('Delete feature response');
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
deleteFeature();

Weitere Sprachen

Informationen zum Installieren und Verwenden des Vertex AI SDK für Python finden Sie unter Vertex AI SDK für Python verwenden. Weitere Informationen finden Sie in der Referenzdokumentation zur Vertex AI SDK for Python API.

Nächste Schritte