forked from mshtelma/databricks_ml_demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckout-master.py
38 lines (26 loc) · 1.21 KB
/
checkout-master.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Databricks notebook source
# Initialize input widgets
dbutils.widgets.removeAll()
dbutils.widgets.text("admin-token", "", "Admin Token")
dbutils.widgets.text("databricks-instance", "", "Databricks Instance")
# COMMAND ----------
# Feel free to directly set the environment variables here, instead of setting them through widgets
import os
os.environ["ADMIN_TOKEN"] = dbutils.widgets.get("admin-token")
os.environ["DATABRICKS_INSTANCE"] = dbutils.widgets.get("databricks-instance")
# COMMAND ----------
# MAGIC %md
# MAGIC Optional check that environment variables are set correctly
# COMMAND ----------
# MAGIC %sh
# MAGIC echo $ADMIN_TOKEN
# MAGIC echo $DATABRICKS_INSTANCE
# COMMAND ----------
# MAGIC %md
# MAGIC #### Check that there is no folder named "Projects" in the root directory
# MAGIC You should get a `RESOURCE_DOES_NOT_EXIST` response here. If you don't, rename or delete the "Projects" folder in the root directory and migrate the jobs.
# COMMAND ----------
# MAGIC %sh
# MAGIC curl -n -X POST https://$DATABRICKS_INSTANCE/api/2.0/projects/fetch-and-checkout \
# MAGIC -H 'Authorization: Bearer '$ADMIN_TOKEN'' \
# MAGIC -d '{"path": "/Projects/[email protected]/demo", "branch": "main"}'