Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/plugin dbt parser #43

Merged
merged 16 commits into from
Nov 13, 2024
Merged

Feature/plugin dbt parser #43

merged 16 commits into from
Nov 13, 2024

Conversation

kiranvasudev
Copy link
Member

@kiranvasudev kiranvasudev commented Nov 7, 2024

Ticket: DATA-2081

Enabling dagger to import and use plugins. Given a folder that contains plugins(python modules), Dagger can now import the classes in these modules and enable their usage using jinja in the task configs.

How this is done:

  1. Add a new plugin attribute in the dagger_config.yaml:
plugin:
  paths:
    - <path relative to AIRFLOW_HOME>
    - 
  1. When above is added, all python classes in all modules are loaded into the Jinja environment using their class name.
  2. If you want to use this class using Jinja in the dagger task template, you just need to add {{ <class_name>.<function_name>() }} and it would replace this Jinja function call with the output of the function.

To test out the functionality, there are two ways:

First way

  1. Debug the tests in this file -> tests/utilities/test_plugins.py

Second way

  1. Modify this test to point to a main module config from airflow-dags and comment out the @skip. It should look like below:
    # @skip("Run only locally")
    def test_generate_task_configs(self):
        module = Module(
            path_to_config="/Users/kiran.vasudev/work/dataeng-airflow-dags/dags/analytics_engineering/pipelines/buyer_product_daily.yaml",
            target_dir="./tests/fixtures/modules/",
        )

        module.generate_task_configs()
  1. Set the AIRFLOW_HOME and create a plugin folder with a sample plugin(you can copy this from the tests/fixtures/plugins directory as an example)
  2. Run the test(easier from Pycharm i guess) and you should see the task config in the target_dir

Other changes:
Apart from introducing this plugin approach, i also disabled the use of the dbt_config_parser, so for dbt configs that are generated using code from this branch, the inputs and outputs will be null and the dbt_manifest is not available to the jinja environment.

@kiranvasudev kiranvasudev marked this pull request as ready for review November 7, 2024 15:18
@kiranvasudev kiranvasudev requested a review from a team as a code owner November 7, 2024 15:18
@siklosid
Copy link
Member

siklosid commented Nov 7, 2024

I don't understand the testing part in the PR description.

* add the plugins into jinja env directly
@kiranvasudev kiranvasudev force-pushed the feature/plugin-dbt-parser branch from afbd4b6 to b0173b8 Compare November 7, 2024 16:50
@kiranvasudev kiranvasudev force-pushed the feature/plugin-dbt-parser branch from b0173b8 to 450b544 Compare November 7, 2024 16:55
@kiranvasudev kiranvasudev requested a review from a team November 7, 2024 17:07
@kiranvasudev kiranvasudev force-pushed the feature/plugin-dbt-parser branch from f207b2b to c247d0d Compare November 8, 2024 12:30
@kiranvasudev kiranvasudev force-pushed the feature/plugin-dbt-parser branch from c247d0d to 98a6b55 Compare November 8, 2024 12:32
Copy link

swarmia bot commented Nov 11, 2024

✅  Linked to Task DATA-2081 · Move dbt parser logic away from dagger
➡️  Part of Epic DATA-136 · 📉 DataTechDebt

claudiazi
claudiazi previously approved these changes Nov 12, 2024
Copy link

@claudiazi claudiazi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so cooool!!!!

@kiranvasudev kiranvasudev merged commit 7554e62 into master Nov 13, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants