featurestore の管理

featurestore の作成、一覧表示、記述、更新、削除方法について説明します。featurestore は、エンティティ タイプ、特徴、特徴値を格納する最上位のコンテナです。

オンライン ストレージとオフライン ストレージ

Vertex AI Feature Store(従来版)は、オンライン ストレージとオフライン ストレージに分類される 2 つのストレージ メソッドを使用します。これらは料金が異なります。すべての featurestore にはオフライン ストレージがあります。また、オプションのオンライン ストレージがある場合もあります。

オンライン ストレージでは、オンライン サービング リクエストを効率的に処理するため、特徴の最新のタイムスタンプ値が保持されます。API を使用してインポート ジョブを実行する場合、データをオンライン ストアに書き込むときにジョブを制御できます。オンライン ストアをスキップすると、オンライン サービング ノードに負荷がかかりません。たとえば、バックフィル ジョブを実行する場合、オンライン ストアへの書き込みを無効にして、オフライン ストアへの書き込みのみを行うことができます。詳細については、API リファレンスdisableOnlineServing フラグをご覧ください。

データが保存数の上限に達するか、ユーザーが削除するまで、Vertex AI Feature Store(従来版)はオフライン ストレージを使用してデータを保存します。オフライン ストアには無制限にデータを保存できます。オフライン保存の費用を管理するには、保持するデータの量を管理します。featurestore のデフォルトのオンライン データ保持制限と、エンティティ タイプのオフライン データ保持制限をオーバーライドすることもできます。詳しくは、Vertex AI Feature Store(従来版)の割り当てと上限の詳細をご覧ください

Google Cloud コンソールを使用して、現在使用しているオンライン ストレージとオフライン ストレージの量を確認します。featurestore のオンライン ストレージの合計オフライン ストレージの合計のモニタリング指標を表示して、使用量を確認します。

オンライン サービング ノード

オンライン サービング ノードは、低レイテンシのオンライン サービングで特徴値の保存と提供に使用されるコンピューティング リソースを提供します。これらのノードは、データを提供していない場合でも、常に実行されています。ノード時間ごとに料金が発生します。

オンライン サービング ノードのストレージの上限は、ノードあたり 5 TB です。詳しくは、Vertex AI Feature Store(従来版)の割り当てと上限の詳細をご覧ください

必要なオンライン サービング ノードの数は、次の 2 つの要因に正比例します。

  • featurestore が受信するオンライン サービング リクエスト(秒間クエリ数)。
  • オンライン ストレージに書き込むインポート ジョブの数。

どちらの要因もノードの CPU 使用率とパフォーマンスに影響します。Google Cloud コンソールから、次の指標を表示します。

  • 秒間クエリ数: featurestore への秒間クエリ数。
  • ノード数: オンライン サービング ノードの数
  • CPU 使用率: ノードの CPU 使用率

CPU 使用率が常に高い場合は、featurestore のオンライン サービング ノード数を増やすことを検討してください。

オンライン サービング ノードのパフォーマンスをテストする

リアルタイムの特徴サービングのために、オンライン サービング ノードのパフォーマンスをテストできます。これにより、featurestore が事前に定義された QPS またはレイテンシのしきい値内で実行するのに十分なマシンリソースを確保できます。これらのテストは、QPS、レイテンシ、API などのさまざまなベンチマーク パラメータに基づいて実行できます。オンライン サービング ノードのパフォーマンスをテストするためのガイドラインとベスト プラクティスについては、Vertex AI Feature Store(従来版)のベスト プラクティスリアルタイム サービング用のオンライン サービング ノードのパフォーマンスをテストするをご覧ください。

また、Vertex AI Benchmarker オープンソース ツールを使用して、Feature Store リソースのパフォーマンス負荷テストを実施できます。Vertex AI Benchmarker のオープンソース ツールは、Python コマンドライン ツールと Java ワーカーで構成されています。

スケーリング オプション

オンライン サービング ノードの数は、次のオプションで構成できます。

  • 自動スケーリング

    自動スケーリングを選択すると、featurestore は CPU 使用率に基づいてノード数を自動的に変更します。自動スケーリングでは、トラフィック パターンを確認します。トラフィックが増加するとノードを追加し、トラフィックが減少するとノードを削除します。

    自動スケーリングは、段階的な成長と減少を伴うトラフィック パターンに効果的です。負荷の変動が頻繁に発生するトラフィック パターンに Vertex AI Feature Store(従来版)を広範囲に使用する場合は、自動スケーリングを使用するとコスト効率が高まります。

  • 固定ノード数の割り当て

    固定ノード数を割り当てると、Vertex AI Feature Store(従来版)はトラフィック パターンに関係なく一貫したノード数を維持します。ノード数は固定されるため、コストは予測可能です。トラフィックの処理に十分なノード数があれば適切に機能します。トラフィック パターンの変化に対応するため、ノード数を手動で変更できます。

自動スケーリングに関するその他の考慮事項

自動スケーリングを選択する場合は、さらに次の 4 つの点を考慮する必要があります。

  • オンライン サービング ノードを追加した後、オンライン ストアでデータのバランスを調整する時間が必要です。パフォーマンスが著しく向上するまでに、負荷のかかった状態が最大で 20 分ほど続く可能性があります。その結果、ノード数をスケーリングしても、トラフィックの急増に対応できない可能性があります。この上限は、手動スケーリングと自動スケーリングの両方に適用されます。

  • オンライン サービング ノードなしで featurestore にオンライン サービング リクエストを送信すると、エラーが返されます。

featurestore でオンライン サービングを無効にする

オンライン サービングが不要になり、オンライン サービング ノードが変更されないようにするには、オンライン サービング ノード数を 0 に設定します。featurestore でオンライン サービングを無効にするには、次の構成を設定します。

  1. 自動スケーリングを使用している場合は、scaling パラメータを削除します。

  2. オンライン サービング ノードの固定数を 0 に設定します。

featurestore の作成方法については、featurestore の作成をご覧ください。既存の featurestore の構成を変更する方法については、featurestore の更新をご覧ください。

オンライン サービング ノード数を 0 に設定すると、そのデータを含むオンライン ストア全体が削除されます。オンライン ストアを一時的に無効にしてから復元するには、削除されたデータを再度インポートする必要があります。

たとえば、featurestore のオンライン サービング ノード数を 0 に設定し、ノード数を 1 以上に設定してオンライン サービング ノードをプロビジョニングする場合、Vertex AI Feature Store(従来版)は削除された特徴データをオンライン ストアに移行しません。オンライン ストアで再入力するには、データを再インポートする必要があります。データを再インポートする方法の一つとして、オンライン サービング ノードを無効にする前に履歴データをエクスポートし、ノードをプロビジョニングした後にそのエクスポート データをインポートする方法があります。

オンライン サービング ノードをプロビジョニングする場合、オペレーションが完了するのを待ってから新しいデータをインポートする必要があります。進行中のインポート ジョブは、オンライン サービング ノード プロビジョニングの完了後にのみ再開されます。

オンライン サービング ノードのない featurestore にオンライン サービング リクエストを送信すると、エラーが返されます。

featurestore を作成する

エンティティのタイプと特徴を含む featurestore リソースを作成します。featurestore の場所は、ソースデータと同じロケーションにする必要があります。たとえば、featurestore が us-central, にある場合、us-central1 または米国のマルチリージョンにある Cloud Storage バケット内のファイルからデータをインポートできます。ただし、デュアルリージョン バケットのソースデータはサポートされていません。BigQuery と同様に、us-central1 または米国のマルチリージョン ロケーションにあるテーブルからデータをインポートできます。詳細については、ソースデータの要件をご覧ください。

Vertex AI Feature Store(従来版)の可用性はロケーションによって異なります。詳細については、機能の提供状況をご覧ください。

ウェブ UI

選択したリージョンの Google Cloud プロジェクトに featurestore がまだ作成されていない場合は、Google Cloud コンソールを使用して featurestore を作成できます。プロジェクトとリージョンに featurestore がすでに存在する場合は、別の方法を使用します。

Google Cloud コンソールを使用して featurestore を作成するには:

  1. Google Cloud コンソールの [Vertex AI] セクションで、[特徴] ページに移動します。

    [特徴] ページに移動

  2. [featurestore を作成] をクリックします。
  3. featurestore の名前を指定します。
  4. featurestore のオンライン サービングをオンにするには、[オンライン サービングを有効にする] トグルをクリックして、スケーリング オプションを設定します。
    オンライン サービングとスケーリング オプションの詳細については、オンライン サービング ノードをご覧ください。
  5. [作成] をクリックします。

Terraform

次のサンプルでは、固定のノード数を持つ featurestore を作成するために、google_vertex_ai_featurestore Terraform リソースを使用しています。featurestore の名前は featurestore_xxxxxxxx です。xxxxxxxx はランダムに生成された英数字の ID です。

Terraform 構成を適用または削除する方法については、基本的な Terraform コマンドをご覧ください。

# Featurestore name must be unique for the project
resource "random_id" "featurestore_name_suffix" {
  byte_length = 8
}

