ניהול מאגרי תכונות

איך יוצרים, מציגים ברשימה, מתארים, מעדכנים ומוחקים מאגרי תכונות. מאגר פיצ'רים הוא קונטיינר ברמה העליונה שמכיל סוגי ישויות, תכונות וערכי תכונות.

אחסון אונליין ואופליין

ב-Vertex AI Feature Store (גרסה קודמת) יש שתי שיטות אחסון שמסווגות כאחסון אונליין ואחסון אופליין, והמחירים שלהן שונים. לכל מאגרי התכונות יש אחסון אופליין, ואפשרות לאחסון אונליין.

האחסון אונליין שומר את ערכי חותמות הזמן האחרונים של התכונות כדי לטפל ביעילות בבקשות להצגת מודעות אונליין. כשמריצים עבודת ייבוא באמצעות ה-API, אפשר לשלוט בעבודה אם הנתונים נכתבים בחנות אונליין. דילוג על החנות הווירטואלית מונע טעינה של צמתים להצגה באינטרנט. לדוגמה, כשמריצים משימות של מילוי חוסרים, אפשר להשבית את הכתיבה לחנות אונליין ולכתוב רק לחנות אופליין. מידע נוסף מופיע בקטע בנושא הדגל disableOnlineServing במאמרי העזרה של ה-API.

מאגר התכונות של Vertex AI (גרסה קודמת) משתמש באחסון אופליין כדי לאחסן נתונים עד שהנתונים מגיעים למגבלת השמירה או עד שמוחקים את הנתונים. אתם יכולים לאחסן נתונים ללא הגבלה במאגר האופליין. אתם יכולים לשלוט בעלויות של אחסון במצב אופליין על ידי ניהול כמות הנתונים שאתם שומרים. אפשר גם לבטל את מגבלת ברירת המחדל של שמירת נתונים בחנות הפיצ'רים באינטרנט, ואת מגבלת שמירת הנתונים אופליין לסוג ישות. מידע נוסף על מכסות ומגבלות ב-Vertex AI Feature Store (גרסה קודמת)

בעזרת מסוף Google Cloud אפשר לראות כמה נפח אחסון אונליין ואופליין אתם מנצלים. כדי לקבוע את השימוש שלכם, תוכלו לצפות במדדי המעקב Total online storage ו-Total offline storage של מאגר התכונות.

צמתים של מילוי בקשות אונליין

צמתי ההגשה אונליין מספקים את משאבי החישוב שמשמשים לאחסון ולהגשה של ערכי תכונות בהגשה אונליין עם זמן אחזור נמוך. הצמתים האלה פועלים תמיד, גם כשהם לא משרתים נתונים. החיוב מתבצע על כל שעת שימוש בצומת.

מגבלת האחסון לצמתים של שרתים אונליין היא 5TB לכל צומת. מידע נוסף על מכסות ומגבלות ב-Vertex AI Feature Store (גרסה קודמת)

מספר הצמתים להצגת מודעות אונליין שנדרשים לכם פרופורציונלי ישירות לשני הגורמים הבאים:

  • מספר הבקשות להצגת מודעות אונליין (שאילתות לשנייה) שמאגר התכונות מקבל.
  • מספר משימות הייבוא שכותבות לאחסון אונליין.

שני הגורמים האלה משפיעים על ניצול המעבד ועל הביצועים של הצמתים. במסוף Google Cloud , אפשר לראות את המדדים של:

  • שאילתות לשנייה: מספר השאילתות לשנייה שמופנות אל מאגר התכונות.
  • מספר הצמתים: מספר הצמתים שלכם להצגת מודעות באינטרנט.
  • ניצול המעבד: ניצול המעבד של הצמתים.

אם ניצול המעבד (CPU) גבוה באופן עקבי, כדאי להגדיל את מספר הצמתים המקוונים של שרתים עבור מאגר התכונות.

בדיקת הביצועים של צמתים להצגת מודעות אונליין

