cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Databricks Asset Bundles

Skr7
New Contributor II

Hi, I'm implementing Databricks Asset bundles, my scripts are in GitHub and my /resource has all the .yml of my Databricks workflow which are pointing to the main branch 

 

 

 

 

 git_source:
        git_url: https://github.com/xxxx
        git_provider: gitHubEnterprise
        git_branch: main

 

 

 

 

Now when I work with DABs, I create a feature branch and when I deploy and run my bundle, I want my databricks workflows to point to my feature branch, is there a way to dynamically change my git_branch to my feature branch when I deploy my bundle and run it.
Also, can we create a script to /resource/xx.yml mapping, the reason is that I don't want all my jobs to run when I run my bundle for a script change that is part of a single job 
@Kaniz Appreciate your input here

1 REPLY 1

Kaniz
Community Manager
Community Manager

Hi @Skr7 , Let’s break down your requirements:

  1. Dynamically Changing Git Branch for Databricks Asset Bundles (DABs): When deploying and running your DAB, you want the Databricks workflows to point to your feature branch instead of the main branch. Unfortunately, DABs do not inherently support dynamic branch switching during deployment.

    However, you can achieve this by following these steps:

    • Step 1: Create a Template Configuration File: Start by creating a template configuration file (e.g., config_template.yml) that includes placeholders for the Git branch and other relevant parameters. For example:

      git_source:
        git_url: https://github.com/xxxx
        git_provider: gitHubEnterprise
        git_branch: {{branch_placeholder}}
      
    • Step 2: Generate a Custom Configuration File: Before deploying your DAB, dynamically generate a custom configuration file (e.g., config.yml) by replacing the {{branch_placeholder}} with the actual feature branch name. You can use a script or a tool to achieve this. For instance, if you’re using Python, you can use a simple script to replace the placeholder with the desired branch name.

    • Step 3: Deploy the DAB with the Custom Configuration: During deployment, use the custom configuration file (config.yml) that points to your feature branch. This way, your Databricks workflows will use the correct Git branch.

  2. Selective Job Execution: To prevent all jobs from running when you make a script change that affects only a single job, consider the following approaches:

    • Option 1: Conditional Execution: Modify your Databricks notebooks or scripts to include conditional logic. For example, you can add a parameter (e.g., RUN_JOB) in your configuration or environment variables. Then, within each job, check this parameter. If it’s set to true, execute the job; otherwise, skip it.

    • Option 2: Job Tagging: Tag your Databricks jobs based on their purpose or impact. For instance, tag jobs as “critical,” “optional,” or “development.” When deploying your DAB, selectively execute jobs based on their tags. You can use the Databricks REST API or the Databricks CLI to manage job execution based on tags.

    Remember that these approaches require some manual setup and scripting, but they allow you to achieve the desired behaviour.

Keep in mind that while DABs provide a convenient way to package and deploy Databricks assets, customizing their behaviour often involves additional scripting or configuration management. Make sure to thoroughly test your solution in your specific environment to ensure it meets your requirements. 😊

To ensure we provide you with the best support, could you please take a moment to review the response and choose the one that best answers your question? Your feedback not only helps us assist you better but also benefits other community members who may have similar questions in the future.

If you found the answer helpful, consider giving it a kudo. If the response fully addresses your question, please mark it as the accepted solution. This will help us close the thread and ensure your question is resolved.

We appreciate your participation and are here to assist you further if you need it!