Search code examples
databricksdatabricks-clidatabricks-rest-api

Databricks REST API: move Repo to Workspace Folder


I am using the Python Databricks REST API. I create folder in the workspace:

workspace_api = WorkspaceApi(api_client)    
workspace_api.mkdirs("/Users/xxxx/myfirstrepo")

Then, I checkout a repo:

repos_api = ReposApi(api_client)
repos_api.create("https://github.com/xxx","github","/Repos/xxx/freshRepo")

Now, I want to copy the content of the repo to the workspace folder myfirstrepo. How can I do this?

Thanks


Solution

  • You can't do this as a single operation - these are different object types.

    There are few approaches to that:

    • checkout the Git repository to the local disk and then use import_dir command from the Databricks CLI (doc)

    • list all files in repository, export each file with REST API export command, and then import it with corresponding REST API command