Mengelola featurestore

Pelajari cara membuat, mencantumkan, mendeskripsikan, memperbarui, dan menghapus featurestores. Featurestore adalah container level teratas untuk jenis entity, fitur, dan nilai fitur.

Penyimpanan online dan offline

Vertex AI Feature Store (Lama) menggunakan dua metode penyimpanan yang diklasifikasikan sebagai penyimpanan online dan penyimpanan offline, yang harganya berbeda. Semua featurestore memiliki penyimpanan offline dan penyimpanan online (opsional).

Penyimpanan online mempertahankan nilai stempel waktu terbaru fitur Anda untuk menangani permintaan penyaluran online secara efisien. Saat menjalankan tugas impor menggunakan API, Anda dapat mengontrol tugas tersebut jika data ditulis ke toko online. Melewatkan penyimpanan online akan mencegah beban apa pun pada node penyaluran online. Misalnya, saat menjalankan tugas pengisian ulang, Anda dapat menonaktifkan penulisan ke penyimpanan online dan hanya menulis ke penyimpanan offline. Untuk mengetahui informasi selengkapnya, lihat flag disableOnlineServing dalam referensi API.

Vertex AI Feature Store (Lama) menggunakan penyimpanan offline untuk menyimpan data hingga data mencapai batas retensi atau hingga Anda menghapus data. Anda dapat menyimpan data tanpa batas di penyimpanan offline. Anda dapat mengontrol biaya penyimpanan offline dengan mengelola jumlah data yang disimpan. Anda juga dapat mengganti batas retensi data penyimpanan online default untuk featurestore dan batas retensi data offline untuk jenis entitas. Pelajari kuota dan batas Vertex AI Feature Store (Lama) lebih lanjut.

Gunakan konsol Google Cloud untuk melihat jumlah penyimpanan online dan offline yang Anda gunakan saat ini. Lihat metrik pemantauan Total penyimpanan online dan Total penyimpanan offline dari featurestore Anda untuk menentukan penggunaan Anda.

Node penyaluran online

Node penyaluran online menyediakan resource komputasi yang digunakan untuk menyimpan dan menyalurkan nilai fitur untuk penyaluran online berlatensi rendah. Node ini selalu berjalan meskipun tidak menyajikan data. Anda dikenai biaya untuk setiap jam kerja node.

Batas penyimpanan untuk node penyaluran online adalah 5 TB per node. Pelajari kuota dan batas Vertex AI Feature Store (Lama) lebih lanjut.

Jumlah node penyaluran online yang Anda perlukan berbanding lurus dengan dua faktor berikut:

  • Jumlah permintaan penyaluran online (kueri per detik) yang diterima featurestore.
  • Jumlah tugas impor yang menulis ke penyimpanan online.

Kedua faktor ini berkontribusi pada penggunaan CPU dan performa node. Dari konsol Google Cloud, lihat metrics berikut:

  • Kueri per detik: Jumlah kueri per detik ke featurestore Anda.
  • Jumlah node: Jumlah node penyaluran online Anda.
  • Pemakaian CPU: Pemakaian CPU node Anda.

Jika penggunaan CPU selalu tinggi, pertimbangkan untuk meningkatkan jumlah node penyaluran online untuk featurestore Anda.

Menguji performa node penyaluran online

Anda dapat menguji performa node penyaluran online untuk penyajian fitur real-time. Hal ini memungkinkan Anda memastikan bahwa featurestore memiliki resource mesin yang cukup untuk dijalankan dalam QPS atau batas latensi yang telah ditentukan. Anda dapat melakukan pengujian ini berdasarkan berbagai parameter tolok ukur, seperti QPS, latensi, dan API. Untuk mengetahui panduan dan praktik terbaik dalam menguji performa node penyaluran online, lihat Menguji performa node penyaluran online untuk penyaluran real-time di Praktik terbaik untuk Vertex AI Feature Store (Lama).