אתם יכולים לבדוק את הביצועים של צמתי הצגה אונליין של תכונות בזמן אמת. כך תוכלו לוודא שיש למאגר הפיצ'רים מספיק משאבי מכונה כדי לפעול בתוך סף QPS או סף זמן האחזור שנקבעו מראש. אתם יכולים לבצע את הבדיקות האלה על סמך פרמטרים שונים להשוואה, כמו QPS, זמן אחזור ו-API. להנחיות ושיטות מומלצות לבדיקת הביצועים של צמתים למילוי בקשה באופן מיידי, ראו בדיקת הביצועים של צמתים למילוי בקשה באופן מיידי למילוי בקשה בזמן אמת בשיטות מומלצות ל-Vertex AI Feature Store (גרסה קודמת).

בנוסף, אתם יכולים להשתמש בכלי קוד פתוח Vertex AI Benchmarker כדי לבצע בדיקת עומס על הביצועים של משאבי מאגר התכונות. הכלי Vertex AI Benchmarker בקוד פתוח מורכב מכלי שורת פקודה ב-Python ומעובד Java.

אפשרויות שינוי גודל

אתם יכולים לעבור בין האפשרויות הבאות כדי להגדיר את מספר הצמתים להצגת מודעות אונליין:

  • שינוי גודל אוטומטי

    אם בוחרים באפשרות של התאמה אוטומטית לעומס, מאגר הפיצ'רים משנה אוטומטית את מספר הצמתים על סמך ניצול המעבד. מערכת הגידול האוטומטי של הקיבולת בודקת את דפוסי התנועה כדי לשמור על הביצועים ולבצע אופטימיזציה של העלויות. היא מוסיפה צמתים כשהתנועה גדלה ומסירה צמתים כשהתנועה קטנה.

    שינוי גודל אוטומטי מתאים לדפוסי תנועה שבהם יש עלייה וירידה הדרגתיות. אם אתם משתמשים ב-Vertex AI Feature Store (גרסה קודמת) באופן נרחב כדי לנתח דפוסי תנועה שחווים תנודות תכופות בעומס, כדאי להשתמש בהתאמת קנה מידה אוטומטית כדי לשפר את היעילות מבחינת עלויות.

  • הקצאת מספר קבוע של צמתים

    אם מקצים מספר קבוע של צמתים, Vertex AI Feature Store (גרסה קודמת) שומר על מספר עקבי של צמתים ללא קשר לדפוסי התנועה. מספר הצמתים הקבוע מאפשר לחזות את העלויות, והצמתים אמורים לפעול בצורה טובה אם יש מספיק צמתים לטיפול בתנועה. אתם יכולים לשנות ידנית את מספר הצמתים הקבוע כדי לטפל בשינויים בדפוסי התנועה.

שיקולים נוספים לגבי שינוי גודל אוטומטי

אם בוחרים באפשרות של שינוי גודל אוטומטי, יש עוד ארבע נקודות שכדאי לקחת בחשבון, כולל:

  • אחרי שמוסיפים צמתים למילוי בקשה באופן מיידי, חנות אונליין צריכה זמן כדי לאזן מחדש את הנתונים. יכולות לחלוף עד 20 דקות בעומס לפני שרואים שיפור משמעותי בביצועים. לכן, הגדלת מספר הצמתים לא תעזור במקרים של פרצי תנועה קצרים. המגבלה הזו חלה גם על שינוי גודל ידני וגם על שינוי גודל אוטומטי.

  • אם שולחים בקשות להצגת תכונות אונליין למאגר התכונות בלי צמתים להצגת תכונות אונליין, הפעולה מחזירה שגיאה.

השבתת הצגת תכונות אונליין בחנות התכונות

אם אינכם זקוקים למילוי בקשה באופן מיידי וברצונכם למנוע חיובים עבור צמתים של מילוי בקשה באופן מיידי, הגדירו את מספר הצמתים של מילוי בקשה באופן מיידי לאפס. כדי להשבית את ההצגה אונליין בחנות התכונות, מגדירים את ההגדרה הבאה:

  1. אם אתם משתמשים בהתאמת קנה מידה אוטומטית, צריך להסיר את הפרמטר scaling.

  2. מגדירים את המספר הקבוע של צמתים להצגת מודעות אונליין ל-0.

