Get startedGet started for free

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.

This exercise is part of the course

Databricks with the Python SDK

View Course

Exercise instructions

  • Store value of environment variable DATACAMP_CLUSTER_ID in a variable called cluster_id.
  • Start cluster with id stored in environment variable DATACAMP_CLUSTER_ID.

Hands-on interactive exercise

Have a go at this exercise by completing this sample 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")
Edit and Run Code