Selain itu, Anda dapat menggunakan alat open source Vertex AI Benchmarker untuk menguji performa resource penyimpanan fitur Anda. Alat open source Vertex AI Benchmarker terdiri atas alat command line Python dan worker Java.

Opsi Penskalaan

Anda dapat beralih di antara opsi berikut untuk mengonfigurasi jumlah node penyaluran online:

  • Penskalaan otomatis

    Jika Anda memilih penskalaan otomatis, featurestore akan otomatis mengubah jumlah node berdasarkan pemakaian CPU. Penskalaan otomatis meninjau pola traffic untuk mempertahankan performa dan mengoptimalkan biaya dengan menambahkan node saat traffic meningkat dan menghapus node saat traffic berkurang.

    Penskalaan otomatis berperforma baik untuk pola traffic yang mengalami pertumbuhan dan penurunan bertahap. Jika Anda menggunakan Vertex AI Feature Store (Lama) secara ekstensif untuk pola traffic yang sering mengalami fluktuasi beban, gunakan penskalaan otomatis untuk meningkatkan efisiensi biaya.

  • Mengalokasikan jumlah node tetap

    Jika Anda mengalokasikan jumlah node tetap, Vertex AI Feature Store (Lama) mempertahankan jumlah node yang konsisten, terlepas dari pola traffic-nya. Jumlah node tetap membuat biaya dapat diprediksi, dan node harus berperforma baik jika ada cukup node untuk menangani traffic. Anda dapat mengubah jumlah node tetap secara manual untuk menangani perubahan pola lalu lintas.

Pertimbangan tambahan untuk penskalaan otomatis

Jika Anda memilih penskalaan otomatis, ada empat poin tambahan yang perlu dipertimbangkan yang meliputi:

  • Setelah menambahkan node penyaluran online, penyimpanan online memerlukan waktu untuk menyeimbangkan kembali data tersebut. Perlu waktu hingga 20 menit dalam pemuatan sebelum Anda melihat peningkatan performa yang signifikan. Akibatnya, menskalakan jumlah node mungkin tidak membantu untuk burst traffic yang singkat. Batasan ini berlaku untuk penskalaan manual dan penskalaan otomatis.

  • Jika Anda mengirimkan permintaan penyaluran online ke featurestore tanpa node penyaluran online, operasi akan menampilkan error.

Menonaktifkan penyaluran online di featurestore Anda

Jika Anda tidak memerlukan penyaluran online dan ingin mencegah perubahan yang timbul pada node penyaluran online, tetapkan jumlah node penyaluran online ke nol. Untuk menonaktifkan penyaluran online di featurestore Anda, tetapkan konfigurasi berikut:

  1. Jika Anda menggunakan penskalaan otomatis, hapus parameter scaling.

  2. Tetapkan jumlah tetap node penyaluran online ke 0.

Untuk informasi selengkapnya tentang cara membuat featurestore, lihat Membuat featurestore. Untuk informasi selengkapnya tentang cara mengubah konfigurasi featurestore yang ada, lihat Mengupdate featurestore.

Jika Anda menetapkan jumlah node penyaluran online ke 0, seluruh penyimpanan online, termasuk datanya, akan dihapus. Jika Anda ingin menonaktifkan toko online untuk sementara lalu memulihkannya, Anda harus mengimpor ulang data yang dihapus.

Misalnya, jika Anda menetapkan jumlah node penyaluran online untuk featurestore ke 0, lalu menyediakan node penyaluran online dengan menyetel jumlah node ke 1 atau lebih tinggi, Vertex AI Feature Store (Lama) tidak akan memigrasikan menghapus data fitur ke toko {i>online<i}. Untuk mengisi ulang toko online, Anda harus mengimpor ulang data Anda. Salah satu cara untuk mengimpor ulang data Anda adalah dengan mengekspor data historis sebelum Anda menonaktifkan node penayangan online, lalu mengimpor data yang diekspor setelah Anda menyediakan node.

