啟動叢集
叢集通常會在一段時間未使用後設定為關閉,並以 IDLE 模式待命。你可以使用 Databricks SDK 的 clusters 服務,啟動已在已驗證工作區中的現有叢集。
本練習屬於課程
使用 Python SDK 的 Databricks
練習說明
- 將環境變數
DATACAMP_CLUSTER_ID的值儲存到名為cluster_id的變數中。 - 使用儲存在環境變數
DATACAMP_CLUSTER_ID中的 id 來啟動叢集。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
w = WorkspaceClient()
# Store value of environment variable as cluster_id
cluster_id = os.____['DATACAMP_CLUSTER_ID']
# Start cluster with id stored in cluster_id variable
try:
w.clusters.start(____=cluster_id).result()
except:
print(f"Cannot start cluster_id={cluster_id} because it is already running")