Start a cluster
Clusters oftentimes are configured to turn off and run in IDLE mode after being inactive for a certain period of time. We can use the clusters service of the Databricks SDK to run a cluster that exists in the authenticated workspace.
Cet exercice fait partie du cours
Databricks with the Python SDK
Instructions
- Store value of environment variable
DATACAMP_CLUSTER_IDin a variable calledcluster_id. - Start cluster with id stored in environment variable
DATACAMP_CLUSTER_ID.
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
w = WorkspaceClient()
# Store value of the 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")