Saat menyediakan node penayangan online, Anda harus menunggu hingga operasi selesai sebelum mengimpor data baru. Tugas impor yang sedang berlangsung akan dilanjutkan, hanya setelah penyediaan node penayangan online selesai.

Jika Anda mengirimkan permintaan penyaluran online ke featurestore tanpa node penyaluran online, permintaan tersebut akan menampilkan error.

Membuat featurestore

Membuat resource featurestore untuk memuat jenis dan fitur entity. Lokasi featurestore Anda harus berada di lokasi yang sama dengan data sumber. Misalnya, jika featurestore Anda berada di us-central,, Anda dapat mengimpor data dari file dalam bucket Cloud Storage yang berada di us-central1 atau di lokasi multi-region AS, meskipun data sumber dari bucket dual-region tidak didukung. Demikian pula untuk BigQuery, Anda dapat mengimpor data dari tabel yang ada di us-central1 atau di lokasi multi-region AS. Untuk mengetahui informasi selengkapnya, lihat Persyaratan data sumber.

Ketersediaan Vertex AI Feature Store (Lama) dapat bervariasi berdasarkan lokasi. Untuk informasi selengkapnya, lihat Ketersediaan fitur.

UI Web

Anda dapat membuat featurestore menggunakan Google Cloud Console jika featurestore belum dibuat di project Google Cloud untuk region yang dipilih. Jika featurestore sudah ada untuk project dan region, gunakan metode lain.

Untuk membuat featurestore menggunakan Konsol Google Cloud:

  1. Di bagian Vertex AI pada Konsol Google Cloud, buka halaman Features.

    Buka halaman Fitur

  2. Klik Buat featurestore
  3. Tentukan nama untuk featurestore.
  4. Jika Anda ingin mengaktifkan penyaluran online untuk featurestore, klik tombol Turn on onlineserving dan setel opsi penskalaan.
    Untuk mengetahui informasi selengkapnya tentang opsi penskalaan dan penyaluran online, lihat Node penyaluran online
  5. Klik Create.

Terraform

Contoh berikut menggunakan resource Terraform google_vertex_ai_featurestore untuk membuat featurestore dengan jumlah node tetap. Nama featurestore adalah featurestore_xxxxxxxx, dengan xxxxxxxx adalah ID alfanumerik yang dibuat secara acak.

Untuk mempelajari cara menerapkan atau menghapus konfigurasi Terraform, lihat Perintah dasar 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

Untuk membuat featurestore, kirim permintaan POST menggunakan metode featurestores.create.

Contoh berikut membuat featurestore dengan jumlah node tetap 1. Jumlah node menentukan jumlah node penyaluran online, yang memengaruhi jumlah permintaan penyaluran online yang dapat ditangani featurestore. Latensi dapat meningkat jika jumlah node tidak dapat mendukung jumlah permintaan yang masuk.

Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:

  • LOCATION_ID: Region tempat featurestore dibuat. Contoh, us-central1.
  • PROJECT_ID: Project ID Anda.
  • FEATURESTORE_ID: ID untuk featurestore.

Metode HTTP dan URL:

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

Isi JSON permintaan:

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

Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:

curl

Simpan isi permintaan dalam file bernama request.json, dan jalankan perintah berikut:

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

Simpan isi permintaan dalam file bernama request.json, dan jalankan perintah berikut:

$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

Anda akan melihat output yang mirip dengan berikut ini: Anda dapat menggunakan OPERATION_ID sebagai respons untuk mendapatkan status operasi.

