Vinayak Pandey
Vinayak Pandey

Reputation: 141

Convert <type 'google.protobuf.pyext._message.RepeatedScalarContainer'> to list

I am trying to list a dataproc cluster to get the worker node names. The datatype that the code is returning is and I want to convert it to list

for cluster in dataproc_cluster_client.list_clusters(project_id, region):
    if cluster.cluster_name == 'test':
        print(type(cluster.config.worker_config.instance_names))
        print(type(cluster.config.master_config.instance_names))

Upvotes: 11

Views: 11085

Answers (3)

waykiki
waykiki

Reputation: 1094

For those wondering, conversion to numpy array can be done as simply as:

x = np.array(proto_object)

Upvotes: 0

user2350206
user2350206

Reputation: 185

Maybe

[_ for _ in cluster.config.worker_config.instance_names]

Upvotes: 1

Shristy
Shristy

Reputation: 131

list(cluster.config.worker_config.instance_names) to convert to a Python list

Upvotes: 12

Related Questions