Allow TestBehavior.AFTER_EACH with DBT_MANIFEST load method #949
Labels
area:selector
Related to selector, like DAG selector, DBT selector, etc
parsing:dbt_manifest
Issues, questions, or features related to dbt_manifest parsing
Context
When running cosmos with LoadMode.DBT_MANIFEST, I noticed that all tests would disappear when trying to filter via
RenderConfig.select
. The tests show up properly when rendering the full dbt project (removing the select filter), so I assumed this issue was related to the select/exclude logic. I tested this on my own project as well as withcosmos_manifest_example.py
in this repo. Below are some screenshots of the behavior I observed with the example DAG in this repo.With
The tests show up properly here.
With
The tests do not show up once the
select=["+customers"]
is included in the RenderConfig.Upon further investigation, it seems as though this issue stems from the fact that test nodes are not included in the
depends_on
field inmanifest.json
. The logic in selector.py builds the dbt graph based on thisdepends_on
field and therefore winds up filtering out all test nodes so that they are not included in the filtered_nodes by this step in graph.pySolution
There's a few different ways we could update the logic to allow model filtering while maintaining the proper testing behavior.
update the update_node_dependency() method which gets called after the filtering process is completed. We can update the logic here to add any test nodes which are tests for a node in self.filtered_nodes.
update the resources dict to add all test nodes to the
depends_on
field of node(s) they are testing.update the selector.py logic to account for the fact that test nodes do not show up in the depends_on field of nodes they are testing. This is probably the most complex solution as it would require updating the filtering logic itself. It seems the
GraphSelector
class is the one that would need updating.I can put up a PR for option 1 but am open to any thoughts or suggestions on what makes the most sense. Also please let me know if there is an easier fix or workaround that I am missing. Thanks!
BTW I'm seeing a failure in the pre-commit mypy check even without any changes yet made on my feature branch. I noticed other PR's seem to skip that check, is that something I should be doing? Is there a way to skip it?
The text was updated successfully, but these errors were encountered: