MulaiMulai sekarang secara gratis

Check that a cluster is running

We can use the clusters service in the Databricks SDK to retrieve information about a specified cluster. In this exercise, we are interested in looking at the state of a cluster. This informs us whether a cluster is Terminated, Idle or in a Running state. Assume that the id of the cluster we are interested in is stored in a variable called cluster_id.

Latihan ini adalah bagian dari kursus

Databricks with the Python SDK

Lihat Kursus

Petunjuk latihan

  • Retrieve cluster information for cluster with id stored in variable cluster_id.
  • Print the state of cluster to confirm it is running.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

w = WorkspaceClient()

# Retrieve cluster info for cluster with id stored in variable cluster_id
cluster_info = w.clusters.____(cluster_id)

# Print the state of cluster to confirm it is running
print(cluster_info.____)
Edit dan Jalankan Kode