resource "google_vertex_ai_featurestore" "main" {
  name   = "featurestore_${random_id.featurestore_name_suffix.hex}"
  region = "us-central1"
  labels = {
    environment = "testing"
  }

  online_serving_config {
    fixed_node_count = 1
  }

  force_destroy = true
}

REST

featurestore を作成するには、featurestores.create メソッドを使用して POST リクエストを送信します。

次の例では、固定ノード数(1)の featurestore を作成します。ノード数にはオンライン サービング ノードの数を指定します。これは、featurestore が処理できるオンライン サービング リクエストの数に影響します。受信リクエストをサポートできないノード数の場合、レイテンシが長くなる可能性があります。

リクエストのデータを使用する前に、次のように置き換えます。

  • LOCATION_ID: featurestore が作成されるリージョン。例: us-central1
  • PROJECT_ID: 実際のプロジェクト ID
  • FEATURESTORE_ID: featurestore の ID。

HTTP メソッドと URL:

POST http://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores?featurestoreId=FEATURESTORE_ID

リクエストの本文(JSON):

{
  "online_serving_config": {
    "fixed_node_count": 1
  },
  "labels": {
    "environment": "testing"
  }
}

リクエストを送信するには、次のいずれかのオプションを選択します。

curl

リクエスト本文を request.json という名前のファイルに保存して、次のコマンドを実行します。

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

PowerShell

リクエスト本文を request.json という名前のファイルに保存して、次のコマンドを実行します。

$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 "http://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores?featurestoreId=FEATURESTORE_ID" | Select-Object -Expand Content

出力は次のようになります。レスポンスの OPERATION_ID を使用して、オペレーションのステータスを取得できます。

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

Python

Vertex AI SDK for Python のインストールまたは更新の方法については、Vertex AI SDK for Python をインストールするをご覧ください。詳細については、Python API リファレンス ドキュメントをご覧ください。

from google.cloud import aiplatform

def create_featurestore_sample(
    project: str,
    location: str,
    featurestore_id: str,
    online_store_fixed_node_count: int = 1,
    sync: bool = True,
):

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

    fs = aiplatform.Featurestore.create(
        featurestore_id=featurestore_id,
        online_store_fixed_node_count=online_store_fixed_node_count,
        sync=sync,
    )

    fs.wait()

    return fs

Python

Vertex AI SDK for Python をインストールすると、Vertex AI のクライアント ライブラリが組み込まれます。Vertex AI SDK for Python のインストール方法については、Vertex AI SDK for Python をインストールするをご覧ください。詳細については、Vertex AI SDK for Python API のリファレンス ドキュメントをご覧ください。

from google.cloud import aiplatform

def create_featurestore_sample(
    project: str,
    featurestore_id: str,
    fixed_node_count: int = 1,
    location: str = "us-central1",
    api_endpoint: str = "us-central1-aiplatform.googleapis.com",
    timeout: int = 1200,
):
    # 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}"
    create_featurestore_request = aiplatform.gapic.CreateFeaturestoreRequest(
        parent=parent,
        featurestore_id=featurestore_id,
        featurestore=aiplatform.gapic.Featurestore(
            online_serving_config=aiplatform.gapic.Featurestore.OnlineServingConfig(
                fixed_node_count=fixed_node_count,
            ),
        ),
    )
    lro_response = client.create_featurestore(request=create_featurestore_request)
    print("Long running operation:", lro_response.operation.name)
    create_featurestore_response = lro_response.result(timeout=timeout)
    print("create_featurestore_response:", create_featurestore_response)

Java

このサンプルを試す前に、Vertex AI クイックスタート: クライアント ライブラリの使用にある Java の設定手順を完了してください。詳細については、Vertex AI Java API のリファレンス ドキュメントをご覧ください。

