Skip to content

Instantly share code, notes, and snippets.

@rndazurescript
Created April 2, 2020 19:34
Show Gist options
  • Save rndazurescript/6dabaacd907b3f3ed3dba4e45361a82c to your computer and use it in GitHub Desktop.
Save rndazurescript/6dabaacd907b3f3ed3dba4e45361a82c to your computer and use it in GitHub Desktop.
Versioning databricks workspace files
@echo off
REM Create a conda environment
conda create -n databricks pip
REM Activate environment
conda activate databricks
REM Ensure pip is located inside that environment
pip --version
REM Should have envs\databricks in the output like ...conda\envs\databricks\lib\site-packages\pip
REM Install databricks cli
pip install databricks-cli
REM The following command will prompt you for the following:
REM "Databricks Host (should begin with https://):" use https://westeurope.azuredatabricks.net/?o=1112223334444.
REM "Token:" generate a token following instructions from https://docs.databricks.com/dev-tools/api/latest/authentication.html#generate-a-token
databricks configure --token
REM To test that it worked enumerate the workspaces
databricks workspace ls
REM Create a folder locally where we will initialize a git repository
md testgitrepo
cd testgitrepo
REM Initialize git here
git init
REM Let's export the folder /Users/user to here
databricks workspace export_dir -o /Users/user ./
REM See the status of git
git status
REM Stage all changes (the new files)
git add .
REM Commit our original files
git commit -m "Initial version"
REM Got to your databricks workspace and make a change in one of the notebooks
REM Grab newest version
databricks workspace export_dir -o /Users/user ./
REM Check that this file changed
git status
REM Stage the change (. or the file path that appeared in status)
git add .
REM Check difference with current master (. or the file path that appeared in status)
git diff --cached .
REM Commit the staged changes
git commit -m "Modified version"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment