設定執行作業快取

Gemini Enterprise Agent Platform Pipelines 執行管道時,會檢查 Vertex ML Metadata 中,是否已存在每個管道步驟的介面 (快取金鑰) 執行作業

步驟的介面定義為下列項目的組合:

  1. 管道步驟的輸入內容。這些輸入內容包括輸入參數的值 (如有) 和輸入構件 ID (如有)。

  2. 管道步驟的輸出定義。這項輸出定義包含輸出參數定義 (名稱,如有) 和輸出構件定義 (名稱,如有)。

  3. 元件規格。這項規格包含使用的映像檔、指令、引數和環境變數,以及指令和引數的順序。

此外,只有管道名稱相同的管道才會共用快取。

如果 Vertex ML Metadata 中有相符的執行作業,系統會使用該執行作業的輸出內容,並略過該步驟。這有助於略過先前管道執行中完成的運算,進而降低成本。

您可以設定下列項目,在工作層級關閉執行快取:

eval_task.set_caching_options(False)

您可以為整個管道工作關閉執行階段快取。使用 PipelineJob() 執行管道時,可以透過 enable_caching 引數指定這個管道執行作業不使用快取。管道工作中的所有步驟都不會使用快取。進一步瞭解如何建立管道執行作業

請使用下列範例關閉快取:

pl = PipelineJob(
    display_name="My first pipeline",

    # Whether or not to enable caching
    # True = enable the current run to use caching results from previous runs
    # False = disable the current run's use of caching results from previous runs
    # None = defer to cache option for each pipeline component in the pipeline definition
    enable_caching=False,

    # Local or Cloud Storage path to a compiled pipeline definition
    template_path="pipeline.yaml",

    # Dictionary containing input parameters for your pipeline
    parameter_values=parameter_values,

    # Cloud Storage path to act as the pipeline root
    pipeline_root=pipeline_root,
)

這項功能有以下限制:

  • 快取結果沒有存留時間 (TTL),只要項目未從 Vertex ML Metadata 刪除,即可重複使用。如果項目從 Vertex ML Metadata 刪除,工作就會重新執行,再次產生結果。