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

Fix adding test nodes to DAGs built using LoadMethod.DBT_MANIFEST and LoadMethod.CUSTOM #615

Merged
merged 15 commits into from
Oct 30, 2023

Conversation

navedgaras
Copy link
Contributor

@navedgaras navedgaras commented Oct 19, 2023

Resolving issues with the DBT_MANIFEST/CUSTOM load methods when the has_test attribute is not assigned to the node correctly.

Description

When a tag selector is used, all tests are filtered out because of the DbtResourceType.TEST node does not have any information about tags. To bypass this limitation - tags are assigned to tests based on their parent model.

Related Issue(s)

Closes #580

Breaking Change?

The change should not be breaking anything.

Checklist

  • I have made corresponding changes to the documentation (if required)
  • I have added tests that prove my fix is effective or that my feature works

…ibute is not assigned to the node correctly
@navedgaras navedgaras requested a review from a team as a code owner October 19, 2023 13:39
@navedgaras navedgaras requested a review from a team October 19, 2023 13:39
@netlify
Copy link

netlify bot commented Oct 19, 2023

👷 Deploy Preview for amazing-pothos-a3bca0 processing.

Name Link
🔨 Latest commit 61fdeaf
🔍 Latest deploy log https://app.netlify.com/sites/amazing-pothos-a3bca0/deploys/653f633483986e0008dd05ea

@navedgaras navedgaras marked this pull request as draft October 19, 2023 13:46
@pre-commit-ci pre-commit-ci bot temporarily deployed to external October 19, 2023 13:48 Inactive
@tatiana
Copy link
Collaborator

tatiana commented Oct 20, 2023

Thank you very much for working on this, @edgga ! Please let us know if you'd like reviews. We'll assume that while it is in the draft, it's a work in progress, and we shouldn't review it yet.

@navedgaras navedgaras temporarily deployed to external October 23, 2023 07:59 — with GitHub Actions Inactive
@tatiana tatiana added this to the 1.3.0 milestone Oct 23, 2023
@navedgaras navedgaras temporarily deployed to external October 23, 2023 09:52 — with GitHub Actions Inactive
@navedgaras navedgaras marked this pull request as ready for review October 23, 2023 10:00
@navedgaras
Copy link
Contributor Author

Hello, @tatiana, I made a minor change that assigns tags to tests based on their parent model. It works as expected but I am not sure if this is the best approach. Would love to get some feedback!

@codecov
Copy link

codecov bot commented Oct 23, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c1a1406) 93.37% compared to head (61fdeaf) 93.38%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #615   +/-   ##
=======================================
  Coverage   93.37%   93.38%           
=======================================
  Files          53       53           
  Lines        2113     2115    +2     
=======================================
+ Hits         1973     1975    +2     
  Misses        140      140           