Vertex AI に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証を設定するをご覧ください。


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1.CreateFeaturestoreOperationMetadata;
import com.google.cloud.aiplatform.v1.CreateFeaturestoreRequest;
import com.google.cloud.aiplatform.v1.Featurestore;
import com.google.cloud.aiplatform.v1.Featurestore.OnlineServingConfig;
import com.google.cloud.aiplatform.v1.Featurestore.OnlineServingConfig.Scaling;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import com.google.cloud.aiplatform.v1.LocationName;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class CreateFeaturestoreSample {

  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";
    int minNodeCount = 1;
    int maxNodeCount = 5;
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";
    int timeout = 900;
    createFeaturestoreSample(
        project, featurestoreId, minNodeCount, maxNodeCount, location, endpoint, timeout);
  }

  static void createFeaturestoreSample(
      String project,
      String featurestoreId,
      int minNodeCount,
      int maxNodeCount,
      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)) {

      OnlineServingConfig.Builder builderValue =
          OnlineServingConfig.newBuilder()
              .setScaling(
                  Scaling.newBuilder().setMinNodeCount(minNodeCount).setMaxNodeCount(maxNodeCount));
      Featurestore featurestore =
          Featurestore.newBuilder().setOnlineServingConfig(builderValue).build();
      String parent = LocationName.of(project, location).toString();

      CreateFeaturestoreRequest createFeaturestoreRequest =
          CreateFeaturestoreRequest.newBuilder()
              .setParent(parent)
              .setFeaturestore(featurestore)
              .setFeaturestoreId(featurestoreId)
              .build();

      OperationFuture<Featurestore, CreateFeaturestoreOperationMetadata> featurestoreFuture =
          featurestoreServiceClient.createFeaturestoreAsync(createFeaturestoreRequest);
      System.out.format(
          "Operation name: %s%n", featurestoreFuture.getInitialFuture().get().getName());
      System.out.println("Waiting for operation to finish...");
      Featurestore featurestoreResponse = featurestoreFuture.get(timeout, TimeUnit.SECONDS);
      System.out.println("Create Featurestore Response");
      System.out.format("Name: %s%n", featurestoreResponse.getName());
    }
  }
}

Node.js

このサンプルを試す前に、Vertex AI クライアント ライブラリをインストールするにある Node.js の設定手順を完了してください。詳細については、Vertex AI Node.js API のリファレンス ドキュメントをご覧ください。

Vertex AI に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証を設定するをご覧ください。

/**
 * 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 minNodeCount = <MINIMUM_NO_OF_NODES>;
// const maxNodeCount = <MAXIMUM_NO_OF_NODES>;
// 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').v1beta1;

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

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

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

  const featurestore = {
    onlineServingConfig: {
      scaling: {
        minNodeCount: minNodeCount,
        maxNodeCount: maxNodeCount,
      },
    },
  };

  const request = {
    parent: parent,
    featurestore: featurestore,
    featurestoreId: featurestoreId,
  };

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

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

CMEK を使用する featurestore を作成する

始める前に、既存の CMEK(顧客管理の暗号鍵)がない場合は、Cloud Key Management Service を使用して顧客管理の暗号鍵を構成し、権限を設定します。次のサンプルは、CMEK 鍵を使用する featurestore を作成します。

Vertex AI で関連する CMEK 鍵の権限が失われると、その鍵で暗号化された featurestore 内のリソースと値は、Vertex AI が再び使用できるようになるまでアクセスできなくなります。

30 日が経過しても Vertex AI が CMEK 鍵にアクセスできない場合、Vertex AI はその鍵で暗号化されたすべての featurestore を削除します。新しい featurestore の作成時に、これらの featurestore 名を再利用することはできません。

ウェブ UI

別の方法を使用してください。Google Cloud コンソールから featurestore を作成することはできません。

REST

リクエストのデータを使用する前に、次のように置き換えます。

  • LOCATION_ID: featurestore が作成されるリージョン。例: us-central1
  • PROJECT_ID: 実際のプロジェクト ID
  • FEATURESTORE_ID: featurestore の ID。
  • CMEK_PROJECT: CMEK を含むプロジェクト ID またはプロジェクト番号。
  • KEY_RING: 暗号鍵が存在する Cloud Key Management Service のキーリングの名前。
  • KEY_NAME: 使用する暗号鍵の名前。

HTTP メソッドと URL:

POST http://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores?featurestoreId=FEATURESTORE_ID

リクエストの本文(JSON):

{
  "online_serving_config": {
    "fixed_node_count": 1
  },
  "encryption_spec":{
    "kms_key_name": "projects/CMEK_PROJECT/locations/LOCATION_ID/keyRings/KEY_RING/cryptoKeys/KEY_NAME"
  }
}

リクエストを送信するには、次のいずれかのオプションを選択します。

curl

リクエスト本文を request.json という名前のファイルに保存して、次のコマンドを実行します。

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

PowerShell

リクエスト本文を request.json という名前のファイルに保存して、次のコマンドを実行します。

$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 "http://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores?featurestoreId=FEATURESTORE_ID" | Select-Object -Expand Content

出力は次のようになります。レスポンスの OPERATION_ID を使用して、オペレーションのステータスを取得できます。

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

featurestore の一覧表示

プロジェクト内のすべての featurestore を一覧表示します。

ウェブ UI

  1. Google Cloud Console の [Vertex AI] セクションで、[特徴] ページに移動します。

    [特徴] ページに移動

  2. [リージョン] プルダウン リストからリージョンを選択します。
  3. 特徴テーブルの [Featurestore] 列を表示して、選択したリージョンのプロジェクト内の featurestore を確認します。

REST

プロジェクト内の特定リージョンの featurestore を一覧表示するには、featurestores.list メソッドを使用して GET リクエストを送信します。

リクエストのデータを使用する前に、次のように置き換えます。

  • LOCATION_ID: featurestore が配置されているリージョン(us-central1 など)。
  • PROJECT_ID: 実際のプロジェクト ID

HTTP メソッドと URL:

GET http://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores

リクエストを送信するには、次のいずれかのオプションを選択します。

curl

次のコマンドを実行します。

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

PowerShell

次のコマンドを実行します。

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

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

次のような JSON レスポンスが返されます。

{
  "featurestores": [
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/test",
      "createTime": "2021-02-26T00:44:44.216805Z",
      "updateTime": "2021-02-26T00:44:44.364916Z",
      "etag": "AMEw9yNL0s7qZh8lZVZ5T3BEuhoEgFR7JmjbbCSAkRZjeKDXkkIYnxxA4POe5BWT8cCn",
      "labels": {
        "environment": "testing"
      },
      "onlineServingConfig": {
        "fixedNodeCount": 2
      },
      "state": "STABLE"
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/featurestore_demo",
      "createTime": "2021-02-25T00:39:40.598781Z",
      "updateTime": "2021-02-25T00:39:40.744038Z",
      "etag": "AMEw9yO_e0vm-9W_yeCz4rJm-XnnEMYQ-vQesevxya_sz-FckuysnDwo3cEXHdWWSeda",
      "labels": {
        "environment": "testing"
      },
      "onlineServingConfig": {
        "fixedNodeCount": 3
      },
      "state": "STABLE"
    }
  ]
}

Java

このサンプルを試す前に、Vertex AI クイックスタート: クライアント ライブラリの使用にある Java の設定手順を完了してください。詳細については、Vertex AI Java API のリファレンス ドキュメントをご覧ください。

Vertex AI に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証を設定するをご覧ください。


import com.google.cloud.aiplatform.v1.Featurestore;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import com.google.cloud.aiplatform.v1.ListFeaturestoresRequest;
import com.google.cloud.aiplatform.v1.LocationName;
import java.io.IOException;

public class ListFeaturestoresSample {

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

  static void listFeaturestoresSample(String project, 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)) {

      ListFeaturestoresRequest listFeaturestoresRequest =
          ListFeaturestoresRequest.newBuilder()
              .setParent(LocationName.of(project, location).toString())
              .build();

      System.out.println("List Featurestores Response");
      for (Featurestore element :
          featurestoreServiceClient.listFeaturestores(listFeaturestoresRequest).iterateAll()) {
        System.out.println(element);
      }
    }
  }
}

Node.js

このサンプルを試す前に、Vertex AI クライアント ライブラリをインストールするにある Node.js の設定手順を完了してください。詳細については、Vertex AI Node.js API のリファレンス ドキュメントをご覧ください。

Vertex AI に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証を設定するをご覧ください。

/**
 * 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 listFeaturestores() {
  // Configure the parent resource
  const parent = `projects/${project}/locations/${location}`;

  const request = {
    parent: parent,
  };

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

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

その他の言語

Vertex AI SDK for Python をインストールして使用する方法については、Vertex AI SDK for Python を使用するをご覧ください。詳細については、Vertex AI SDK for Python API のリファレンス ドキュメントをご覧ください。

featurestore の詳細を表示する

featurestore の詳細(名前やオンライン サービング構成など)を取得します。Google Cloud コンソールを使用する場合、featurestore の Cloud Monitoring 指標を表示できます。

ウェブ UI

  1. Google Cloud Console の [Vertex AI] セクションで、[特徴] ページに移動します。

    [特徴] ページに移動

  2. [リージョン] プルダウン リストからリージョンを選択します。
  3. 特徴テーブルの [Featurestore] 列を表示して、情報を表示する featurestore を見つけます。
  4. featurestore の名前をクリックして、モニタリング指標を表示します。
  5. [プロパティ] タブをクリックして、featurestore のオンライン サービング構成を表示します。

REST

単一の featurestore の詳細を取得するには、featurestores.get メソッドを使用して GET リクエストを送信します。

リクエストのデータを使用する前に、次のように置き換えます。

  • LOCATION_ID: featurestore が配置されているリージョン(us-central1 など)。
  • PROJECT_ID: 実際のプロジェクト ID
  • FEATURESTORE_ID: featurestore の ID。

HTTP メソッドと URL:

GET http://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID

リクエストを送信するには、次のいずれかのオプションを選択します。

curl

次のコマンドを実行します。

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

PowerShell

次のコマンドを実行します。

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

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

次のような JSON レスポンスが返されます。

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID",
  "createTime": "2021-02-25T00:39:40.598781Z",
  "updateTime": "2021-02-25T00:39:40.744038Z",
  "etag": "AMEw9yNy_b4IaMIvw1803ZT38cpUtjfwlyLkR709oBCY6pQrm6dHophLcqhrvsNqkQQZ",
  "onlineServingConfig": {
    "fixedNodeCount": 3
  },
  "state": "STABLE"
}

Java

このサンプルを試す前に、Vertex AI クイックスタート: クライアント ライブラリの使用にある Java の設定手順を完了してください。詳細については、Vertex AI Java API のリファレンス ドキュメントをご覧ください。

Vertex AI に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証を設定するをご覧ください。


import com.google.cloud.aiplatform.v1.Featurestore;
import com.google.cloud.aiplatform.v1.FeaturestoreName;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import com.google.cloud.aiplatform.v1.GetFeaturestoreRequest;
import java.io.IOException;

public class GetFeaturestoreSample {

  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 location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";
    getFeaturestoreSample(project, featurestoreId, location, endpoint);
  }

  static void getFeaturestoreSample(
      String project, String featurestoreId, 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)) {

      GetFeaturestoreRequest getFeaturestoreRequest =
          GetFeaturestoreRequest.newBuilder()
              .setName(FeaturestoreName.of(project, location, featurestoreId).toString())
              .build();

      Featurestore featurestore = featurestoreServiceClient.getFeaturestore(getFeaturestoreRequest);
      System.out.println("Get Featurestore Response");
      System.out.println(featurestore);
    }
  }
}

Node.js

このサンプルを試す前に、Vertex AI クライアント ライブラリをインストールするにある Node.js の設定手順を完了してください。詳細については、Vertex AI Node.js API のリファレンス ドキュメントをご覧ください。

Vertex AI に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証を設定するをご覧ください。

/**
 * 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 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 getFeaturestore() {
  // Configure the parent resource
  const name = `projects/${project}/locations/${location}/featurestores/${featurestoreId}`;

  const request = {
    name: name,
  };

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

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

その他の言語

Vertex AI SDK for Python をインストールして使用する方法については、Vertex AI SDK for Python を使用するをご覧ください。詳細については、Vertex AI SDK for Python API のリファレンス ドキュメントをご覧ください。

featurestore を更新する

featurestore を更新します。たとえば、オンライン サービング ノードの数の変更や featurestore ラベルの更新を行います。

ウェブ UI

更新できるのは、オンライン サービング ノードの数のみです。ラベルを更新するには、API を使用します。

  1. Google Cloud Console の [Vertex AI] セクションで、[特徴] ページに移動します。

    [特徴] ページに移動

  2. [リージョン] プルダウン リストからリージョンを選択します。
  3. 特徴テーブルの [Featurestore] 列を表示し、更新する featurestore の名前をクリックします。
  4. [構成を編集] をクリックして、[featurestore の構成の編集] ペインを開きます。
  5. featurestore の構成を編集します。
  6. [更新] をクリックして変更を適用します。

REST

featurestore を更新するには、featurestores.patch メソッドを使用して PATCH リクエストを送信します。

次のサンプルでは、featurestore のオンライン サービング ノード数を 2 に更新します。他の設定は変更しません。

リクエストのデータを使用する前に、次のように置き換えます。

  • LOCATION_ID: featurestore が配置されているリージョン(us-central1 など)。
  • PROJECT_ID: 実際のプロジェクト ID
  • FEATURESTORE_ID: featurestore の ID。

HTTP メソッドと URL:

PATCH http://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID

リクエストの本文(JSON):

{
  "online_serving_config": {
    "fixed_node_count": 2
  }
}

リクエストを送信するには、次のいずれかのオプションを選択します。

curl

リクエスト本文を request.json という名前のファイルに保存して、次のコマンドを実行します。

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

PowerShell

リクエスト本文を request.json という名前のファイルに保存して、次のコマンドを実行します。

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

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

出力は次のようになります。レスポンスの OPERATION_ID を使用して、オペレーションのステータスを取得できます。

{
"name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/featurestores/FEATURESTORE_ID/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.UpdateFeaturestoreOperationMetadata",
    "genericMetadata": {
      "createTime": "2021-03-18T21:12:08.373664Z",
      "updateTime": "2021-03-18T21:12:08.373664Z"
    }
  }
}

Java

このサンプルを試す前に、Vertex AI クイックスタート: クライアント ライブラリの使用にある Java の設定手順を完了してください。詳細については、Vertex AI Java API のリファレンス ドキュメントをご覧ください。

Vertex AI に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証を設定するをご覧ください。


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1.Featurestore;
import com.google.cloud.aiplatform.v1.Featurestore.OnlineServingConfig;
import com.google.cloud.aiplatform.v1.Featurestore.OnlineServingConfig.Scaling;
import com.google.cloud.aiplatform.v1.FeaturestoreName;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1.FeaturestoreServiceSettings;
import com.google.cloud.aiplatform.v1.UpdateFeaturestoreOperationMetadata;
import com.google.cloud.aiplatform.v1.UpdateFeaturestoreRequest;
import java.io.IOException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

public class UpdateFeaturestoreSample {

  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";
    int minNodeCount = 2;
    int maxNodeCount = 4;
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";
    int timeout = 300;
    updateFeaturestoreSample(
        project, featurestoreId, minNodeCount, maxNodeCount, location, endpoint, timeout);
  }

  static void updateFeaturestoreSample(
      String project,
      String featurestoreId,
      int minNodeCount,
      int maxNodeCount,
      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)) {

      OnlineServingConfig.Builder builderValue =
          OnlineServingConfig.newBuilder()
              .setScaling(
                  Scaling.newBuilder().setMinNodeCount(minNodeCount).setMaxNodeCount(maxNodeCount));
      Featurestore featurestore =
          Featurestore.newBuilder()
              .setName(FeaturestoreName.of(project, location, featurestoreId).toString())
              .setOnlineServingConfig(builderValue)
              .build();

      UpdateFeaturestoreRequest request =
          UpdateFeaturestoreRequest.newBuilder().setFeaturestore(featurestore).build();

      OperationFuture<Featurestore, UpdateFeaturestoreOperationMetadata> updateFeaturestoreFuture =
          featurestoreServiceClient.updateFeaturestoreAsync(request);
      System.out.format(
          "Operation name: %s%n", updateFeaturestoreFuture.getInitialFuture().get().getName());
      System.out.println("Waiting for operation to finish...");
      Featurestore featurestoreResponse = updateFeaturestoreFuture.get(timeout, TimeUnit.SECONDS);
      System.out.println("Update Featurestore Response");
      System.out.format("Name: %s%n", featurestoreResponse.getName());
    }
  }
}

Node.js

このサンプルを試す前に、Vertex AI クライアント ライブラリをインストールするにある Node.js の設定手順を完了してください。詳細については、Vertex AI Node.js API のリファレンス ドキュメントをご覧ください。

Vertex AI に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証を設定するをご覧ください。

/**
 * 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 minNodeCount = <MINIMUM_NO_OF_NODES>;
// const maxNodeCount = <MAXIMUM_NO_OF_NODES>;
// 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').v1beta1;

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

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

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

  const featurestore = {
    name: parent,
    onlineServingConfig: {
      scaling: {
        minNodeCount: minNodeCount,
        maxNodeCount: maxNodeCount,
      },
    },
  };

  const request = {
    featurestore: featurestore,
  };

  // Update Featurestore request
  const [operation] = await featurestoreServiceClient.updateFeaturestore(
    request,
    {timeout: Number(timeout)}
  );
  const [response] = await operation.promise();

  console.log('Update featurestore response');
  console.log(`Name : ${response.name}`);
  console.log('Raw response:');
  console.log(JSON.stringify(response, null, 2));
}
updateFeaturestore();

その他の言語

Vertex AI SDK for Python をインストールして使用する方法については、Vertex AI SDK for Python を使用するをご覧ください。詳細については、Vertex AI SDK for Python API のリファレンス ドキュメントをご覧ください。

featurestore を削除する

featurestore を削除します。featurestore に既存のエンティティ タイプと特徴が含まれている場合は、force クエリ パラメータを有効にして、featurestore とそのコンテンツをすべて削除します。

ウェブ UI

別の方法を使用してください。Google Cloud コンソールから featurestore を削除することはできません。

REST

featurestore とそのすべてのコンテンツを削除するには、featurestores.delete メソッドを使用して DELETE リクエストを送信します。

リクエストのデータを使用する前に、次のように置き換えます。

  • LOCATION_ID: featurestore が配置されているリージョン(us-central1 など)。
  • PROJECT_ID: 実際のプロジェクト ID
  • FEATURESTORE_ID: featurestore の ID。
  • BOOLEAN: エンティティ タイプと特徴を含む場合でも featurestore を削除するかどうか。force クエリ パラメータは省略可能です。デフォルトでは false です。

HTTP メソッドと URL:

DELETE http://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID?force=BOOLEAN

リクエストを送信するには、次のいずれかのオプションを選択します。

curl

次のコマンドを実行します。

curl -X DELETE \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"http://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID?force=BOOLEAN"

PowerShell

次のコマンドを実行します。

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

Invoke-WebRequest `
-Method DELETE `
-Headers $headers `
-Uri "http://LOCATION_ID-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION_ID/featurestores/FEATURESTORE_ID?force=BOOLEAN" | Select-Object -Expand Content

次のような JSON レスポンスが返されます。

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION_ID/operations/OPERATIONS_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.aiplatform.v1.DeleteOperationMetadata",
    "genericMetadata": {
      "createTime": "2021-05-03T17:50:21.813112Z",
      "updateTime": "2021-05-03T17:50:21.813112Z"
    }
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.protobuf.Empty"
  }
}

Python

Vertex AI SDK for Python のインストールまたは更新の方法については、Vertex AI SDK for Python をインストールするをご覧ください。詳細については、Python API リファレンス ドキュメントをご覧ください。

from google.cloud import aiplatform

def delete_featurestore_sample(
    project: str,
    location: str,
    featurestore_name: str,
    sync: bool = True,
    force: bool = True,
):

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

    fs = aiplatform.featurestore.Featurestore(featurestore_name=featurestore_name)
    fs.delete(sync=sync, force=force)

Python

Vertex AI SDK for Python をインストールすると、Vertex AI のクライアント ライブラリが組み込まれます。Vertex AI SDK for Python のインストール方法については、Vertex AI SDK for Python をインストールするをご覧ください。詳細については、Vertex AI SDK for Python API のリファレンス ドキュメントをご覧ください。

from google.cloud import aiplatform

def delete_featurestore_sample(
    project: str,
    featurestore_id: str,
    location: str = "us-central1",
    api_endpoint: str = "us-central1-aiplatform.googleapis.com",
    timeout: int = 1200,
):
    # 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)
    name = client.featurestore_path(
        project=project, location=location, featurestore=featurestore_id
    )
    response = client.delete_featurestore(name=name)
    print("Long running operation:", response.operation.name)
    delete_featurestore_response = response.result(timeout=timeout)
    print("delete_featurestore_response:", delete_featurestore_response)

Java

このサンプルを試す前に、Vertex AI クイックスタート: クライアント ライブラリの使用にある Java の設定手順を完了してください。詳細については、Vertex AI Java API のリファレンス ドキュメントをご覧ください。

Vertex AI に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証を設定するをご覧ください。


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1.DeleteFeaturestoreRequest;
import com.google.cloud.aiplatform.v1.DeleteOperationMetadata;
import com.google.cloud.aiplatform.v1.FeaturestoreName;
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 DeleteFeaturestoreSample {

  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";
    boolean useForce = true;
    String location = "us-central1";
    String endpoint = "us-central1-aiplatform.googleapis.com:443";
    int timeout = 60;
    deleteFeaturestoreSample(project, featurestoreId, useForce, location, endpoint, timeout);
  }

  static void deleteFeaturestoreSample(
      String project,
      String featurestoreId,
      boolean useForce,
      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)) {

      DeleteFeaturestoreRequest deleteFeaturestoreRequest =
          DeleteFeaturestoreRequest.newBuilder()
              .setName(FeaturestoreName.of(project, location, featurestoreId).toString())
              .setForce(useForce)
              .build();

      OperationFuture<Empty, DeleteOperationMetadata> operationFuture =
          featurestoreServiceClient.deleteFeaturestoreAsync(deleteFeaturestoreRequest);
      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 Featurestore.");
    }
  }
}

Node.js

このサンプルを試す前に、Vertex AI クライアント ライブラリをインストールするにある Node.js の設定手順を完了してください。詳細については、Vertex AI Node.js API のリファレンス ドキュメントをご覧ください。

Vertex AI に対する認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証を設定するをご覧ください。

/**
 * 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 force = <BOOLEAN>;
// 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 deleteFeaturestore() {
  // Configure the name resource
  const name = `projects/${project}/locations/${location}/featurestores/${featurestoreId}`;

  const request = {
    name: name,
    force: Boolean(force),
  };

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

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

次のステップ