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

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

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

ב-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 (Legacy)

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

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

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

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

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

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

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

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

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

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

  • התאמה אוטומטית לעומס

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

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

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

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

שיקולים נוספים לגבי התאמה אוטומטית לעומס

אם בוחרים באפשרות של התאמה אוטומטית לעומס (automatic scaling), יש עוד ארבע נקודות שכדאי לקחת בחשבון, כולל:

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

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

השבתת מילוי בקשה באופן מיידי בחנות התכונות

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

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

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

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

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

לדוגמה, אם הגדרתם את מספר צמתי מילוי הבקשה באופן מיידי של Feature Store ל-0 ואז הקציתם צמתי מילוי בקשה באופן מיידי על ידי הגדרת מספר הצמתים ל-1 ומעלה, Feature Store (גרסה קודמת) של 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. לוחצים על Create featurestore (יצירת מאגר תכונות).
  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. בוחרים אזור מהרשימה הנפתחת אזור.
  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 ואיך להשתמש בו. מידע נוסף מופיע במאמרי העזרה של ה-API בשפת Python של Vertex AI SDK.

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

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

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

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

    כניסה לדף Features

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

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

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

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

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

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

    כניסה לדף Features

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

מחיקת מאגר תכונות

מחיקת מאגר תכונות. אם מאגר הפיצ'רים כולל סוגים ותכונות קיימים של ישויות, מפעילים את פרמטר השאילתה 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();

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