Skip to content

Instantly share code, notes, and snippets.

@nescobar
Last active September 12, 2020 20:58
Show Gist options
  • Save nescobar/f751a9d49308d63351935601f3ac0143 to your computer and use it in GitHub Desktop.
Save nescobar/f751a9d49308d63351935601f3ac0143 to your computer and use it in GitHub Desktop.
Exports Databricks notebook
# Databricks access credentials
DOMAIN = 'ACCOUNT.cloud.databricks.com'
TOKEN = dbutils.secrets.get(scope="databricks", key="token")
BASE_URL = 'https://%s/api/2.0/jobs/runs/export?run_id=' % (DOMAIN)
# Exports notebook with given run id as a JSON object
def export_notebook(run_id):
views_to_export = '&views_to_export=DASHBOARDS'
response = requests.get(
BASE_URL + str(run_id) + views_to_export,
headers={'Authorization': 'Bearer %s' % TOKEN}
)
return response.json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment