|
34 | 34 |
|
35 | 35 | from google.cloud import dataproc_v1 |
36 | 36 | from google.cloud import storage |
37 | | -from google.cloud.dataproc_v1.gapic.transports import cluster_controller_grpc_transport |
38 | | -from google.cloud.dataproc_v1.gapic.transports import job_controller_grpc_transport |
39 | 37 |
|
40 | 38 |
|
41 | 39 | DEFAULT_FILENAME = "pyspark_sort.py" |
@@ -77,10 +75,8 @@ def download_output(project, cluster_id, output_bucket, job_id): |
77 | 75 | print("Downloading output file.") |
78 | 76 | client = storage.Client(project=project) |
79 | 77 | bucket = client.get_bucket(output_bucket) |
80 | | - output_blob = ( |
81 | | - "google-cloud-dataproc-metainfo/{}/jobs/{}/driveroutput.000000000".format( |
82 | | - cluster_id, job_id |
83 | | - ) |
| 78 | + output_blob = "google-cloud-dataproc-metainfo/{}/jobs/{}/driveroutput.000000000".format( |
| 79 | + cluster_id, job_id |
84 | 80 | ) |
85 | 81 | return bucket.blob(output_blob).download_as_string() |
86 | 82 |
|
@@ -135,14 +131,7 @@ def list_clusters_with_details(dataproc, project, region): |
135 | 131 | for cluster in dataproc.list_clusters( |
136 | 132 | request={"project_id": project, "region": region} |
137 | 133 | ): |
138 | | - print( |
139 | | - ( |
140 | | - "{} - {}".format( |
141 | | - cluster.cluster_name, |
142 | | - cluster.status.state.name, |
143 | | - ) |
144 | | - ) |
145 | | - ) |
| 134 | + print(("{} - {}".format(cluster.cluster_name, cluster.status.state.name,))) |
146 | 135 |
|
147 | 136 |
|
148 | 137 | # [END dataproc_list_clusters_with_detail] |
@@ -232,16 +221,12 @@ def main( |
232 | 221 | region = get_region_from_zone(zone) |
233 | 222 | # Use a regional gRPC endpoint. See: |
234 | 223 | # https://cloud.google.com/dataproc/docs/concepts/regional-endpoints |
235 | | - client_transport = ( |
236 | | - cluster_controller_grpc_transport.ClusterControllerGrpcTransport( |
237 | | - address="{}-dataproc.googleapis.com:443".format(region) |
238 | | - ) |
| 224 | + dataproc_cluster_client = dataproc_v1.ClusterControllerClient( |
| 225 | + client_options={"api_endpoint": f"{region}-dataproc.googleapis.com:443"} |
239 | 226 | ) |
240 | | - job_transport = job_controller_grpc_transport.JobControllerGrpcTransport( |
241 | | - address="{}-dataproc.googleapis.com:443".format(region) |
| 227 | + dataproc_job_client = dataproc_v1.ClusterControllerClient( |
| 228 | + client_options={"api_endpoint": f"{region}-dataproc.googleapis.com:443"} |
242 | 229 | ) |
243 | | - dataproc_cluster_client = dataproc_v1.ClusterControllerClient(client_transport) |
244 | | - dataproc_job_client = dataproc_v1.JobControllerClient(job_transport) |
245 | 230 | # [END dataproc_get_client] |
246 | 231 |
|
247 | 232 | try: |
|
0 commit comments