在自定义作业中指定服务账户

在自定义作业中指定服务账户

我们正在使用 Python 代码来启动一些自定义训练作业,我的问题是,即使使用服务帐户“[电子邮件保护]“要启动该作业,该作业内部使用“service-xxxxxxxxxxxxxxxx-compute@gcp-sa-aiplataform-cc.iam.gserviceaccount.com”帐户,是什么破坏了我的代码,因为第二个帐户没有所有 bigquery 权限,是否可以使用“[电子邮件保护]“?我尝试了几种方法,但都没有用。

def create_custom_job(
        project: str,
        display_name: str,
        container_image_uri: str,
        args: list,
        machine: str="n1-standard-4",
        location: str = "northamerica-northeast1",
        api_endpoint: str = "northamerica-northeast1-aiplatform.googleapis.com"
):
    client_options = {"api_endpoint": api_endpoint}
    client = aiplatform.gapic.JobServiceClient(client_options=client_options)
    custom_job = {
        "display_name": display_name,
        "job_spec": {
            "worker_pool_specs": [
                {
                    "machine_spec": {
                        "machine_type": machine,
                    },
                    "replica_count": 1,
                    "container_spec": {
                        "image_uri": container_image_uri,
                        "command": [],
                        "args": args,
                    },
                }
            ]

        },
    }
    parent = f"projects/{project}/locations/{location}"
    response = client.create_custom_job(parent=parent, custom_job=custom_job)
    return response
temp=create_custom_job(
            display_name="yyyyyyyyyyyyya",
            container_image_uri="container_image_path",
            args=["--a=c"],
            project='project_name',
            machine='n1-highmem-16'
        )

相关内容