Create a client to initiate a Dataproc workflow template

Creates a client using application default credentials to initiate a Dataproc workflow template. Use either the global or a regional endpoint.

Code sample

Python

Before trying this sample, follow the Python setup instructions in the Dataproc quickstart using client libraries. For more information, see the Dataproc Python API reference documentation.

To authenticate to Dataproc, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.

if global_region:
    region = "global"
    # Use the default gRPC global endpoints.
    dataproc_workflow_client = dataproc_v1.WorkflowTemplateServiceClient()
else:
    region = get_region_from_zone(zone)
    # Use a regional gRPC endpoint. See:
    # https://cloud.google.com/dataproc/docs/concepts/regional-endpoints
    client_transport = workflow_template_service_grpc_transport.WorkflowTemplateServiceGrpcTransport(
        address=f"{region}-dataproc.googleapis.com:443"
    )
    dataproc_workflow_client = dataproc_v1.WorkflowTemplateServiceClient(
        client_transport
    )

What's next

To search and filter code samples for other Google Cloud products, see the Google Cloud sample browser.