מידע נוסף על יצירת מאגר פיצ'רים זמין במאמר בנושא יצירת מאגר פיצ'רים. במאמר עדכון של מאגר תכונות מוסבר איך לשנות את ההגדרה של מאגר תכונות קיים.

אם מגדירים את מספר הצמתים למילוי בקשה באופן מיידי ל-0, כל החנות אונליין, כולל הנתונים שלה, נמחקת. אם רוצים להשבית זמנית את החנות הווירטואלית ואז לשחזר אותה, צריך לייבא מחדש את הנתונים שנמחקו.

לדוגמה, אם הגדרתם את מספר צמתי ההצגה אונליין של מאגר התכונות ל-0 ואז הקציתם צמתי הצגה אונליין על ידי הגדרת מספר הצמתים ל-1 או יותר, מאגר התכונות (מאגר ישן) של Vertex AI לא מעביר את נתוני התכונות שנמחקו למאגר אונליין. כדי לאכלס מחדש את חנות האונליין, צריך לייבא מחדש את הנתונים. אחת הדרכים לייבא מחדש את הנתונים היא לייצא את הנתונים ההיסטוריים לפני שמשביתים את צמתי מילוי הבקשה באופן מיידי, ואז לייבא את הנתונים המיוצאים אחרי הקצאת הצמתים.

כשמפעילים צמתים להצגת מודלים אונליין, צריך להמתין עד שהפעולה תושלם לפני שמייבאים נתונים חדשים. תהליכי ייבוא שנמצאים בעיצומם יתחדשו רק אחרי שהקצאת המשאבים של צומת מילוי הבקשה באופן מיידי תושלם.

אם שולחים בקשה להצגת תכונות אונליין למאגר התכונות בלי צמתים להצגת תכונות אונליין, הבקשה מחזירה שגיאה.

יצירת מאגר פיצ'רים

יוצרים משאב של מאגר תכונות שיכיל סוגי ישויות ותכונות. המיקום של מאגר הפיצ'רים צריך להיות זהה למיקום של נתוני המקור. לדוגמה, אם מאגר הפיצ'רים נמצא ב-us-central,, אפשר לייבא נתונים מקבצים בקטגוריות של Cloud Storage שנמצאות ב-us-central1 או במיקום בארה"ב שמכסה מספר אזורים, אבל אי אפשר לייבא נתוני מקור מקטגוריות שמכסות שני אזורים. באופן דומה, ב-BigQuery אפשר לייבא נתונים מטבלאות שנמצאות ב-us-central1 או במיקום במספר אזורים בארה"ב. מידע נוסף זמין במאמר בנושא דרישות לגבי נתוני המקור.

הזמינות של Vertex AI Feature Store (גרסה מדור קודם) עשויה להשתנות בהתאם למיקום. מידע נוסף זמין במאמר בנושא זמינות התכונות.

ממשק משתמש באינטרנט

אפשר ליצור מאגר פיצ'רים באמצעות המסוף Google Cloud אם עדיין לא נוצר מאגר פיצ'רים בפרויקט Google Cloud עבור האזור שנבחר. אם מאגר התכונות כבר קיים בפרויקט ובאזור, צריך להשתמש בשיטה אחרת.

כדי ליצור מאגר פיצ'רים באמצעות המסוף Google Cloud :

  1. בקטע Vertex AI במסוף Google Cloud , עוברים לדף Features.

    כניסה לדף Features

  2. לוחצים על יצירת מאגר פיצ'רים.
  3. מציינים שם למאגר הפיצ'רים.
  4. אם רוצים להפעיל את האפשרות להצגת תכונות אונליין במאגר התכונות, לוחצים על המתג הפעלה של הצגת תכונות אונליין ומגדירים את אפשרויות ההתאמה.
    מידע נוסף על אפשרויות של מילוי בקשה באופן מיידי ושינוי קנה מידה זמין במאמר בנושא צמתים למילוי בקשה באופן מיידי.
  5. לוחצים על יצירה.

Terraform