Files Coverage Δ
cosmos/dbt/selector.py 96.58% <100.00%> (+0.05%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@navedgaras navedgaras temporarily deployed to external October 24, 2023 06:06 — with GitHub Actions Inactive
Copy link
Collaborator

@tatiana tatiana left a comment

Choose a reason for hiding this comment

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

@edgga This seems like a very pragmatic solution to the problem, and it seems it allows us to have consistent behaviour on test tag-selection when using all the supported LoadMethod. Do you see any downside to this approach?

It would be great if we could add a test!

@navedgaras
Copy link
Contributor Author

@tatiana I could not think of any downsides, but it's very possible I haven't thought about every existing use case. Right, I could add some tests, I would like to clarify - should I only add tags for testing purposes only in manifest.json, or should I also make changes to the underlying DBT project for consistency?

@tatiana
Copy link
Collaborator

tatiana commented Oct 25, 2023

@edgga Since ATM, this change is meant to solve a custom selection issue, we can probably have it where you've implemented it, for now. In the future, if we see the need for it, we can move this change to the DbtGraph - WDYT?

…sts based on the has_test attribute + specifying tag in manifest.json for a couple of models.
@navedgaras navedgaras temporarily deployed to external October 26, 2023 10:48 — with GitHub Actions Inactive
@navedgaras navedgaras temporarily deployed to external October 26, 2023 11:01 — with GitHub Actions Inactive
@navedgaras
Copy link
Contributor Author

@tatiana, I have added a pretty basic test that checks the general functionality of the has_test attribute update when node selection based on a TAG is used. Not sure if that's enough though.

If you have any pointers on what else I need to do to get this merged, I am all ears, I would love to have this merged next week.

Copy link
Collaborator

@tatiana tatiana left a comment

Choose a reason for hiding this comment

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

@edgga thank you very much. This is looking very good!
I left a minor comment, and we'll release this as part of 1.2.2, next week.

tests/dbt/test_graph.py Show resolved Hide resolved
@navedgaras navedgaras temporarily deployed to external October 30, 2023 08:03 — with GitHub Actions Inactive
Copy link
Collaborator

@tatiana tatiana left a comment

Choose a reason for hiding this comment

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

Thank you very much, @edgga !

@tatiana tatiana changed the title resolving issues with the DBT_MANIFEST load method when has_test attr… Fix adding test nodes to DAGs built using LoadMethod.DBT_MANIFEST and LoadMethod.CUSTOM Oct 30, 2023
@tatiana tatiana merged commit 58de67e into astronomer:main Oct 30, 2023
40 checks passed
tatiana pushed a commit that referenced this pull request Nov 6, 2023
…nd `LoadMethod.CUSTOM` (#615)

Resolving issues with the DBT_MANIFEST/CUSTOM load methods when the
has_test attribute is not assigned to the node correctly.

## Description

When a tag selector is used, all tests are filtered out because of the
DbtResourceType.TEST node does not have any information about tags. To
bypass this limitation - tags are assigned to tests based on their
parent model.

## Related Issue(s)

Closes: #580

Co-authored-by: edgarasnavickas <[email protected]>
(cherry picked from commit 58de67e)
tatiana added a commit that referenced this pull request Nov 6, 2023
Bug fixes

* Support ProjectConfig.dbt_project_path = None & different paths for Rendering and Execution by @MrBones757 in #634
* Fix adding test nodes to DAGs built using LoadMethod.DBT_MANIFEST and LoadMethod.CUSTOM by @edgga in #615

Others

* Add pre-commit hook for McCabe max complexity check and fix errors by @jbandoro in #629
* Update contributing docs for running integration tests by @jbandoro in #638
* Fix CI issue running integration tests by @tatiana in #640 and #644
* pre-commit updates in #637
@tatiana tatiana mentioned this pull request Nov 6, 2023
tatiana pushed a commit that referenced this pull request Nov 6, 2023
…nd `LoadMethod.CUSTOM` (#615)

Resolving issues with the DBT_MANIFEST/CUSTOM load methods when the
has_test attribute is not assigned to the node correctly.

## Description

When a tag selector is used, all tests are filtered out because of the
DbtResourceType.TEST node does not have any information about tags. To
bypass this limitation - tags are assigned to tests based on their
parent model.

## Related Issue(s)

Closes: #580

Co-authored-by: edgarasnavickas <[email protected]>
(cherry picked from commit 58de67e)
tatiana added a commit that referenced this pull request Nov 6, 2023
Bug fixes

* Support ProjectConfig.dbt_project_path = None & different paths for Rendering and Execution by @MrBones757 in #634
* Fix adding test nodes to DAGs built using LoadMethod.DBT_MANIFEST and LoadMethod.CUSTOM by @edgga in #615

Others

* Add pre-commit hook for McCabe max complexity check and fix errors by @jbandoro in #629
* Update contributing docs for running integration tests by @jbandoro in #638
* Fix CI issue running integration tests by @tatiana in #640 and #644
* pre-commit updates in #637
tatiana added a commit that referenced this pull request Nov 7, 2023
Bug fixes

* Support ProjectConfig.dbt_project_path = None & different paths for Rendering and Execution by @MrBones757 in #634
* Fix adding test nodes to DAGs built using LoadMethod.DBT_MANIFEST and LoadMethod.CUSTOM by @edgga in #615

Others

* Add pre-commit hook for McCabe max complexity check and fix errors by @jbandoro in #629
* Update contributing docs for running integration tests by @jbandoro in #638
* Fix CI issue running integration tests by @tatiana in #640 and #644
* pre-commit updates in #637

(cherry picked from commit fa0620a)
arojasb3 pushed a commit to arojasb3/astronomer-cosmos that referenced this pull request Jul 14, 2024
Bug fixes

* Support ProjectConfig.dbt_project_path = None & different paths for Rendering and Execution by @MrBones757 in astronomer#634
* Fix adding test nodes to DAGs built using LoadMethod.DBT_MANIFEST and LoadMethod.CUSTOM by @edgga in astronomer#615

Others

* Add pre-commit hook for McCabe max complexity check and fix errors by @jbandoro in astronomer#629
* Update contributing docs for running integration tests by @jbandoro in astronomer#638
* Fix CI issue running integration tests by @tatiana in astronomer#640 and astronomer#644
* pre-commit updates in astronomer#637

(cherry picked from commit fa0620a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tag selector not working with tests using the manifest json
2 participants