LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Databricks with the Python SDK

Kurs anzeigen

Anleitung zur Übung

  • 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.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

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")
Code bearbeiten und ausführen