You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为Vertex AI Pipeline组件配置子网连接VPC内数据库

解决Vertex AI Pipeline组件配置子网连接VPC数据库的问题

你直接给组件传subnetwork_uri参数报错,是因为这个组件的定义里没把子网作为输入参数暴露出来。要让组件使用指定子网,得通过设置组件的运行时执行配置来修改workerPoolSpecs,而不是给组件本身传参。

正确配置方式

修改你的Pipeline代码,在组件实例上调用set_execution_options(),传入包含子网信息的worker_pool_specs:

preprocess_data_op = component_store.load_component('org/ml_engine/preprocess')

@dsl.pipeline(name="test-pipeline-vertex-ai")
def pipeline(project_id: str, some_param: str):
    # 创建组件任务实例
    preprocess_task = preprocess_data_op(
        project_id=project_id,
        my_param=some_param,
    ).set_display_name("Preprocess data")
    
    # 配置子网到worker池规格
    preprocess_task.set_execution_options(
        dsl.ExecutionOptions(
            worker_pool_specs=[
                {
                    "machine_spec": {
                        "machine_type": "n1-standard-4"  # 替换为你实际使用的机器类型
                    },
                    "subnetwork_uri": "projects/xxxxxxxxx/global/networks/data"  # 你的子网URI
                }
            ]
        )
    )

注意事项

  • machine_spec.machine_type必须填写组件实际使用的机器类型,不能省略,否则会导致配置失效
  • 如果你的组件需要多worker池(比如分布式训练场景),需要在worker_pool_specs列表中为每个worker池单独配置子网信息
  • 确保子网URI格式正确:通常格式为projects/[你的项目ID]/regions/[区域]/subnetworks/[子网名称],如果是全局VPC网络,格式需匹配你的实际网络配置

内容的提问来源于stack exchange,提问作者DarioB

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 10:05:35