BookerE1
New Contributor III

Hello,

I can try to give you some possible solutions for your problem, based on the web search results that I found. Here are some suggestions:

  • Make sure that your Databricks workspace and your Azure DevOps account are properly connected and authenticated.
  • Check if your Databricks Repos update API call is using the correct parameters and values. You can refer to the Databricks Repos API documentation for more details. In particular, make sure that the repo-id parameter matches the ID of the repository that you want to update, and the branch parameter matches the name of the branch that you want to pull from.
  • Try adding a delay or a retry mechanism in your pipeline code, in case the Databricks Repos update API call takes some time to complete or fails intermittently. You can use the time module in Python to add a delay, or the requests module to handle retries. For example, you can modify your code as follows:

import requests as rq
import os
import time

access_token = os.environ["DATABRICKS_TOKEN_GENERATOR_ACCESS_TOKEN"]
url = "$(databrick-hostname)/api/2.0/repos/$(repo-id)"
headers = {'Authentication': f'Bearer {access_token}'}

# Add a delay of 10 seconds between each API call
time.sleep(10)

data = '{"branch": "main"}'
response = rq.patch(url, headers=headers, data = data)
print(response)

time.sleep(10)

data = '{"branch": "staging"}'
response = rq.patch(url, headers=headers, data = data)
print(response)

# Add a retry mechanism with 3 attempts and a backoff factor of 1 second
session = rq.Session()
adapter = rq.adapters.HTTPAdapter(max_retries=rq.packages.urllib3.util.retry.Retry(total=3, backoff_factor=1))
session.mount('https://', adapter)
session.mount('http://', adapter)

data = '{"branch": "main"}'
response = session.patch(url, headers=headers, data = data)
print(response)

data = '{"branch": "staging"}'
response = session.patch(url, headers=headers, data = data)
print(response)

 

I hope this helps you to fix your problem and update your Databricks local repo using your DevOps pipeline. If you have any other questions or requests, please let me know.