בדוגמה הבאה נעשה שימוש במשאב google_vertex_ai_featurestore של Terraform כדי ליצור מאגר פיצ'רים עם מספר קבוע של צמתים. השם של מאגר התכונות הוא featurestore_yyyyyyyy, כאשר yyyyyyyy הוא מזהה אלפאנומרי שנוצר באופן אקראי.

כדי ללמוד איך להחיל הגדרות ב-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

כדי ליצור מאגר פיצ'רים, שולחים בקשת POST באמצעות השיטה featurestores.create.

בדוגמה הבאה נוצר מאגר פיצ'רים עם מספר קבוע של צמתים, 1. מספר הצמתים מציין את מספר הצמתים המקוונים להצגת תכונות, שמשפיע על מספר הבקשות המקוונות להצגת תכונות שמאגר התכונות יכול לטפל בהן. זמן האחזור עלול להתארך אם מספר הצמתים לא יכול לתמוך במספר הבקשות הנכנסות.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • LOCATION_ID: האזור שבו מאגר התכונות נוצר. לדוגמה, us-central1.
  • PROJECT_ID: מזהה הפרויקט.
  • FEATURESTORE_ID: מזהה של מאגר התכונות.

ה-method של ה-HTTP וכתובת ה-URL:

POST https://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 \
"https://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 "https://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 ל-Python מוסבר איך להתקין או לעדכן את Vertex AI SDK ל-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

Java

לפני שמנסים את הדוגמה הזו, צריך לפעול לפי Javaההוראות להגדרה במאמר Vertex AI quickstart using client libraries. מידע נוסף מופיע במאמרי העזרה של Vertex AI Java API.

כדי לבצע אימות ב-Vertex AI, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.


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

לפני שמנסים את הדוגמה הזו, צריך לפעול לפי Node.jsההוראות להגדרה במאמר Vertex AI quickstart using client libraries. מידע נוסף מופיע במאמרי העזרה של Vertex AI Node.js API.

כדי לבצע אימות ב-Vertex AI, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

