开始使用免费开始使用

启动集群

许多集群会被配置为在一段时间未活动后自动关闭,并进入 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")
编辑并运行代码