開始使用免費開始

檢查叢集是否正在執行

你可以使用 Databricks SDK 的 clusters 服務來擷取指定叢集的資訊。在本練習中,我們關注叢集的 state。這可告訴我們叢集是 Terminated、Idle,還是處於 Running 狀態。 假設我們關心的叢集 id 已儲存在名為 cluster_id 的變數中。

本練習屬於課程

使用 Python SDK 的 Databricks

檢視課程

練習說明

  • 擷取 cluster_id 變數所儲存 id 的叢集資訊。
  • 印出叢集的 state,確認它正在執行。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

w = WorkspaceClient()

# Retrieve info for the specified cluster
cluster_info = w.clusters.____(cluster_id)

# Print the state of the cluster
print(cluster_info.____)
編輯並執行程式碼