From 16e9388b7baacc3f1769fa2ae3774b95f308ef01 Mon Sep 17 00:00:00 2001 From: vikrant-sinha <63613816+vikrant-sinha@users.noreply.github.com> Date: Sat, 3 Jul 2021 00:09:58 +0530 Subject: [PATCH] fix: Attribute error Name while executing the sample code (#205) * Fix attribute error `Name` while getting the status of cluster `cluster.status.State.Name(cluster.status.state),` this code will throw an attribute error when executed because it's trying to access State.Name which is not a function of class ClusterStatus.State A better approach will be to use the `cluster.status.state.name` as State is of enum type * fix:attribute error Name while getting the status of cluster --- .../google-cloud-dataproc/samples/snippets/list_clusters.py | 2 +- .../samples/snippets/submit_job_to_cluster.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/google-cloud-dataproc/samples/snippets/list_clusters.py b/packages/google-cloud-dataproc/samples/snippets/list_clusters.py index f0e7bac348e8..916f1a541f9f 100644 --- a/packages/google-cloud-dataproc/samples/snippets/list_clusters.py +++ b/packages/google-cloud-dataproc/samples/snippets/list_clusters.py @@ -32,7 +32,7 @@ def list_clusters(dataproc, project, region): ( "{} - {}".format( cluster.cluster_name, - cluster.status.State.Name(cluster.status.state), + cluster.status.state.name ) ) ) diff --git a/packages/google-cloud-dataproc/samples/snippets/submit_job_to_cluster.py b/packages/google-cloud-dataproc/samples/snippets/submit_job_to_cluster.py index d613cf5b8609..35d329c550aa 100644 --- a/packages/google-cloud-dataproc/samples/snippets/submit_job_to_cluster.py +++ b/packages/google-cloud-dataproc/samples/snippets/submit_job_to_cluster.py @@ -137,7 +137,7 @@ def list_clusters_with_details(dataproc, project, region): ( "{} - {}".format( cluster.cluster_name, - cluster.status.State.Name(cluster.status.state), + cluster.status.state.name, ) ) )