Gemini Enterprise Agent Platform Pipelines 的資源標籤

視元件、資源類型和 Google Cloud Pipeline Components SDK 版本而定,Agent Platform Pipelines 會自動將管道執行的標籤傳播至從 Google Cloud Pipeline Components 產生的資源,或要求您標記產生的資源。如果是使用者定義的元件,您必須撰寫元件程式碼,才能附加環境變數中的標籤。詳情請參閱「從使用者定義的元件產生的資源」。

自動加上標籤的資源

無論 Google Cloud 管道元件 SDK 版本為何,Agent Platform Pipelines 都會自動為下列資源加上標籤:

CustomJob 項資源

Agent Platform Pipelines 會自動將管道執行的標籤傳播至 CustomJob 資源。所有版本的 Google Cloud Pipeline Components SDK 都支援這項功能,包括下列元件:

在 Google Cloud Pipeline Components SDK 1.0.31 以上版本中,自動標記的資源

如果您使用 Google Cloud Pipeline Components SDK 1.0.31 以上版本,Agent Platform Pipelines 會自動為下列資源加上標籤:

BatchPredictionJob 項資源

如果您使用 Pipeline Components SDK 1.0.31 以上版本,Agent Platform Pipelines 會自動將標籤從管道執行作業傳播至 ModelBatchPredictOp 元件產生的 BatchPredictionJob 資源。 Google Cloud

Gemini Enterprise endpoint 資源

如果您使用 Google Cloud Pipeline Components SDK 1.0.31 以上版本,Agent Platform Pipelines 會自動將管道執行作業中的標籤,傳播至從 EndpointCreateOp 元件產生的 Gemini Enterprise API endpoint 資源。

HyperparameterTuningJob 項資源

如果您使用 Pipeline Components SDK 1.0.31 以上版本,Agent Platform Pipelines 會自動將標籤從管道執行作業傳播至 HyperparameterTuningJobRunOp 元件產生的 HyperparameterTuningJob 資源。 Google Cloud

Gemini Enterprise API 資料集資源

如果您使用 1.0.31 以上版本的 Google Cloud Pipeline Components SDK,Agent Platform Pipelines 會自動將標籤從管道執行作業傳播至下列 Gemini Enterprise API 元件產生的 Gemini Enterprise API 資料集資源:

Google Cloud BigQuery 工作資源

如果您使用 Google Cloud Pipeline Components SDK 1.0.31 以上版本,Agent Platform Pipelines 會自動將標籤從管道執行作業傳播至 Google Cloud 從任何 BigQuery ML 元件產生的 BigQuery Job 資源。

Google Cloud Managed Service for Apache Spark 工作資源

如果您使用 Google Cloud Pipeline Components SDK 1.0.31 以上版本,Agent Platform Pipelines 會自動將管道執行的標籤,從管道執行傳播至 Google Cloud Managed Service for Apache Spark 工作資源,這些資源是從任何 Managed Service for Apache Spark 元件產生。

TrainingPipelineModel 資源

如果您使用 Google Cloud Pipeline Components SDK 1.0.31 以上版本,Agent Platform Pipelines 會自動將標籤從管道執行作業傳播至下列 AutoML 元件產生的 TrainingPipelineModel 資源:

Google Cloud BigQuery 資料表資源

如果您使用 Google Cloud Pipeline Components SDK 1.0.31 以上版本,Agent Platform Pipelines 會自動從管道執行作業 Google Cloud BigQuery 資料表資源傳播標籤,這些資源是從 ForecastingPreprocessingOp 元件產生。

未自動加上標籤的資源

無論 Google Cloud Pipeline Components SDK 版本為何,Agent Platform Pipelines 都不會自動標記下列資源:

Google Cloud Dataflow 資源

Agent Platform Pipelines 不會自動標記 DataflowPythonJobOp 元件產生的 Dataflow 資源。您可以在程式碼中加入標記資源的指令。

使用下列程式碼範例,將帳單標籤從管道執行作業傳播至使用 DataflowPythonJobOp 元件產生的任何 Google Cloud Dataflow 資源:

  import argparse
  import apache_beam as beam
  ...
  def run(argv=None):
    parser = argparse.ArgumentParser()
    # Don't add `--labels` to the argument list, so that they will be passed to the pipeline_options 
    parser.add_argument('--input', )
    parser.add_argument('--output', )
  ...
    known_args, pipeline_args = parser.parse_known_args(argv)
    pipeline_options = PipelineOptions(pipeline_args)
    with beam.Pipeline(options=pipeline_options) as p:

從使用者定義的元件產生的資源

Agent Platform Pipelines 不會自動標記 Google Cloud 使用者定義元件產生的資源。您可以在程式碼中加入指令,從環境變數 VERTEX_AI_PIPELINES_RUN_LABELS 擷取標籤,並在執行階段將這些標籤附加至使用元件產生的 Google Cloud 資源。

環境變數 VERTEX_AI_PIPELINE_RUN_LABELS 包含 JSON 格式的標籤,以鍵/值組合表示。

例如:{ "label1_key": "label1_value", "label2_key": "label2_value", ...}

如果您使用適用於 Python 的 Agent Platform SDK,請在元件程式碼中使用下列程式碼範例,將標籤從環境變數傳播至元件產生的新資源:

import os
import json
from google.cloud import aiplatform

aiplatform.init(
  project='PROJECT_ID',
  location='LOCATION'
)

aiplatform.RESOURCE.create(
  ...
  json.loads(os.getenv("VERTEX_AI_PIPELINES_RUN_LABELS"))
)

更改下列內容:

  • PROJECT_ID:包含管道執行的 Google Cloud 專案。

  • LOCATION:管道執行的位置。

  • RESOURCE: Google Cloud 從元件產生的資源,例如 CustomJobModel

如要使用 Python 剖析環境變數,也可以使用 gcp_labels_util.attach_system_labels 公用程式。只有在您有權存取 Google Cloud 管道元件程式庫,且使用 Python 時,才能使用這項公用程式。詳情請參閱 GitHub 中的公用函式原始碼

不支援標籤的資源

Agent Platform Pipelines 不支援將帳單標籤傳播至下列資源:

機器學習中繼資料資源

系統會根據商店層級的機器學習中繼資料資源計費。您無法使用帳單標籤瞭解資源層級的費用。

Cloud Storage 資源

Agent Platform Pipelines 不會將帳單標籤傳播至 Cloud Storage 資源,例如 Cloud Storage bucket。

後續步驟