/**
 * 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

לפני שמתחילים, אם אין לכם מפתח הצפנה בניהול הלקוח (CMEK), צריך להשתמש ב-Cloud Key Management Service כדי להגדיר מפתח הצפנה בניהול הלקוח ולהגדיר הרשאות. בדוגמה הבאה נוצר מאגר פיצ'רים שמשתמש במפתח CMEK.

אם ל-Vertex AI אין יותר הרשאה למפתח CMEK המשויך, לא תהיה יותר גישה למשאבים ולערכים במאגרי התכונות שהוצפנו באמצעות המפתח הזה, עד של-Vertex AI תהיה שוב אפשרות להשתמש במפתח.

אחרי 30 יום, אם ל-Vertex AI עדיין אין גישה למפתח ה-CMEK, ‏ Vertex AI מוחק את כל מאגרי התכונות שהוצפנו באמצעות המפתח הזה. כשיוצרים מאגרי תכונות חדשים, אי אפשר להשתמש שוב בשמות של מאגרי התכונות האלה.

ממשק משתמש באינטרנט

שימוש בשיטה אחרת. אי אפשר ליצור מאגר תכונות מ-Google Cloud console.

REST

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • LOCATION_ID: האזור שבו מאגר התכונות נוצר. לדוגמה, us-central1.
  • PROJECT_ID: .
  • FEATURESTORE_ID: מזהה של מאגר התכונות.
  • CMEK_PROJECT: מזהה הפרויקט או מספר הפרויקט שמכילים את מפתח ה-CMEK.
  • KEY_RING: השם של אוסף המפתחות ב-Cloud Key Management Service שבו נמצא מפתח ההצפנה.
  • KEY_NAME: השם של מפתח ההצפנה שרוצים להשתמש בו.

ה-method של ה-HTTP וכתובת ה-URL:

POST https://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 \
"https://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 "https://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"
    }
  }
}

הצגת רשימה של מאגרי תכונות

הצגת רשימה של כל מאגרי התכונות בפרויקט.

ממשק משתמש באינטרנט

  1. בקטע Vertex AI במסוף Google Cloud , עוברים לדף Features.

    כניסה לדף Features

  2. בוחרים אזור מהרשימה הנפתחת Region (אזור).
  3. בטבלת התכונות, מעיינים בעמודה Featurestore כדי לראות את מאגרי התכונות בפרויקט באזור שנבחר.

REST

כדי להציג רשימה של מאגרי תכונות באזור מסוים בפרויקט, שולחים בקשת GET באמצעות השיטה featurestores.list.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • LOCATION_ID: האזור שבו נמצא מאגר התכונות, למשל us-central1.
  • PROJECT_ID: .

ה-method של ה-HTTP וכתובת ה-URL:

GET https://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)" \
"https://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 "https://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

לפני שמנסים את הדוגמה הזו, צריך לפעול לפי Javaההוראות להגדרה במאמר Vertex AI quickstart using client libraries. מידע נוסף מופיע במאמרי העזרה של Vertex AI Java API.

כדי לבצע אימות ב-Vertex AI, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.


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

לפני שמנסים את הדוגמה הזו, צריך לפעול לפי Node.jsההוראות להגדרה במאמר Vertex AI quickstart using client libraries. מידע נוסף מופיע במאמרי העזרה של Vertex AI Node.js API.

כדי לבצע אימות ב-Vertex AI, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

/**
 * 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 ל-Python מוסבר איך להתקין את Vertex AI SDK ל-Python ואיך להשתמש בו. מידע נוסף מופיע במאמרי העזרה של Vertex AI SDK ל-Python API.

צפייה בפרטים של מאגר התכונות

קבלת פרטים על מאגר תכונות, כמו השם וההגדרה של ההצגה באינטרנט. אם אתם משתמשים במסוף Google Cloud , תוכלו גם לראות את המדדים של Cloud Monitoring עבור מאגרי תכונות.

ממשק משתמש באינטרנט

  1. בקטע Vertex AI במסוף Google Cloud , עוברים לדף Features.

    כניסה לדף Features

  2. בוחרים אזור מהרשימה הנפתחת Region (אזור).
  3. בטבלת התכונות, מעיינים בעמודה Featurestore ומחפשים את מאגר התכונות שרוצים להציג את המידע שלו.
  4. לוחצים על שם מאגר התכונות כדי לראות את מדדי המעקב שלו.
  5. לוחצים על הכרטיסייה Properties (מאפיינים) כדי לראות את ההגדרה של ההצגה אונליין של מאגר התכונות.

REST

כדי לקבל פרטים על מאגר תכונות יחיד, שולחים בקשת GET באמצעות השיטה featurestores.get.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • LOCATION_ID: האזור שבו נמצא מאגר התכונות, למשל us-central1.
  • PROJECT_ID: .
  • FEATURESTORE_ID: מזהה מאגר התכונות.

ה-method של ה-HTTP וכתובת ה-URL:

GET https://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)" \
"https://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 "https://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

לפני שמנסים את הדוגמה הזו, צריך לפעול לפי Javaההוראות להגדרה במאמר Vertex AI quickstart using client libraries. מידע נוסף מופיע במאמרי העזרה של Vertex AI Java API.

כדי לבצע אימות ב-Vertex AI, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.


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

לפני שמנסים את הדוגמה הזו, צריך לפעול לפי Node.jsההוראות להגדרה במאמר Vertex AI quickstart using client libraries. מידע נוסף מופיע במאמרי העזרה של Vertex AI Node.js API.

כדי לבצע אימות ב-Vertex AI, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

/**
 * 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 ל-Python מוסבר איך להתקין את Vertex AI SDK ל-Python ואיך להשתמש בו. מידע נוסף מופיע במאמרי העזרה של Vertex AI SDK ל-Python API.

עדכון של מאגר תכונות

לעדכן מאגר פיצ'רים, למשל כדי לשנות את מספר הצמתים של מילוי בקשה באופן מיידי או לעדכן תוויות במאגר פיצ'רים.

ממשק משתמש באינטרנט

אפשר לעדכן רק את מספר הצמתים להצגת מודעות אונליין. כדי לעדכן תוויות, צריך להשתמש ב-API.

  1. בקטע Vertex AI במסוף Google Cloud , עוברים לדף Features.

    כניסה לדף Features

  2. בוחרים אזור מהרשימה הנפתחת Region (אזור).
  3. בטבלת התכונות, מסתכלים על העמודה Featurestore ולוחצים על השם של מאגר התכונות שרוצים לעדכן.
  4. לוחצים על Edit configuration (עריכת ההגדרות) כדי לפתוח את החלונית Edit featurestore configuration (עריכת ההגדרות של מאגר התכונות).
  5. עורכים את ההגדרות של מאגר הפיצ'רים.
  6. לוחצים על עדכון כדי להחיל את השינויים.

REST

כדי לעדכן מאגר תכונות, שולחים בקשת PATCH באמצעות השיטה featurestores.patch.

בדוגמה הבאה, מספר הצמתים להצגת נתונים אונליין מתעדכן ל-2 במאגר התכונות. כל שאר ההגדרות יישארו ללא שינוי.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • LOCATION_ID: האזור שבו נמצא מאגר התכונות, למשל us-central1.
  • PROJECT_ID: .
  • FEATURESTORE_ID: מזהה מאגר התכונות.

ה-method של ה-HTTP וכתובת ה-URL:

PATCH https://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 \
"https://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 "https://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

לפני שמנסים את הדוגמה הזו, צריך לפעול לפי Javaההוראות להגדרה במאמר Vertex AI quickstart using client libraries. מידע נוסף מופיע במאמרי העזרה של Vertex AI Java API.

כדי לבצע אימות ב-Vertex AI, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.


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

לפני שמנסים את הדוגמה הזו, צריך לפעול לפי Node.jsההוראות להגדרה במאמר Vertex AI quickstart using client libraries. מידע נוסף מופיע במאמרי העזרה של Vertex AI Node.js API.

כדי לבצע אימות ב-Vertex AI, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

/**
 * 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 ל-Python מוסבר איך להתקין את Vertex AI SDK ל-Python ואיך להשתמש בו. מידע נוסף מופיע במאמרי העזרה של Vertex AI SDK ל-Python API.

מחיקת מאגר פיצ'רים

מחיקת מאגר פיצ'רים. אם מאגר התכונות כולל סוגי ישויות ותכונות קיימים, מפעילים את פרמטר השאילתה force כדי למחוק את מאגר התכונות ואת כל התוכן שלו.

ממשק משתמש באינטרנט

שימוש בשיטה אחרת. אי אפשר למחוק מאגר תכונות ממסוףGoogle Cloud .

REST

כדי למחוק מאגר תכונות ואת כל התוכן שלו, שולחים בקשת DELETE באמצעות השיטה featurestores.delete.

לפני שמשתמשים בנתוני הבקשה, צריך להחליף את הנתונים הבאים:

  • LOCATION_ID: האזור שבו נמצא מאגר התכונות, למשל us-central1.
  • PROJECT_ID: .
  • FEATURESTORE_ID: מזהה מאגר התכונות.
  • BOOLEAN: האם למחוק את מאגר הפיצ'רים גם אם הוא מכיל סוגי ישויות ותכונות. פרמטר השאילתה force הוא אופציונלי, וערך ברירת המחדל שלו הוא false.

ה-method של ה-HTTP וכתובת ה-URL:

DELETE https://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)" \
"https://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 "https://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 ל-Python מוסבר איך להתקין או לעדכן את Vertex AI SDK ל-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)

Java

לפני שמנסים את הדוגמה הזו, צריך לפעול לפי Javaההוראות להגדרה במאמר Vertex AI quickstart using client libraries. מידע נוסף מופיע במאמרי העזרה של Vertex AI Java API.

כדי לבצע אימות ב-Vertex AI, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.


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

לפני שמנסים את הדוגמה הזו, צריך לפעול לפי Node.jsההוראות להגדרה במאמר Vertex AI quickstart using client libraries. מידע נוסף מופיע במאמרי העזרה של Vertex AI Node.js API.

כדי לבצע אימות ב-Vertex AI, צריך להגדיר את Application Default Credentials. מידע נוסף זמין במאמר הגדרת אימות לסביבת פיתוח מקומית.

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

המאמרים הבאים