From cb0328f3bfec416be9aec34d027fe0f48aab4242 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 --- samples/snippets/list_clusters.py | 2 +- samples/snippets/submit_job_to_cluster.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/snippets/list_clusters.py b/samples/snippets/list_clusters.py index f0e7bac3..916f1a54 100644 --- a/samples/snippets/list_clusters.py +++ b/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/samples/snippets/submit_job_to_cluster.py b/samples/snippets/submit_job_to_cluster.py index d613cf5b..35d329c5 100644 --- a/samples/snippets/submit_job_to_cluster.py +++ b/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, ) ) )