{
"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

Untuk mempelajari cara menginstal atau mengupdate Vertex AI SDK untuk Python, lihat Menginstal Vertex AI SDK untuk Python. Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi 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

Library klien untuk Vertex AI disertakan saat Anda menginstal Vertex AI SDK untuk Python. Guna mempelajari cara menginstal Vertex AI SDK untuk Python, lihat Menginstal Vertex AI SDK untuk Python. Untuk mengetahui informasi selengkapnya, lihat Dokumentasi referensi API Vertex AI SDK untuk Python.

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

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Java di Panduan memulai Vertex AI menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat Dokumentasi referensi API Java Vertex AI.

Untuk melakukan autentikasi ke Vertex AI, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1beta1.CreateFeaturestoreOperationMetadata;
import com.google.cloud.aiplatform.v1beta1.CreateFeaturestoreRequest;
import com.google.cloud.aiplatform.v1beta1.Featurestore;
import com.google.cloud.aiplatform.v1beta1.Featurestore.OnlineServingConfig;
import com.google.cloud.aiplatform.v1beta1.Featurestore.OnlineServingConfig.Scaling;
import com.google.cloud.aiplatform.v1beta1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1beta1.FeaturestoreServiceSettings;
import com.google.cloud.aiplatform.v1beta1.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

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Node.js di Panduan memulai Vertex AI menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat Dokumentasi referensi API Node.js Vertex AI.

Untuk melakukan autentikasi ke Vertex AI, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

/**
 * 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();

Membuat featurestore yang menggunakan CMEK

Sebelum memulai, jika Anda belum memiliki CMEK (kunci enkripsi yang dikelola pelanggan), gunakan Cloud Key Management Service untuk mengonfigurasi kunci enkripsi yang dikelola pelanggan dan menyiapkan izin. Contoh berikut membuat featurestore yang menggunakan kunci CMEK.

Jika Vertex AI kehilangan izin ke kunci CMEK terkait, resource dan nilai apa pun dalam featurestore yang dienkripsi oleh kunci tersebut tidak akan dapat diakses hingga Vertex AI dapat menggunakan kunci tersebut lagi.

Setelah 30 hari, jika Vertex AI masih tidak memiliki akses ke kunci CMEK, Vertex AI akan menghapus semua featurestore yang dienkripsi dengan kunci tersebut. Saat membuat featurestore baru, Anda tidak dapat menggunakan kembali nama featurestore tersebut.

UI Web

Gunakan metode lain. Anda tidak dapat membuat featurestore dari Konsol Google Cloud.

REST

Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:

  • LOCATION_ID: Region tempat featurestore dibuat. Contoh, us-central1.
  • PROJECT_ID: Project ID Anda.
  • FEATURESTORE_ID: ID untuk featurestore.
  • CMEK_PROJECT: Project ID atau nomor project yang berisi CMEK Anda.
  • KEY_RING: Nama key ring Cloud Key Management Service tempat kunci enkripsi Anda aktif.
  • KEY_NAME: Nama kunci enkripsi yang akan digunakan.

Metode HTTP dan URL:

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

Isi JSON permintaan:

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

Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:

curl

Simpan isi permintaan dalam file bernama request.json, dan jalankan perintah berikut:

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

Simpan isi permintaan dalam file bernama request.json, dan jalankan perintah berikut:

$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

Anda akan melihat output yang mirip dengan berikut ini: Anda dapat menggunakan OPERATION_ID sebagai respons untuk mendapatkan status operasi.

{
"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"
    }
  }
}

Mencantumkan featurestore

Mencantumkan semua featurestore dalam sebuah project.

UI web

  1. Di bagian Vertex AI pada Konsol Google Cloud, buka halaman Features.

    Buka halaman Fitur

  2. Pilih region dari menu drop-down Region.
  3. Di tabel fitur, lihat kolom Featurestore untuk melihat featurestore di project Anda untuk region yang dipilih.

REST

Untuk mencantumkan featurestore untuk region tertentu dalam project Anda, kirim permintaan GET menggunakan metode featurestores.list.

Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:

  • LOCATION_ID: Region tempat featurestore berada, seperti us-central1.
  • PROJECT_ID: Project ID Anda.

Metode HTTP dan URL:

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

Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:

curl

Jalankan perintah berikut:

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

Jalankan perintah berikut:

$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

Anda akan menerima respons JSON yang mirip seperti berikut:

{
  "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

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Java di panduan memulai Vertex AI menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat Dokumentasi referensi API Java Vertex AI.

Untuk melakukan autentikasi ke Vertex AI, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.


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

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Node.js di Panduan memulai Vertex AI menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat Dokumentasi referensi API Node.js Vertex AI.

Untuk melakukan autentikasi ke Vertex AI, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

/**
 * 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();

Bahasa tambahan

Untuk mempelajari cara menginstal dan menggunakan Vertex AI SDK untuk Python, lihat Menggunakan Vertex AI SDK untuk Python. Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi API Vertex AI SDK untuk Python.

Melihat detail featurestore

Mendapatkan detail tentang featurestore seperti nama dan konfigurasi penyaluran onlinenya. Jika menggunakan konsol Google Cloud, Anda juga dapat melihat metrik Cloud Monitoring untuk featurestore.

UI web

  1. Di bagian Vertex AI pada Konsol Google Cloud, buka halaman Features.

    Buka halaman Fitur

  2. Pilih region dari menu drop-down Region.
  3. Di tabel fitur, lihat kolom Featurestore, lalu temukan featurestore yang ingin Anda lihat informasinya.
  4. Klik nama featurestore untuk melihat metrik Monitoring-nya.
  5. Klik tab Properties untuk melihat konfigurasi penyaluran online featurestore.

REST

Untuk mendapatkan detail tentang satu featurestore, kirim permintaan GET menggunakan metode featurestores.get.

Sebelum menggunakan salah satu data permintaan, lakukan proses penggantian berikut:

  • LOCATION_ID: Region tempat featurestore berada, seperti us-central1.
  • PROJECT_ID: Project ID Anda.
  • FEATURESTORE_ID: ID featurestore.

Metode HTTP dan URL:

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

Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:

curl

Jalankan perintah berikut:

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

Jalankan perintah berikut:

$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

Anda akan menerima respons JSON yang mirip seperti berikut:

{
  "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

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Java di panduan memulai Vertex AI menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat Dokumentasi referensi API Java Vertex AI.

Untuk melakukan autentikasi ke Vertex AI, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.


import com.google.cloud.aiplatform.v1beta1.Featurestore;
import com.google.cloud.aiplatform.v1beta1.FeaturestoreName;
import com.google.cloud.aiplatform.v1beta1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1beta1.FeaturestoreServiceSettings;
import com.google.cloud.aiplatform.v1beta1.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

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Node.js di Panduan memulai Vertex AI menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat Dokumentasi referensi API Node.js Vertex AI.

Untuk melakukan autentikasi ke Vertex AI, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

/**
 * 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();

Bahasa tambahan

Untuk mempelajari cara menginstal dan menggunakan Vertex AI SDK untuk Python, lihat Menggunakan Vertex AI SDK untuk Python. Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi API Vertex AI SDK untuk Python.

Mengupdate featurestore

Memperbarui featurestore, misalnya, untuk mengubah jumlah node penyaluran online atau memperbarui label di featurestore.

UI Web

Anda hanya dapat memperbarui jumlah node penyaluran online. Untuk memperbarui label, gunakan API.

  1. Di bagian Vertex AI pada Konsol Google Cloud, buka halaman Features.

    Buka halaman Fitur

  2. Pilih region dari menu drop-down Region.
  3. Di tabel fitur, lihat kolom Featurestore, lalu klik nama featurestore untuk memperbarui.
  4. Klik Edit configuration untuk membuka panel Edit featurestore configuration.
  5. Mengedit konfigurasi featurestore.
  6. Klik Update untuk menerapkan perubahan.

REST

Untuk mengupdate featurestore, kirim permintaan PATCH menggunakan metode featurestores.patch.

Contoh berikut memperbarui jumlah node penyaluran online menjadi 2 untuk featurestore. Semua setelan lainnya tetap sama.

Sebelum menggunakan salah satu data permintaan, lakukan proses penggantian berikut:

  • LOCATION_ID: Region tempat featurestore berada, seperti us-central1.
  • PROJECT_ID: Project ID Anda.
  • FEATURESTORE_ID: ID featurestore.

Metode HTTP dan URL:

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

Isi JSON permintaan:

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

Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:

curl

Simpan isi permintaan dalam file bernama request.json, dan jalankan perintah berikut:

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

Simpan isi permintaan dalam file bernama request.json, dan jalankan perintah berikut:

$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

Anda akan melihat output yang mirip dengan berikut ini: Anda dapat menggunakan OPERATION_ID sebagai respons untuk mendapatkan status operasi.

{
"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

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Java di Panduan memulai Vertex AI menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat Dokumentasi referensi API Java Vertex AI.

Untuk melakukan autentikasi ke Vertex AI, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.


import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.aiplatform.v1beta1.Featurestore;
import com.google.cloud.aiplatform.v1beta1.Featurestore.OnlineServingConfig;
import com.google.cloud.aiplatform.v1beta1.Featurestore.OnlineServingConfig.Scaling;
import com.google.cloud.aiplatform.v1beta1.FeaturestoreName;
import com.google.cloud.aiplatform.v1beta1.FeaturestoreServiceClient;
import com.google.cloud.aiplatform.v1beta1.FeaturestoreServiceSettings;
import com.google.cloud.aiplatform.v1beta1.UpdateFeaturestoreOperationMetadata;
import com.google.cloud.aiplatform.v1beta1.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

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Node.js di Panduan memulai Vertex AI menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat Dokumentasi referensi API Node.js Vertex AI.

Untuk melakukan autentikasi ke Vertex AI, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

/**
 * 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();

Bahasa tambahan

Untuk mempelajari cara menginstal dan menggunakan Vertex AI SDK untuk Python, lihat Menggunakan Vertex AI SDK untuk Python. Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi API Vertex AI SDK untuk Python.

Menghapus featurestore

Menghapus featurestore. Jika featurestore menyertakan jenis dan fitur entity yang ada, aktifkan parameter kueri force untuk menghapus featurestore dan semua kontennya.

UI Web

Gunakan metode lain. Anda tidak dapat menghapus featurestore dari Google Cloud Console.

REST

Untuk menghapus featurestore dan semua kontennya, kirim permintaan DELETE menggunakan metode featurestores.delete.

Sebelum menggunakan salah satu data permintaan, lakukan penggantian berikut:

  • LOCATION_ID: Region tempat featurestore berada, seperti us-central1.
  • PROJECT_ID: Project ID Anda.
  • FEATURESTORE_ID: ID featurestore.
  • BOOLEAN: Apakah akan menghapus featurestore meskipun berisi jenis dan fitur entity. Parameter kueri force bersifat opsional dan false secara default.

Metode HTTP dan URL:

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

Untuk mengirim permintaan Anda, pilih salah satu opsi berikut:

curl

Jalankan perintah berikut:

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

Jalankan perintah berikut:

$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

Anda akan melihat respons JSON seperti berikut:

{
  "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

Untuk mempelajari cara menginstal atau mengupdate Vertex AI SDK untuk Python, lihat Menginstal Vertex AI SDK untuk Python. Untuk mengetahui informasi selengkapnya, lihat dokumentasi referensi 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

Library klien untuk Vertex AI disertakan saat Anda menginstal Vertex AI SDK untuk Python. Guna mempelajari cara menginstal Vertex AI SDK untuk Python, lihat Menginstal Vertex AI SDK untuk Python. Untuk mengetahui informasi selengkapnya, lihat Dokumentasi referensi API Vertex AI SDK untuk Python.

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

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Java di Panduan memulai Vertex AI menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat Dokumentasi referensi API Java Vertex AI.

Untuk melakukan autentikasi ke Vertex AI, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.


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

Sebelum mencoba contoh ini, ikuti petunjuk penyiapan Node.js di Panduan memulai Vertex AI menggunakan library klien. Untuk mengetahui informasi selengkapnya, lihat Dokumentasi referensi API Node.js Vertex AI.

Untuk melakukan autentikasi ke Vertex AI, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

/**
 * 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();

Langkah selanjutnya